初始化模板腳本實現
1、查看 cat /etc/redhat-release 確認是centos7還是centos6
2、檢查是否能ping www.baidu.com 不能的話檢查 vim /etc/resolv.conf
3、設置主機名,請檢查hostname
4、關閉selinux
5、關閉防火牆
6、查看內存 cpu 硬盤大小
7、換成阿里雲的的源 //這裏需要一個人爲的判斷,是否換成阿里雲的源 是爲換 不是爲不換
8、下載必要的初始化的工具 //yum -y install net-tools tree nmap lrzsz dos2unix telnet screen vim lsof wget ntp rsync
9、修改IP和主機名的對應關係
10、查看時間 並設置初始化時間
11、設置linux的最大文件打開數
12、centos6系統設置grep加顏色別名
13、centos7特有的默認還有進程數限制/etc/security/limits.d/20-nproc.conf
14、禁止內存巨大頁
15、禁止swap交換(可選)
16、ssh優化,正反向解析 //這一步在腳本中,沒有寫,
sed -i "s/#UseDNS yes/UseDNS no/g" /etc/ssh/sshd_config && sed -i "s/GSSAPIAuthentication yes/GSSAPIAuthentication no/g" /etc/ssh/sshd_config
ssh 連接緩慢解決方法
http://blog.chinaunix.net/uid-16728139-id-3435980.html
修改後,別忘了重啓sshd服務
service sshd restart
17、 //hbase要設置的 關鍵是當內存爲8G的時候這樣設置
set vm.min_free_kbytes to least 1GB(8GB on larger memory systems)
//該文件表示強制Linux VM最低保留多少空閒內存(Kbytes)。 //代表系統所保留空閒內存的最低限
官方文檔中要求min_free_kbytes不能小於1G(在大內存系統中設置8G),就是不要輕易觸發直接回收。
當可用內存低於這個參數時,系統開始回收cache內存,以釋放內存,直到可用內存大於這個值。
vm.min_free_kbytes=409600;
vm.vfs_cache_pressure=200;
vm.swappiness=40。
調整MIN_FREE_KBYTES的目的是保持物理內存有足夠的空閒空間,防止突發性的換頁。
swapiness缺省爲60,減少swapiness會使系統儘快通過swapout不使用的進程資源來釋放更多的物理內存。
vfs_cache_pressure的缺省值是100,加大這個參數設置了虛擬內存回收directory和i-node緩衝的傾向,這個值越大,回收的傾向越嚴重。調整這3個參數的目的就是讓操作系統在平時就儘快回收緩衝,釋放物理內存,這樣就可以避免突發性的大規模換頁。
https://blog.csdn.net/hanyingzhong/article/details/71637391?utm_source=blogxgwz0
具體操作如下:
[root@NewCDH-0--141 ~]# cat /proc/sys/vm/min_free_kbytes //原來的
67584
[root@NewCDH-0--141 ~]# cat /proc/sys/vm/min_free_kbytes //設置成
1048576
[root@NewCDH-0--141 ~]# ll /proc/sys/vm/|wc -l
42
18、4、disable numa zone reclaim with vm.zone_reclaim_mode = 0
//官方建議把vm.zone_reclaim_mode = 0 設置成0
[root@NewCDH-0--141 vm]# cat /proc/sys/vm/zone_reclaim_mode //這個參數系統默認就是0
0
//UMA是什麼?NUMA和swap有什麼關係?zone_reclaim_mode的具體意義?
zone_reclaim_mode,這個參數定義了NUMA架構下不同的內存回收策略,可以取值0/1/3/4,其中0表示在local內存不夠用的情況下可以去其他的內存區域分配內存;1表示在local內存不夠用的情況下本地先回收再分配;3表示本地回收儘可能先回收文件緩存對象;4表示本地回收優先使用swap回收匿名內存。
19、注意在使用中,可能centos7也安裝了iptables 遇到問題的時候,需要檢查此項 //腳本中沒有寫,需要手動檢查
centos7關閉iptables的命令
/bin/systemctl stop iptables.service
systemctl disable iptables.service
#!/bin/bash
#initialization scripts
#author majihui
#date 20190313
#by hadoop
if [ ! -d "/opt/scripts" ]; then
mkdir -p /opt/scripts
fi
echo "等待1s:#1/判斷centos7還是centos6系統"
sleep 1
VERSION=`cat /etc/redhat-release|awk -F " " '{print $3}'|awk -F "." '{print $1}'`
if [ "$VERSION" == "6" ];then
VERSION='6'
echo "centos6"
else
VERSION='7'
echo "centos7"
fi
echo "-----------------------------分隔符----------------------------------------"
echo "等待2s:#2/檢查是否能ping 通百度"
sleep 1
echo "1S"
sleep 1
echo "2S"
PING=`ping -c 3 www.baidu.com`
if [ "$?" -ne 0 ];then
echo "ping 不通 baidu 請檢查 /etc/resolv.conf"
exit 1
else
echo "能ping 通 baidu"
fi
echo "-----------------------------分隔符----------------------------------------"
echo "等待5s: #3/請檢查hostname 若沒設置請 ctrl+c 退出設置"
sleep 1
echo "1S"
sleep 2
echo "2S"
sleep 3
echo "3S"
sleep 4
echo "4S"
sleep 5
echo "5S"
echo "-----------------------------分隔符----------------------------------------"
echo "等待2S:#4/關閉selinux "
sleep 2
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0
echo "-----------------------------分隔符----------------------------------------"
echo "等待2S:#5/關閉防火牆,並設置關閉開機自啓動"
sleep 2
if [ "$VERSION" == "7" ];then
systemctl stop firewalld && systemctl disable firewalld
else
service iptables stop && chkconfig iptables off
fi
echo "-----------------------------分隔符----------------------------------------"
echo "等待1S:#6/查看內存 cpu 硬盤大小"
sleep 1
MEM=`free -m`
#4.1查看物理CPU個數
physical_id=`cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l`
#4.2查看每個物理CPU中core的個數(即核數)
cpu_cores=`cat /proc/cpuinfo| grep "cpu cores"| uniq`
#4.3查看邏輯CPU的個數
processor=`cat /proc/cpuinfo| grep "processor"| wc -l`
echo "$MEM"
echo "####################################################"
echo "cpu物理個數 physical_id: $physical_id"
echo "每個cpu中core的個數(即核數) $cpu_cores"
echo "邏輯cpu的個數 processor: $processor"
echo "####################################################"
#4.4硬盤大小
disk=`df -Th`
echo "$disk"
echo "-----------------------------分隔符----------------------------------------"
echo "等待2S:#7/是否換成阿里雲的的源 "
sleep 3
cat << EOF
**********************
1.[change aliyuan]
2.[no change aliyuan]
3.[exit]
pls input the num you want:
**********************
EOF
read -t 30 -p "pls input the num you want:" a
[ -n "`echo $a|sed 's#[0-9]##g'`" ] && {
}
iffuncation(){
if [ $a -eq 1 ];then
echo "change aliyuan"
echo "等待3S"
sleep 3
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
if [ "$VERSION" == "7" ];then
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
else
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum makecache
echo "等待3S"
sleep 3
elif [ $a -eq 2 ];then
echo "no change aliyuan"
elif [ $a -eq 3 ];then
exit 1
else
echo "Input error"
exit 1
fi
}
iffuncation
echo "-----------------------------分隔符----------------------------------------"
echo "等待3S:#8/下載必要的初始化的工具"
sleep 3
echo "-----------------------------分隔符----------------------------------------"
echo "等待3S:#9/修改ip和主機名的對應關係 /etc/hosts"
sleep 3
cat > /etc/hosts << EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
EOF
if [ "$VERSION" == "7" ];then
echo "`ifconfig|sed -n '2p'|awk -F " " '{print $2}'` $HOSTNAME" >> /etc/hosts
else
fi
echo "-----------------------------分隔符----------------------------------------"
echo "等待3S:#10/查看時間 並設置初始化時間"
date +%F\ %T
ntpdate cn.pool.ntp.org && hwclock -w
echo "-----------------------------分隔符----------------------------------------"
echo "#11/設置linux的最大文件打開數"
ulimit -SHn 65535
ulimit -a
#!/bin/bash
#initialization scripts
#author majihui
#date 20190313
#by hadoop
if [ ! -d "/opt/scripts" ]; then
mkdir -p /opt/scripts
fi
echo "等待1s:#1/判斷centos7還是centos6系統"
sleep 1
#!/bin/bash
#initialization scripts
#author majihui
#date 20190313
#by hadoop
if [ ! -d "/opt/scripts" ]; then
mkdir -p /opt/scripts
fi
echo "等待1s:#1/判斷centos7還是centos6系統"
sleep 1
VERSION=`cat /etc/redhat-release|awk -F " " '{print $3}'|awk -F "." '{print $1}'`
if [ "$VERSION" == "6" ];then
VERSION='6'
echo "centos6"
else
VERSION='7'
echo "centos7"
fi
echo "-----------------------------分隔符----------------------------------------"
echo "等待2s:#2/檢查是否能ping 通百度"
sleep 1
echo "1S"
sleep 1
echo "2S"
PING=`ping -c 3 www.baidu.com`
if [ "$?" -ne 0 ];then
echo "ping 不通 baidu 請檢查 /etc/resolv.conf"
exit 1
else
echo "能ping 通 baidu"
fi
echo "-----------------------------分隔符----------------------------------------"
echo "等待5s: #3/請檢查hostname 若沒設置請 ctrl+c 退出設置"
sleep 1
echo "1S"
sleep 2
echo "2S"
sleep 3
echo "3S"
sleep 4
echo "4S"
sleep 5
echo "5S"
echo "-----------------------------分隔符----------------------------------------"
echo "等待2S:#4/關閉selinux "
sleep 2
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0
echo "-----------------------------分隔符----------------------------------------"
echo "等待2S:#5/關閉防火牆,並設置關閉開機自啓動"
sleep 2
if [ "$VERSION" == "7" ];then
systemctl stop firewalld && systemctl disable firewalld
else
service iptables stop && chkconfig iptables off
fi
echo "-----------------------------分隔符----------------------------------------"
echo "等待1S:#6/查看內存 cpu 硬盤大小"
sleep 1
MEM=`free -m`
#4.1查看物理CPU個數
physical_id=`cat /proc/cpuinfo| grep "physical id"| sort| uniq| wc -l`
#4.2查看每個物理CPU中core的個數(即核數)
cpu_cores=`cat /proc/cpuinfo| grep "cpu cores"| uniq`
#4.3查看邏輯CPU的個數
processor=`cat /proc/cpuinfo| grep "processor"| wc -l`
echo "$MEM"
echo "####################################################"
echo "cpu物理個數 physical_id: $physical_id"
echo "每個cpu中core的個數(即核數) $cpu_cores"
echo "邏輯cpu的個數 processor: $processor"
echo "####################################################"
#4.4硬盤大小
disk=`df -Th`
echo "$disk"
echo "-----------------------------分隔符----------------------------------------"
echo "等待2S:#7/是否換成阿里雲的的源 "
sleep 3
cat << EOF
**********************
1.[change aliyuan]
2.[no change aliyuan]
3.[exit]
pls input the num you want:
**********************
EOF
read -t 30 -p "pls input the num you want:" a
[ -n "`echo $a|sed 's#[0-9]##g'`" ] && {
}
iffuncation(){
if [ $a -eq 1 ];then
echo "change aliyuan"
echo "等待3S"
sleep 3
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
if [ "$VERSION" == "7" ];then
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
else
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum makecache
echo "等待3S"
sleep 3
elif [ $a -eq 2 ];then
echo "no change aliyuan"
elif [ $a -eq 3 ];then
exit 1
else
echo "Input error"
exit 1
fi
}
iffuncation
echo "-----------------------------分隔符----------------------------------------"
echo "等待3S:#8/下載必要的初始化的工具"
sleep 3
echo "-----------------------------分隔符----------------------------------------"
echo "等待3S:#9/修改ip和主機名的對應關係 /etc/hosts"
sleep 3
cat > /etc/hosts << EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
EOF
if [ "$VERSION" == "7" ];then
echo "`ifconfig|sed -n '2p'|awk -F " " '{print $2}'` $HOSTNAME" >> /etc/hosts
else
fi
echo "-----------------------------分隔符----------------------------------------"
echo "等待3S:#10/查看時間 並設置初始化時間"
date +%F\ %T
ntpdate cn.pool.ntp.org && hwclock -w
echo "-----------------------------分隔符----------------------------------------"
echo "#11/設置linux的最大文件打開數"
ulimit -SHn 65535
ulimit -a
if [ "`egrep "* - nofile 65535|* - nproc 65536" /etc/security/limits.conf|wc -l`" == "0" ];then
echo "* - nofile 65535" >> /etc/security/limits.conf
echo "* - nproc 65536" >> /etc/security/limits.conf
else
echo "linux的最大文件打開數 設置成功或者之前已經設置過了"
fi
sleep 2
echo "-----------------------------分隔符----------------------------------------"
echo "#12/centos6系統設置grep加顏色別名"
if [ "$VERSION" == "6" ];then
if [ "`egrep "alias grep='grep --color=auto'" /etc/profile|wc -l`" == "0" ];then
echo "alias grep='grep --color=auto'" >>/etc/profile
source /etc/profile
else
echo "centos6系統設置grep加顏色別名 設置成功或者之前已經設置過了"
fi
fi
echo "-----------------------------分隔符----------------------------------------"
echo "#13/centos7特有的默認還有進程數限制/etc/security/limits.d/20-nproc.conf"
if [ "$VERSION" == "7" ];then
sed -i 's#4096#65536#g' /etc/security/limits.d/20-nproc.conf
fi
echo "-----------------------------分隔符----------------------------------------"
echo "#14/禁止內存巨大頁"
if [ "`egrep "transparent_hugepage" /etc/rc.d/rc.local |wc -l`" == "0" ];then
echo "echo 'never' >/sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.d/rc.local
echo "echo 'never' >/sys/kernel/mm/transparent_hugepage/defrag" >> /etc/rc.d/rc.local
else
echo "禁止內存巨大頁 設置成功或者之前已經設置過了"
fi
chmod +x /etc/rc.d/rc.local
echo "-----------------------------分隔符----------------------------------------"
echo "#15/禁止swap交換"
if [ "`egrep "vm.swappiness=0" /etc/sysctl.conf|wc -l`" == "0" ];then
echo "vm.swappiness=0" >> /etc/sysctl.conf
sysctl -p
else
echo "禁止swap交換 設置成功或者之前已經設置過了"
fi
[root@emm-kafka02-10--175 opt]# sh initialization.sh
等待1s:#1/判斷centos7還是centos6系統
centos7
-----------------------------分隔符----------------------------------------
等待2s:#2/檢查是否能ping 通百度
1S
2S
能ping 通 baidu
-----------------------------分隔符----------------------------------------
等待5s: #3/請檢查hostname 若沒設置請 ctrl+c 退出設置
1S
2S
3S
4S
5S
-----------------------------分隔符----------------------------------------
等待2S:#4/關閉selinux
setenforce: SELinux is disabled
-----------------------------華麗分隔符----------------------------------------
等待2S:#5/關閉防火牆,並設置關閉開機自啓動
Warning: firewalld.service changed on disk. Run 'systemctl daemon-reload' to reload units.
-----------------------------華麗分隔符----------------------------------------
等待1S:#6/查看內存 cpu 硬盤大小
total used free shared buff/cache available
Mem: 3790 115 3442 8 232 3431
Swap: 3967 0 3967
####################################################
cpu物理個數 physical_id: 4
每個cpu中core的個數(即核數) cpu cores : 1
邏輯cpu的個數 processor: 4
####################################################
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 46G 2.0G 44G 5% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 1.9G 8.8M 1.9G 1% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 497M 161M 337M 33% /boot
tmpfs tmpfs 380M 0 380M 0% /run/user/0
-----------------------------分隔符----------------------------------------
等待2S:#7/是否換成阿里雲的的源
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 5.4 kB 00:00:00
* base: mirrors.cn99.com
* epel: fedora.cs.nctu.edu.tw
* extras: mirrors.163.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/6): extras/7/x86_64/primary_db | 180 kB 00:00:00
(2/6): base/7/x86_64/group_gz | 166 kB 00:00:00
(3/6): updates/7/x86_64/primary_db | 2.5 MB 00:00:01
(4/6): epel/x86_64/primary_db | 6.6 MB 00:00:03
(5/6): base/7/x86_64/primary_db | 6.0 MB 00:00:07
(6/6): epel/x86_64/updateinfo | 1.0 MB 00:00:27
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-15.el7_4.1 will be updated
---> Package wget.x86_64 0:1.14-18.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================
Package Arch Version Repository Size
===============================================================================================================
Updating:
wget x86_64 1.14-18.el7 base 547 k
Transaction Summary
===============================================================================================================
Upgrade 1 Package
Total download size: 547 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
wget-1.14-18.el7.x86_64.rpm | 547 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : wget-1.14-18.el7.x86_64 1/2
Cleanup : wget-1.14-15.el7_4.1.x86_64 2/2
Verifying : wget-1.14-18.el7.x86_64 1/2
Verifying : wget-1.14-15.el7_4.1.x86_64 2/2
Updated:
wget.x86_64 0:1.14-18.el7
Complete!
等待3秒:
**********************
1.[change aliyuan]
2.[no change aliyuan]
3.[exit]
pls input the num you want:
**********************
pls input the num you want:1
change aliyuan
等待3S
--2019-03-13 15:14:40-- http://mirrors.aliyun.com/repo/Centos-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 117.91.183.229, 117.91.183.231, 117.91.183.233, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|117.91.183.229|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2523 (2.5K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/CentOS-Base.repo’
100%[=====================================================================>] 2,523 --.-K/s in 0s
2019-03-13 15:14:41 (155 MB/s) - ‘/etc/yum.repos.d/CentOS-Base.repo’ saved [2523/2523]
Loaded plugins: fastestmirror
Cleaning repos: base epel extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink | 5.8 kB 00:00:00
* base: mirrors.aliyun.com
* epel: fedora.cs.nctu.edu.tw
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/18): base/7/x86_64/group_gz | 166 kB 00:00:00
(2/18): base/7/x86_64/other_db | 2.6 MB 00:00:00
(3/18): epel/x86_64/group_gz | 88 kB 00:00:00
epel/x86_64/filelists_db FAILED
https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/repodata/15c9bc6ab4eb0de733e3ffded9b59486d1f560cc170c3b5f50911653154b6620-filelists.sqlite.bz2: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
(4/18): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(5/18): epel/x86_64/prestodelta | 2.4 kB 00:00:00
(6/18): extras/7/x86_64/filelists_db | 231 kB 00:00:00
(7/18): extras/7/x86_64/prestodelta | 47 kB 00:00:00
(8/18): extras/7/x86_64/primary_db | 180 kB 00:00:00
(9/18): extras/7/x86_64/other_db | 118 kB 00:00:00
(10/18): updates/7/x86_64/filelists_db | 2.2 MB 00:00:01
(11/18): updates/7/x86_64/prestodelta | 358 kB 00:00:00
(12/18): epel/x86_64/other_db | 3.2 MB 00:00:01
(13/18): updates/7/x86_64/primary_db | 2.5 MB 00:00:00
epel/x86_64/primary_db FAILED
https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/repodata/de7e09448b5d5642db87344f87c2f3b196859a57de980871f867df3a959563ff-primary.sqlite.bz2: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
(14/18): epel/x86_64/filelists_db | 11 MB 00:00:09
(15/18): epel/x86_64/primary_db | 6.6 MB 00:00:05
base/7/x86_64/primary_db FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6614b3605d961a4aaec45d74ac4e5e713e517debb3ee454a1c91097955780697-primary.sqlite.bz2: [Errno 12] Timeout on http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/6614b3605d961a4aaec45d74ac4e5e713e517debb3ee454a1c91097955780697-primary.sqlite.bz2: (28, 'Connection timed out after 30000 milliseconds')
Trying other mirror.
base/7/x86_64/filelists_db FAILED
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/a0ec5a4708a1026db100d4799c404c9ed48a9371a4bab234a1355f86628a244a-filelists.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/a0ec5a4708a1026db100d4799c404c9ed48a9371a4bab234a1355f86628a244a-filelists.sqlite.bz2: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
(16/18): base/7/x86_64/primary_db | 6.0 MB 00:00:01
updates/7/x86_64/other_db FAILED 1.3 MB/s | 41 MB 00:00:02 ETA
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/9601d8acc7720a70e4ed2a1d0b36dd5848c50fbd1bf8307f31d16906b182b238-other.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/9601d8acc7720a70e4ed2a1d0b36dd5848c50fbd1bf8307f31d16906b182b238-other.sqlite.bz2: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
(17/18): base/7/x86_64/filelists_db | 7.1 MB 00:00:03
(18/18): updates/7/x86_64/other_db | 351 kB 00:00:01
Metadata Cache Created
等待3S
-----------------------------分隔符----------------------------------------
等待3S:#8/下載必要的初始化的工具
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: fedora.cs.nctu.edu.tw
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package tree-1.6.0-10.el7.x86_64 already installed and latest version
Package lrzsz-0.12.20-36.el7.x86_64 already installed and latest version
Package wget-1.14-18.el7.x86_64 already installed and latest version
Package rsync-3.1.2-4.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package dos2unix.x86_64 0:6.0.3-7.el7 will be installed
---> Package lsof.x86_64 0:4.87-5.el7 will be updated
---> Package lsof.x86_64 0:4.87-6.el7 will be an update
---> Package net-tools.x86_64 0:2.0-0.22.20131004git.el7 will be updated
---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be an update
---> Package nmap.x86_64 2:6.40-16.el7 will be installed
--> Processing Dependency: nmap-ncat = 2:6.40-16.el7 for package: 2:nmap-6.40-16.el7.x86_64
---> Package ntp.x86_64 0:4.2.6p5-28.el7.centos will be installed
--> Processing Dependency: libopts.so.25()(64bit) for package: ntp-4.2.6p5-28.el7.centos.x86_64
---> Package screen.x86_64 0:4.1.0-0.25.20120314git3c2946.el7 will be installed
---> Package telnet.x86_64 1:0.17-64.el7 will be installed
---> Package vim-enhanced.x86_64 2:7.4.160-4.el7 will be updated
---> Package vim-enhanced.x86_64 2:7.4.160-5.el7 will be an update
--> Processing Dependency: vim-common = 2:7.4.160-5.el7 for package: 2:vim-enhanced-7.4.160-5.el7.x86_64
--> Running transaction check
---> Package autogen-libopts.x86_64 0:5.18-5.el7 will be installed
---> Package nmap-ncat.x86_64 2:6.40-16.el7 will be installed
---> Package vim-common.x86_64 2:7.4.160-4.el7 will be updated
---> Package vim-common.x86_64 2:7.4.160-5.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================
Package Arch Version Repository Size
===============================================================================================================
Installing:
dos2unix x86_64 6.0.3-7.el7 base 74 k
nmap x86_64 2:6.40-16.el7 base 3.9 M
ntp x86_64 4.2.6p5-28.el7.centos base 549 k
screen x86_64 4.1.0-0.25.20120314git3c2946.el7 base 552 k
telnet x86_64 1:0.17-64.el7 base 64 k
Updating:
lsof x86_64 4.87-6.el7 base 331 k
net-tools x86_64 2.0-0.24.20131004git.el7 base 306 k
vim-enhanced x86_64 2:7.4.160-5.el7 base 1.0 M
Installing for dependencies:
autogen-libopts x86_64 5.18-5.el7 base 66 k
nmap-ncat x86_64 2:6.40-16.el7 base 206 k
Updating for dependencies:
vim-common x86_64 2:7.4.160-5.el7 base 5.9 M
Transaction Summary
===============================================================================================================
Install 5 Packages (+2 Dependent packages)
Upgrade 3 Packages (+1 Dependent package)
Total download size: 13 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/11): autogen-libopts-5.18-5.el7.x86_64.rpm | 66 kB 00:00:00
(2/11): dos2unix-6.0.3-7.el7.x86_64.rpm | 74 kB 00:00:00
(3/11): lsof-4.87-6.el7.x86_64.rpm | 331 kB 00:00:00
(4/11): net-tools-2.0-0.24.20131004git.el7.x86_64.rpm | 306 kB 00:00:00
(5/11): nmap-ncat-6.40-16.el7.x86_64.rpm | 206 kB 00:00:00
(6/11): nmap-6.40-16.el7.x86_64.rpm | 3.9 MB 00:00:00
(7/11): ntp-4.2.6p5-28.el7.centos.x86_64.rpm | 549 kB 00:00:00
(8/11): screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm | 552 kB 00:00:00
(9/11): telnet-0.17-64.el7.x86_64.rpm | 64 kB 00:00:00
(10/11): vim-enhanced-7.4.160-5.el7.x86_64.rpm | 1.0 MB 00:00:00
(11/11): vim-common-7.4.160-5.el7.x86_64.rpm | 5.9 MB 00:00:02
---------------------------------------------------------------------------------------------------------------
Total 3.3 MB/s | 13 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 2:vim-common-7.4.160-5.el7.x86_64 1/15
Installing : 2:nmap-ncat-6.40-16.el7.x86_64 2/15
Installing : autogen-libopts-5.18-5.el7.x86_64 3/15
Installing : ntp-4.2.6p5-28.el7.centos.x86_64 4/15
Installing : 2:nmap-6.40-16.el7.x86_64 5/15
Updating : 2:vim-enhanced-7.4.160-5.el7.x86_64 6/15
Installing : dos2unix-6.0.3-7.el7.x86_64 7/15
Installing : screen-4.1.0-0.25.20120314git3c2946.el7.x86_64 8/15
Updating : lsof-4.87-6.el7.x86_64 9/15
Updating : net-tools-2.0-0.24.20131004git.el7.x86_64 10/15
Installing : 1:telnet-0.17-64.el7.x86_64 11/15
Cleanup : 2:vim-enhanced-7.4.160-4.el7.x86_64 12/15
Cleanup : 2:vim-common-7.4.160-4.el7.x86_64 13/15
Cleanup : lsof-4.87-5.el7.x86_64 14/15
Cleanup : net-tools-2.0-0.22.20131004git.el7.x86_64 15/15
Verifying : 1:telnet-0.17-64.el7.x86_64 1/15
Verifying : 2:vim-enhanced-7.4.160-5.el7.x86_64 2/15
Verifying : 2:nmap-6.40-16.el7.x86_64 3/15
Verifying : net-tools-2.0-0.24.20131004git.el7.x86_64 4/15
Verifying : ntp-4.2.6p5-28.el7.centos.x86_64 5/15
Verifying : autogen-libopts-5.18-5.el7.x86_64 6/15
Verifying : lsof-4.87-6.el7.x86_64 7/15
Verifying : screen-4.1.0-0.25.20120314git3c2946.el7.x86_64 8/15
Verifying : 2:nmap-ncat-6.40-16.el7.x86_64 9/15
Verifying : 2:vim-common-7.4.160-5.el7.x86_64 10/15
Verifying : dos2unix-6.0.3-7.el7.x86_64 11/15
Verifying : net-tools-2.0-0.22.20131004git.el7.x86_64 12/15
Verifying : 2:vim-enhanced-7.4.160-4.el7.x86_64 13/15
Verifying : lsof-4.87-5.el7.x86_64 14/15
Verifying : 2:vim-common-7.4.160-4.el7.x86_64 15/15
Installed:
dos2unix.x86_64 0:6.0.3-7.el7 nmap.x86_64 2:6.40-16.el7
ntp.x86_64 0:4.2.6p5-28.el7.centos screen.x86_64 0:4.1.0-0.25.20120314git3c2946.el7
telnet.x86_64 1:0.17-64.el7
Dependency Installed:
autogen-libopts.x86_64 0:5.18-5.el7 nmap-ncat.x86_64 2:6.40-16.el7
Updated:
lsof.x86_64 0:4.87-6.el7 net-tools.x86_64 0:2.0-0.24.20131004git.el7 vim-enhanced.x86_64 2:7.4.160-5.el7
Dependency Updated:
vim-common.x86_64 2:7.4.160-5.el7
Complete!
-----------------------------分隔符----------------------------------------
等待3S:#9/修改ip和主機名的對應關係 /etc/hosts
-----------------------------分隔符----------------------------------------
等待3S:#10/查看時間 並設置初始化時間
2019-03-13 15:15:55
13 Mar 15:22:27 ntpdate[19363]: step time server 139.199.215.251 offset 383.664488 sec
-----------------------------分隔符----------------------------------------
#11/設置linux的最大文件打開數
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 15066
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 102400
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
-----------------------------分隔符----------------------------------------
#12/centos6系統設置grep加顏色別名
-----------------------------分隔符----------------------------------------
#13/centos7特有的默認還有進程數限制/etc/security/limits.d/20-nproc.conf
-----------------------------分隔符----------------------------------------
#14/禁止內存巨大頁
-----------------------------分隔符----------------------------------------
#15/禁止swap交換
vm.swappiness = 0
[root@localhost ~]# systemctl daemon-reload
最後,執行以下reboot
此腳本 centos6 和centos7 通用