5、定时自动更新服务器时间
1 [root@server ~]# echo '*/5 * * * * /usr/sbin/ntpdate time.windows.com >/dev/null 2 >&1' >>/var/spool/cron/root
2 [root@server ~]# echo '*/10 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2>&1' >>/var/spool/cron/root
提示:CentOS 6.7的时间同步命令路径不一样
6是/usr/sbin/ntpdate
5是/sbin/ntpdate
扩展:在机器数量少时,以上定时任务同步时间就可以了。如果机器数量大时,可以在网内另外部署一台时间同步服务器NTP Server。此处仅提及,不做部署。
6、精简开机自启动服务
刚装完操作系统可以只保留crond,network,syslog,sshd这四个服务。(Centos6.7为rsyslog)
1 [root@server ~]# for sun in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $sun off;done
2 [root@server ~]# for sun in crond rsyslog sshd network;do chkconfig --level 3 $sun on;done
3 [root@server ~]# chkconfig --list|grep 3:on
4 crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
5 network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
6 rsyslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7 sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7、定时自动清理/var/spool/clientmqueue/目录垃圾文件,放置inode节点被占满
本优化点,在6.7上可以忽略不需要操作即可!
1 [root@server ~]# mkdir /server/scripts -p
2 [root@server ~]# vi /server/scripts/spool_clean.sh
3 #!/bin/sh
4 find/var/spool/clientmqueue/-typef -mtime +30|xargsrm-f
8、变更默认的ssh服务端口,禁止root用户远程连接
1 [root@server ~]# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
2 [root@server ~]# vim /etc/ssh/sshd_config
3 Port 52113#ssh连接默认的端口
4 PermitRootLogin no #root用户黑客都知道,禁止它远程登录
5 PermitEmptyPasswords no #禁止空密码登录
6 UseDNS no #不使用DNS
7 [root@server ~]# /etc/init.d/sshd reload #从新加载配置
8 [root@server ~]# netstat -lnt #查看端口信息
9 [root@server ~]# lsof -i tcp:52113
2015职称计算机考试书PowerPoint2007中 .. 定价:¥45 优惠价:¥42 更多书籍 | |
2015年全国职称计算机考试教材(2007模 .. 定价:¥225 优惠价:¥213 更多书籍 |