/etc/do_some_checks.sh
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local echo 10 >/sys/module/ipmi_si/parameters/kipmid_max_busy_us bash /etc/do_some_checks.sh /etc/balance_lvs_cpu.sh bash /home/fastmedia/push_fastmedia.sh f01i01_fastmedia.conf start CLC [root@cmb-cq-218-201-042-186 ~]# cat /etc/do_some_checks.sh #!/bin/bash # 本脚本用于优化系统 export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin ########## 基础信息获取 ########## CORES=`awk '/processor/{p++};END{print p}' /proc/cpuinfo` DISK_SYS=`mount |awk '$3=="/"{i=$1;gsub(/\/dev\//,"",i);gsub(/[0-9]/,"",i);}END{print i}'` DISK_NUM=0 for i in sd{a..z}; do if [ -b "/dev/$i" ]; then let DISK_NUM++ last_disk=$i [ "/dev/$DISK_SYS" == "/dev/$i" ] && continue # skip OS device. # SSD? if ( smartctl -i /dev/$i 2>/dev/null |grep -q "SSD\|Micron\|INTEL" ); then SSDs[$DISK_NUM]=$i continue fi if ( smartctl -i /dev/$i 2>/dev/null |egrep -q "(4[78][0-9]|800) GB" ); then SSDs[$DISK_NUM]=$i continue fi # DATA? DISKs[$DISK_NUM]=$i else break fi done ########## 调整优化 ################ for disk in ${SSDs[*]} ; do echo noop > /sys/block/$disk/queue/scheduler; done for disk in ${DISKs[*]}; do echo deadline > /sys/block/$disk/queue/scheduler; done # fastcache启动项 if grep -q /usr/local/fastcache/sbin/fastcache /etc/rc.d/rc.local; then sed -i -r 's!(nice -n -3 )?/usr/local/fastcache/sbin/fastcache!/etc/init.d/fastcache start!' /etc/rc.d/rc.local fi # tcp初始化窗口 ip route |grep default | while read p; do ip route change $p initcwnd 10 initrwnd 44; done; ip route # 强制使用 cubic 拥塞控制算法 sysctl -w net.ipv4.tcp_congestion_control=cubic &>/dev/null # 设置 CPU 始终工作在最高频率 for CPUFREQ in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do [ -f $CPUFREQ ] || continue; echo -n performance > $CPUFREQ; done # IPMI CPU高 [ -f /sys/module/ipmi_si/parameters/kipmid_max_busy_us ] && echo 10 >/sys/module/ipmi_si/parameters/kipmid_max_busy_us # # CPU # 平均绑定CPU到网卡多个队列上,避免单核CPU跑满的问题 set_affinity() { if [ $VEC -ge 32 ] then MASK_FILL="" MASK_ZERO="00000000" let "IDX = $VEC / 32" for ((i=1; i<=$IDX;i++)) do MASK_FILL="${MASK_FILL},${MASK_ZERO}" done let "VEC -= 32 * $IDX" MASK_TMP=$((1< /proc/irq/$IRQ/smp_affinity } if ( service irqbalance status &>/dev/null ); then service irqbalance stop chkconfig irqbalance off fi # Set up the desired devices. for DEV in `ifconfig | awk '$0~/^(eth|em)[0-9] /{print $1}'`; do for DIR in rx tx TxRx; do MAX=`grep $DEV-$DIR /proc/interrupts | wc -l` if [ "$MAX" == "0" ] ; then MAX=`egrep -i "$DEV-" /proc/interrupts | wc -l` fi if [ "$MAX" == "0" ] ; then MAX=`egrep -i "$DEV:.*$DIR" /proc/interrupts | wc -l` fi if [ "$MAX" == "0" ] ; then echo no $DIR vectors found on $DEV continue fi for VEC in `seq 0 1 $MAX`; do IRQ=`cat /proc/interrupts | grep -i $DEV-$DIR-$VEC"$" | cut -d: -f1 | sed "s/ //g"` if [ -z $IRQ ]; then IRQ=`cat /proc/interrupts | grep -i $DEV-$VEC"$" | cut -d: -f1 | sed "s/ //g"` fi if [ -n "$IRQ" ]; then set_affinity else IRQ=`cat /proc/interrupts | egrep -i $DEV:v$VEC-$DIR"$" | cut -d: -f1 | sed "s/ //g"` if [ -n "$IRQ" ]; then set_affinity fi fi done done done