CentOS 61-Key System optimized Shell script

Source: Internet
Author: User
Tags delete key gpg

CentOS 61-Key System optimized Shell script

The contents of the script are as follows:

#!/bin/bash
#author Suzezhi
#this script is only for CentOS 6
#check the OS

Platform= ' Uname-i '
if [$platform! = "x86_64"];then
echo "This script was 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 was only for CentOS 6!"
Exit 1
Fi
Cat << EOF
+---------------------------------------+
| Your system is CentOS 6 x86_64 |
| Start Optimizing ... |
+---------------------------------------
Eof

#make the 163.com as the default Yum repo
Mv/etc/yum.repos.d/centos-base.repo/etc/yum.repos.d/centos-base.repo.backup
wget Http://mirrors.163.com/.help/CentOS6-Base-163.repo-O/etc/yum.repos.d/centos-base.repo

#add the Third-party Repo
#add the Epel
RPM-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/root
Service 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 misuse
Sed-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 SSH
Sed-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 crontab
Mkdir/etc/cron.daily.bak
Mv/etc/cron.daily/makewhatis.cron/etc/cron.daily.bak
Mv/etc/cron.daily/mlocate.cron/etc/cron.daily.bak
Chkconfig bluetooth off
Chkconfig cups off
Chkconfig Ip6tables off
#disable the IPv6
Cat >/etc/modprobe.d/ipv6.conf << eofi
Alias 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


Make a note of the contents of the script:

The system is judged first, if it is cent OS 64-bit, continue to run.
First set the system's installation source for NetEase (NetEase's installation source is relatively stable at home)
Install Epel source and Rpmforge sources and use third-party sources to make Yum easier to install
Update Software
Time synchronization is set to four o'clock in the morning daily (time synchronization with the National Service Center server)
Increase the number of files that are open simultaneously on the system
Block the Ctrl alt Delete key to prevent server restarts when misoperation occurs
Turn off SELinux
Disable GSSAPI to authenticate, also disable DNS reverse resolution, speed up SSH login speed
Optimize some kernel parameters
The key to adjust the delete character is backspace (some systems default to delete)
Turn on VIM syntax highlighting
Cancel build Whatis database and locate database
Turn off useless services
Close IPv6

The above part from the network blog, I did some summary

CentOS 61-Key System optimized Shell script

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.