CentOS System Production System optimization script

Source: Internet
Author: User
Tags epel repo
#!/bin/bash

#add the Epel repo and rpmforge repo
cd/root/
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
wget http://repository.it4i.cz/mirrors/repoforge/redhat/el7/en/x86_64/rpmforge/RPMS/ rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

RPM-IVH epel-release-7-9.noarch.rpm
RPM-IVH rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

#remove *.rpm Packages
Sleep 20
cd/root/
RM-RF epel-release-7-9.noarch.rpm rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

#yum Install Sysstat
Yum install-y gcc gcc-c++ vim unzip zip
Yum install-y Iostat Sysstat


#set the NTP
Yum Install-y NTP
echo "* * */usr/sbin/ntpdate ntp.api.bz >>/dev/null 2>&1" >>/etc/crontab ntpdate ntp.api.bz
Service Crond Restart

#set the file limit
Ulimit-shn 65535
echo "Ulimit-shn 65535" >>/etc/rc.local
Cat >>/etc/security/limits.conf << EOF
* Soft Nofile 60000
* Hard Nofile 65535
Eof

#tune kernel parametres
Cat >>/etc/sysctl.conf << EOF
Net.ipv4.tcp_syncookies = 1
Net.ipv4.tcp_syn_retries = 1
Net.ipv4.tcp_tw_reuse = 1
Net.ipv4.tcp_tw_recycle = 1
Net.ipv4.tcp_keepalive_time = 1200
Net.ipv4.tcp_local_port_range = 1024 65535
Eof
/sbin/sysctl-p

#set the Control-alt-delete to guard against the misuse
Sed-i ' s@ ca::ctrlaltdel:/sbin/shutdown-t3-r now@ #ca:: Ctrlaltdel:/sbin/shutdown-t3-r now@ '/etc/inittab

#disable SELinux
Sed-i ' s@ selinux=enforcing@ selinux=disabled@ '/etc/selinux/config

#ssh setting
Sed-i-E ' s/^/#/'-i-e ' s/^/#/'/etc/ssh/sshd_config
Sed-i ' s@ #UseDNS yes@ usedns no@ '/etc/ssh/sshd_config
Service sshd Restart


#disable IPv6
echo "Alias net-pf-10 off" >>/etc/modprobe.conf
echo "Alias IPv6 off" >>/etc/modprobe.conf
echo "Install Ipv6/bin/true" >>/etc/modprobe.conf
echo "Ipv6init=no" >>/etc/sysconfig/network
Sed-i ' s@ networking_ipv6=yes@ networking_ipv6=no@ '/etc/sysconfig/network
Chkconfig Ip6tables off



#vim setting
echo "Syntax on" >>/ROOT/.VIMRC
echo "Set Nohlsearch" >>/ROOT/.VIMRC
echo "Set num" >>/ROOT/.VIMRC


#chkconfig Off Services
Chkconfig bluetooth off
Chkconfig SendMail off
Chkconfig kudzu off
Chkconfig Nfslock off
Chkconfig Portmap off
Chkconfig iptables off
Chkconfig AutoFS off
Chkconfig yum-updatesd off

#reboot system
Reboot

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.