2019/3/13 星期三 初始化模板脚本实现 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 systemctl restart sshd 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
[root@emm-kafka01-10--174 scripts]# cat initialization.sh
#!/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/是否换成阿里云的的源 "
yum -y install wget
echo "等待3秒:"
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'`" ] && {
echo "Input error"
exit 1
}
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
fi
yum clean all
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
yum -y install net-tools tree nmap lrzsz dos2unix telnet screen vim lsof wget ntp rsync
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
echo "`ifconfig|sed -n '2p'|awk -F " " '{print $2}'|awk -F ":" '{print $2}'` $HOSTNAME" >> /etc/hosts
fi
echo "-----------------------------华丽分隔符----------------------------------------"
echo "等待3S:#10/查看时间 并设置初始化时间"
date +%F\ %T
ntpdate cn.pool.ntp.org && hwclock -w
echo "-----------------------------华丽分隔符----------------------------------------"
echo "#11/设置linux的最大文件打开数"
ulimit -SHn 1000000
ulimit -a
if [ "`egrep "* - nofile 1000000|* - nproc 1000000" /etc/security/limits.conf|wc -l`" == "0" ];then
echo "* - nofile 1000000" >> /etc/security/limits.conf
echo "* - nproc 1000000" >> /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"
echo "#13/centos6特有的默认还有进程数限制/etc/security/limits.d/90-nproc.conf"
if [ "$VERSION" == "7" ];then
sed -i 's#4096#65536#g' /etc/security/limits.d/20-nproc.conf
else
sed -i 's#1024#65536#g' /etc/security/limits.d/90-nproc.conf
fi
echo "-----------------------------华丽分隔符----------------------------------------"
echo "#14/禁止内存巨大页"
if [ "`egrif [ "$VERSION" == "7" ];then
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
else
if [ "`egrep "redhat_transparent_hugepage" /etc/rc.d/rc.local |wc -l`" == "0" ];then
echo "echo 'never' >/sys/kernel/mm/redhat_transparent_hugepage/enabled" >> /etc/rc.d/rc.local
echo "echo 'never' >/sys/kernel/mm/redhat_transparent_hugepage/defrag" >> /etc/rc.d/rc.local
else
echo "禁止内存巨大页 设置成功或者之前已经设置过了"
fi
fi
chmod +x /etc/rc.d/rc.localep "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=1" /etc/sysctl.conf|wc -l`" == "0" ];then
echo "vm.swappiness=1" >> /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 = 1
[root@emm-kafka02-10--175 scripts]# systemctl daemon-reload
最后,执行以下reboot 此脚本 centos6 和centos7 通用
[root@uhadoop-4wvgxxla-master1 ~]# sudo vim /etc/security/limits.conf hadoop soft nofile 1000000 hadoop hard nofile 1000000 hadoop soft nproc 32000 hadoop hard nproc 32000
- hard nofile 1000000
- soft nofile 1000000
- soft core unlimited
- soft stack 10240