|
优化内容包括 内核(文章末尾注释掉了,看个人需求) ssh 时间同步 yum源
#!/bin/bash
#update time 20180824
#version 1.1.0
echo -e "\033[31m ------------------------------ Author name is HeFangYaonie-------------------------- \033[0m"
if [[ "$(whoami)" != "root" ]]; then
echo "please run this script as root !" >&2
exit 1
fi
echo -e "\033[31m the script only Support CentOS_6 x86_64 \033[0m"
echo -e "\033[31m system initialization script, Please Seriously. press ctrl+C to cancel \033[0m"
yn="n"
echo "please input [Y\N]"
echo -n "default [N]: "
read yn
if [ "$yn" != "y" -a "$yn" != "Y" ]; then
echo "bye-bye!"
exit 0
fi
for i in seq -w 3 -1 1
do
echo -ne "\b>>>>>$i";
sleep 1;
done
echo -e "\b\Good Luck"
platform=uname -i
if [ $platform != "x86_64" ];then
echo "this script is only for 64bit Operating System !"
exit 1
fi
echo "the platform is ok"
distributor=lsb_release -i | awk '{print $NF}'
version=lsb_release -r | awk '{print substr($NF,1,1)}'
if [ $distributor != 'CentOS' -o $version != '6' ]; then
echo "this script is only for CentOS 6 !"
exit 1
fi
cat > /var/spool/cron/root /dev/null 2>&1
EOF
date
/sbin/service crond restart
echo -e "\033[31m ------------------------------update time is ok !!! --------------------------------------\033[0m"
sleep 5
sed -i "/^ulimit -SHn.*/d" /etc/rc.local
echo "ulimit -SHn 102400" >> /etc/rc.local
sed -i "/^ulimit -s./d" /etc/profile
sed -i "/^ulimit -c./d" /etc/profile
sed -i "/^ulimit -SHn.*/d" /etc/profile
cat >> /etc/profile > /etc/security/limits.conf > /etc/sysctl.conf /proc/sys/net/ipv4/tcp_max_tw_buckets
#delete
sed -i "/^kernel.shmmax/d" /etc/sysctl.conf
sed -i "/^kernel.shmall/d" /etc/sysctl.conf
#add
shmmax=free -l |grep Mem |awk '{printf("%d\n",$2*1024*0.9)}'
shmall=$[$shmmax/4]
echo "kernel.shmmax = "$shmmax >> /etc/sysctl.conf
echo "kernel.shmall = "$shmall >> /etc/sysctl.conf
#bridge
modprobe bridge
lsmod|grep bridge
#reload sysctl
/sbin/sysctl -p
echo -e "\033[31m ---------------------------sysctl ok----------------------------------------------- \033[0m"
sleep 3
#系统服务优化,可适当选择下列服务
#SERVICES="acpid atd auditd avahi-daemon avahi-dnsconfd bluetooth conman cpuspeed cups dnsmasq dund firstboot hidd httpd ibmasm ip6tables irda kdump lm_sensors mcstrans messagebus microcode_ctl netconsole netfs netplugd nfs nfslock nscd oddjobd pand pcscd portmap psacct rdisc restorecond rpcgssd rpcidmapd rpcsvcgssd saslauthd sendmail setroubleshoot smb vncserver winbind wpa_supplicant ypbind"
#for service in $SERVICES
#do
#关闭所选服务随系统启动
#systemctl disable $SERVICES
#停止所选的服务
#syatemctl stop $SERVICES
#done
echo -e "\033 [31m ------------------优化完成-------------------- \033[0m"
|
|
|