-
模板机优化配置---hosts文件配置
\cp /etc/hosts{,.bak}
cat >/etc/hosts<<EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.1.5 lb01
172.16.1.6 lb02
172.16.1.7 web01
172.16.1.8 web02
172.16.1.9 web03
172.16.1.51 db01 db01.etiantian.org
172.16.1.31 nfs01
172.16.1.41 backup
172.16.1.61 m01
EOF -
模板机优化配置---更改yum源
#更改yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup &&
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum install -y wget
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
PS:yum repolist 列出yum源信息;讲解什么是epel源 -
模板机优化配置---关闭selinux
#关闭selinux
sed -i.bak ‘s/SELINUX=enforcing/SELINUX=disabled/‘ /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce 0
getenforce -
模板机优化配置---关闭iptables
#关闭iptables centos7
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld -
模板机优化配置---提权oldboy可以sudo (可选配置)
#提权oldboy可以sudo(可选配置)
useradd oldboy
echo 123456|passwd --stdin oldboy
\cp /etc/sudoers /etc/sudoers.ori
echo "oldboy ALL=(ALL) NOPASSWD: ALL " >>/etc/sudoers
tail -1 /etc/sudoers
visudo -c -
模板机优化配置---英文字符集
#英文字符集
localectl set-locale LANG="en_US.UTF-8" -
模板机优化配置---时间同步
#时间同步
yum install -y ntpdate
echo ‘#time sync by lidao at 2017-03-08‘ >>/var/spool/cron/root
echo ‘*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1‘ >>/var/spool/cron/root
crontab -l -
模板机优化配置---加大文件描述
yum install -y lsof
lsof -i:22
#加大文件描述
echo ‘* - nofile 65536‘ >>/etc/security/limits.conf
tail -1 /etc/security/limits.conf
说明:
一个服务程序运行起来,会打开相应的文件
crond定时任务服务---systemctl start crond --- 打开相应文件
/var/spool/cron/root --- 加载打开配置文件
/var/log/cron --- 加载打开日志文件 -
模板机优化配置---安装其他小软件
#安装其他小软件
yum install lrzsz nmap tree dos2unix nc telnet wget lsof ntpdate bash-completion bash-completion-extras -y -
模板机优化配置---ssh连接速度慢优化
#ssh连接速度慢优化
sed -i.bak ‘s@#UseDNS yes@UseDNS no@g;s@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g‘ /etc/ssh/sshd_config
systemctl restart sshd