阿里云代理商-阿里云服务器-阿里云数据库-重庆典名科技

CentOS 6.8 x86_64系统最小化安装优化脚本

发布时间: 2020-09-18 11:49:37文章作者: 网站编辑阅读量: 251
  CentOS 6.8 x86_64系统最小化安装优化脚本
       CentOS6.8x86_64系统最小化优化脚本,大家注意,下文中有中文注释内 容,如果是放在线上运行时需要格外留意,脚本内容如下所示
  
  #!/hin/hash

  #系统基砝升级,建议以root执行 

       #必须使用root才能执行虼奂本 if [ SUSER! = "root" ]; then echo "需要使用sudo才能使用本奂本" exit 1 f icd /usr/local/srcwget http : //mi rrors. 163.com/.help/CentOS6-Base- 163. repocd /etc/yum. repos.d/mv CentOS-Base. repo CentOS-Base. repo.bak cp /usr/l ocal/src/CentOS6-Base-163. repo ./CentOS-Base. repoyum c丨ean a丨丨

       #清除yum缓存 yum makecache 

       #重建缓存 yum update -y 

       # 升级 Linux 系统 cd . . /#添加epe丨外部y 展浅 cd /usr/local/src wgethttp: //dl. fedoraproject. org/pub/epel/6/x86_64/epel-re I ease-6-8.noarch, rpmrpm -i vh epel-release-6-8.noarch, rpm

        #安装gcc基站库文件以及sysstat工具yum -y install gcc gcc~c++ vim-enhanced unzip unrar sysstat

        #3己置ntpdate自动对时 yum -y install ntpecho "01 01 * * * /usr/sbin/ntpdate ntp.ap i.bz >>/dev/null 2>&1" >> /etc/crontab /usr/sbin/ntpdate ntp.ap i.bz service crond restart 

         #3己置文件的ul imit^ ulimit -SHn 65534echo "ulimit -SHn 65534" >> /etc/rc.local cat >> /etc/security/limits. conf << EOF* soft nofile 65535* hard nofile 65535

  
  EOFecho Mfs.fiIe-max=419430M >> /etc/syset I.conf#基砝系统内核优化cat >> /etc/syset丨.conf << EOFnet. ipv4.tcp_syncookies = 1n r + in\/4 + n n s v n 十 rifts = 1
  
  pv4.tcp_tw_recycIe = 1 pv4.tcp_tw_reuse = 1 pv4.tcp_fin_timeout = 1 pv4.tcp_keepalive_time = 1200 pv4. ip_I oca I_port_range = 10000 65535 pv4.tcp_max_syn_backIog = 16384 pv4.tcp_max_tw_buckets = 36000 pv4. route.gc_timeout = 100 pv4.tcp_syn_retries = 1 pv4.tcp_synack_retries = 1 net.core.somaxconn = 16384 net.core.netdev_max_backIog = 16384 net. ipv4.tcp_max_orphans = 16384 EOF/sbin/sysctl -p
  
  #禁用contro I- alt-delete组合建以防止误搡作sed -i 'sfca : ct rI a ItdeI : /sb i n/shutdown -t3 -rnow@
  
  #ca: ct r I a I tde I : /sb i n/shutdown -t3 -r nowf'/etc/inittab # 关闭 SEI inuxsed -i 's@SELINUX=enforcing@SELINUX=disabled@'/etc/sel inux/config
  
  #关别 i ptab I es service i ptabIes stop chkconfig i ptab I es off
  
  #ssh旺务配置优化,请保持机器中至少有一个具有sudo权限的用户, 下面的記置会禁止root远程登衰sed -i 's@
  
  #Permi tRootLogi n yes@Permi tRootLogi n not'/etc/ssh/sshd_config
  
  #禁止空密码登录sed -i 's@#Permi tEmptyPasswordsno@Permi tEmptyPasswords not' /etc/ssh/sshd_config
  

  #禁止SSH反向解析sed -i 's@

       #UseDNS yes@UseDNS no@' /etc/ssh/sshd_config/etc/ssh/sshd_configservice sshd restart

       #禁用ipv6地址,根据实际需求设置,如杲需要安装I vs段务的机器, 建议保留虼选項echo "install i p v6 /bin/true ■’ >/etc/modprobe.d/disable-ipv6.conf

  #每当系统需要加载IPv6模块时,强刨执行/bin/true来代替实际加载的模块
  
  echo MIPV6INIT=noM >> /etc/sysconfig/network-scr i pts/i fcfg-ethO
  
  #禁用基于IPv6网珞,使之不会被铥发启动chkconfig i p6tabIes off#vim基訑语法优化cat >> /root/.vimrc << EOFset numberset rulerset noh丨searchset sh i ftw i dth = 2set tabstop=4set expandtabset c i ndentset auto indentset mouse=vsyntax onEOF
  
  #精简开机自启动旺务,安装最小化旺务的机器初始可以只留crond|networl^|rsyslog|sshd 这曰个.段务for i in 'chkconfig-----1i st|grep 3: on|awk {printS1} 1 ';do chkconfig---level 3 Si off;donefor CURSRV in crond rsysIog sshd network;do chkconfig----level 3 SCURSRV on;done
  
  #重启旺务器reboot
联系客服免费领取更多阿里云产品新购、续费升级折扣,叠加官网活动折上折更优惠