简单系统开机优化脚本for rhel6

#!/bin/bash
# wul@2013-02-19 14:12:18
# tunning for rhel6

service_tuning()
{
#SELINUX off
sed -i -c 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
setenforce 0

##################### Chkconfig services off #####################
service=`chkconfig --list | grep '3:on' | awk '{print $1}'`
for i in $service
do
	case $i in
		acpid | crond | irqbalance |  messagebus | network | sshd | rsyslog | sysstat | udev-post)
		:
		;;
		*)
			chkconfig --level 2345 $i off	
		;;
	esac	
done
##################### Chkconfig services off #####################
}

system_tuning()
{
sed -i 's/ONBOOT="no"/ONBOOT="yes"/g' /etc/sysconfig/network-scripts/ifcfg-eth0

##################### linux kernel #####################
cat >>/etc/sysctl.conf <<EOF
net.core.rmem_max=16777216 
net.core.wmem_max=16777216 
net.ipv4.tcp_rmem=4096 87380 16777216  
net.ipv4.tcp_wmem=4096 65536 16777216  
net.ipv4.tcp_fin_timeout = 30 
net.core.netdev_max_backlog = 30000 
net.ipv4.tcp_no_metrics_save=1 
net.core.somaxconn = 262144 
net.ipv4.tcp_syncookies = 1 
net.ipv4.tcp_max_orphans = 262144 
net.ipv4.tcp_max_syn_backlog = 262144 
net.ipv4.tcp_synack_retries = 2 
net.ipv4.tcp_syn_retries = 2
EOF
modprobe bridge
sysctl -p
##################### linux kernel #####################

###################### vim ###################### 
cat > /root/.vimrc <<EOF
function HeaderPython()
    call setline(1, "#!/usr/bin/env python")
    call append(1, "# _*_ coding: utf-8 _*_")
    call append(2, "# wul@" . strftime('%Y-%m-%d %T', localtime()))
    normal G
    normal o
    normal o
    endf
    autocmd bufnewfile *.py call HeaderPython()

function HeaderBash()
    call setline(1, "#!/bin/bash")
    call append(1, "# wul@" . strftime('%Y-%m-%d %T', localtime()))                                                      
    endf
    autocmd bufnewfile *.sh call HeaderBash()

set cul noexpandtab tabstop=4 shiftwidth=4 softtabstop=4
EOF
###################### vim ###################### 
}

service_tuning
system_tuning


你可能感兴趣的:(简单系统开机优化脚本for rhel6)