一、脚本功能
- 连接数ulimit调优
- 文件进程数limits调优
- 关闭selinux
- 关闭防火墙
- 配置网易Yum源
- 安装常用工具(ntpd telnet tcpdump lsof vim links)
- 时间同步
二、脚本内容
#!/bin/bash
#此脚本为centos7部署前操作
#定义函数
function input () {
#系统的程序资源限制ulimit(最大连接数调优)
echo -e "ulimit -HSn 307200" >>/etc/profile
#系统调优(设置无限制,解除 Linux 系统的最大进程数和最大文件打开数限制)
echo -e "* soft nproc 65535\n* hard nproc 65535\n* soft nofile 65535\n* hard nofile 6553\n* - sigpending 6553" >>/etc/security/limits.conf
#临时关闭selinux,不用重启即可生效
setenforce 0
#永久关闭selinux,防止重启后自动开启
sed -i "s/^SELINUX\=enforcing/SELINUX\=disabled/g" /etc/selinux/config
#关闭防火墙,开机不自启
systemctl stop firewalld
systemctl disable firewalld
#创建个bak文件夹用于备份yum源
mkdir -p /etc/yum.repos.d/bak
#备份yum源
mv /etc/yum.repos.d/* /etc/yum.repos.d/bak/
#下载网易yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo
#清理yum缓存
yum clean all
#缓存yum源
yum makecache
#安装常用工具
yum -y install ntpd telnet tcpdump lsof vim links
#同步时间至阿里时间服务器
ntpdate ntp1.aliyun.com
}
#执行函数
input
#判断函数执行效果
if [ $? = 0 ];then
echo "done!"
exit
else
echo "please check!"
fi
注释:机器需要连接到公网,否则配置yum、ntp会失败