centos 5.6 linux安装系统后的基本优化

来源:岁月联盟 编辑:exp 时间:2012-02-17
1.关闭不必要的服务器
 
#ntsysv
 
保留
 
crond
 
Linux计划任务服务
 
irqbalance
 
用于优化中断分配,以充分利用CPU 多核
 
network
 
sshd
 
syslog
 
Linux 日志系统(重要)
 
2关闭iptables
 
#services iptables stop && chkconfig iptables off
 
关闭SELinux
 
#vim /etc/selinux/config
 
将文件中的selinux=""改为desabled  ,并重启
 
使用setenforce 0 可以不需要重启关闭SELinux 但是重启后失效
 
3.关闭不需要的tty
 
#vim /etc/inittab
 
# Run gettys in standard runlevels
1:2345:respawn:/sbin/mingetty tty1
2:2345:respawn:/sbin/mingetty tty2
3:2345:respawn:/sbin/mingetty tty3
4:2345:respawn:/sbin/mingetty tty4
5:2345:respawn:/sbin/mingetty tty5
6:2345:respawn:/sbin/mingetty tty6
 
注释掉后4 个控制台 并执行init q  命令生效
 
4.停止打印服务
 
#/etc/init.d/cups stop
 
#chkconfig cups off
 
5.关闭ipv6
 
#vim /etc/modprobe.conf
 
添加内容
 
alias net-pf-10 off
 
alias ipv6 off
 
保存退出
 
#echo "IPV6INIT = no" >>/etc/sysconfig/network-scripts/ifcfg-eth0
 
#reboot  重启生效
 
6.调整Linux 的最大文件打开数
 
#vim /etc/rc.d/rc.local
 
添加内容
 
ulimit -SHn 65565
 
7关闭centos的写磁盘I/O功能
 
一个linux文件默认有3个时间
 
atime:对此文件的访问时间
 
ctime: 此文件的inode发生变化的时间
 
mtime: 此文件的修改时间
 
#vim /etc/fstab
 
/dev/sda2    /data     ext3  noatime,nodiratime  0 0
 
8,优化Linux 下的内核tcp 参数以提高系统性能
 
#vim /etc/sysctl.config
 
添加内容
 
net.ipv4.tcp_fin_timeout = 30
 
net.ipv4.tcp_keepalive_time = 1200
 
net.ipv4.tcp_syncookise = 1
 
net.ipv4.tcp_tw_reuse = 1
 
net.ipv4.tcp_tw_recycle = 1
 
net.ipv4.ip_local_port_range = 1024 65000
 
net.ipv4.tcp_nax_syn_backlog = 8192
 
net.ipv4.tcp_max_tw_buckets  = 5000
 
#sysctl -p 生效