centos6系统优化脚本 -凯发k8官方网
凯发k8官方网
收集整理的这篇文章主要介绍了
centos6系统优化脚本
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
centos 已经发布了6.2版了,现在已经可以用在生产环境了,新版本的内核也能更好的利用硬件。写了一个脚本,用来初始化系统环境,现在分享出来,你可以根据自己的需要,对脚本进行相应的修改。
脚本的内容如下:
#!/bin/bash #author suzezhi #this script is only for centos 6 #check the osplatform=`uname -i` if [ $platform != "x86_64" ];then echo "this script is only for 64bit operating system !"exit 1 fi echo "the platform is ok" version=`lsb_release -r |awk '{print substr($2,1,1)}'` if [ $version != 6 ];then echo "this script is only for centos 6 !" exit 1 ficat << eof --------------------------------------- | your system is centos 6 x86_64 | | start optimizing....... | --------------------------------------- eof#make the 163.com as the default yum repomv /etc/yum.repos.d/centos-base.repo /etc/yum.repos.d/centos-base.repo.backupwget http://mirrors.163.com/.help/centos6-base-163.repo -o /etc/yum.repos.d/centos-base.repo#add the third-party repo #add the epelrpm -uvh http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm rpm --import /etc/pki/rpm-gpg/rpm-gpg-key-epel-6#add the rpmforge rpm -uvh http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm rpm --import /etc/pki/rpm-gpg/rpm-gpg-key-rpmforge-dag#update the system and set the ntp yum clean all yum -y update glibc\* yum -y update yum\* rpm\* python\* yum -y update yum -y install ntp echo "* 4 * * * /usr/sbin/ntpdate 210.72.145.44 > /dev/null 2>&1" >> /var/spool/cron/rootservice crond restart#set the file limit echo "ulimit -shn 102400" >> /etc/rc.local cat >> /etc/security/limits.conf << eof * soft nofile 65535 * hard nofile 65535 eof#set the control-alt-delete to guard against the misusesed -i 's#exec /sbin/shutdown -r now#\#exec /sbin/shutdown -r now#' /etc/init/control-alt-delete.conf#disable selinux sed -i 's/selinux=enforcing/selinux=disabled/' /etc/selinux/config#set sshsed -i 's/^gssapiauthentication yes$/gssapiauthentication no/' /etc/ssh/sshd_config sed -i 's/#usedns yes/usedns no/' /etc/ssh/sshd_config service sshd restart#tune kernel parametres cat >> /etc/sysctl.conf << eof net.ipv4.tcp_fin_timeout = 1 net.ipv4.tcp_keepalive_time = 1200 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_tw_recycle = 1 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 262144 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_max_syn_backlog = 262144 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 eof /sbin/sysctl -p#define the backspace button can erase the last character typed echo 'stty erase ^h' >> /etc/profile echo "syntax on" >> /root/.vimrc#stop some crontabmkdir /etc/cron.daily.bak mv /etc/cron.daily/makewhatis.cron /etc/cron.daily.bak mv /etc/cron.daily/mlocate.cron /etc/cron.daily.bakchkconfig bluetooth off chkconfig cups off chkconfig ip6tables off #disable the ipv6 cat > /etc/modprobe.d/ipv6.conf << eofialias net-pf-10 off options ipv6 disable=1 eofi echo "networking_ipv6=off" >> /etc/sysconfig/network cat << eof ------------------------------------------------- | optimizer is done | | it's recommond to restart this server ! | ------------------------------------------------- eof对脚本的内容做一下说明:
先对系统进行判断,如果是cent os 64位,就继续运行。
先将系统的安装源设置为网易的(网易的安装源算是国内比较稳定的)
安装epel的源和rpmforge的源,利用第三方的源来让yum安装起来更方便
更新软件
设置为每天凌晨四点进行时间同步(跟国家授时中心的服务器进行时间同步)
将系统同时打开的文件个数增大
将ctrl alt delete键进行屏蔽,防止误操作的时候服务器重启
关闭selinux
禁用gssapi来认证,也禁用dns反向解析,加快ssh登陆速度
优化一些内核参数
调整删除字符的按键为backspace(某些系统默认是delete)
打开vim的语法高亮
取消生成whatis数据库和locate数据库
关闭没用的服务
关闭ipv6
转载于:https://blog.51cto.com/jiarh/1721671
总结
以上是凯发k8官方网为你收集整理的centos6系统优化脚本的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: