Centos7.x system optimization script

Source: Internet
Author: User
######################################## ###################### File Name: system. sh # Author: She # E-mail: [email protected] # created time: fri 18 May 2018 05:01:02 pm CST #================================== ========================================== #! /Bin/sh # running environment centos 7.x# Delete Chinese note system = 'uname-I 'if [$ system! = "X86_64"]; thenecho "detected that this system version is not 64-bit! "Exit 1 ficat <EOF + --------------------------------------- + | your system is centos 7. X _ x86_64 | start optimization. Please wait ....... | + --------------------------------------- eofecho "Download wget ·" yum-y install wget &>/dev/nullecho "add DNS address. Please wait ....... "Cat>/etc/resolv. conf <eofnameserver 114.114.114.114 nameserver 114.114.114.114 eofecho "is replaced with the yum source. Please wait ....... "CD/etc/yum. repos. d/mkdir yum_bak &>/dev/nullmv * yum_bak &>/ Dev/nullwget-O Centos-aliyun.repo http://mirrors.aliyun.com/repo/Centos-7.repo &>/dev/nullsed-I's/$ releasever/7/G' Centos-aliyun.repo &>/dev/nullyum makecache &>/dev/nullyum install epel-release-Y &>/dev/nullecho "synchronization time, please wait ....... "If [-F/usr/sbin/ntpdate]; thenecho "" elseyum-y install NTP &>/dev/nullfi/usr/sbin/ntpdate cn.pool.ntp.org &>/dev/nullecho "0 4 ***/usr/sbin/ntpdate CN. pool. NTP. Org ">/var/spool/cron/rootsystemctl restart crond. serviceecho "Install Vim. Please wait ....... complete the "yum-y install Vim &>/dev/nullecho" command. Please wait ....... "yum install bash-completion-Y &>/dev/nullecho" sets the maximum number of open file descriptors. Please wait ....... "Echo" ulimit-shn 102400 ">/etc/rc. localcat>/etc/security/limits. conf <EOF * Soft nofile 655350 * hard nofile 655350 eofecho "Disable SELinux. Please wait ....... "sed-I's/SELinux = enforcing/SELinux = Disa Bled/'/etc/SELinux/configsetenforce 0 echo "Disable the firewall. Please wait ....... "systemctl disable firewalld. servicesystemctl stop firewalld. serviceecho "optimized the SSH service. Please wait ....... "sed-I's/^ gssapiauthentication Yes $/gssapiauthentication no/'/etc/ssh/sshd_configsed-I's/# usedns Yes/usedns no/'/etc/ssh/ sshd_configsystemctl Restart sshd. serviceecho "------- <Kernel Parameter Optimization> -------" cat>/etc/sysctl. conf <eofvm. overcommit_memory = 1 # indicates the kernel check method when allocating memory. net. ipv4.ip _ local_port_range = 1024 65536 # port range: 1024 ~ 65535net. ipv4.tcp _ fin_timeout = 1 # Time to keep in the fin-wait-2 state. net. ipv4.tcp _ keepalive_time = 1200 # interval between TCP and keepalive message sending (s). Net. ipv4.tcp _ mem = 94500000 915000000 927000000 # overall TCP cache settings, control the usage of all TCP memory, in the unit of page, in turn, it indicates the total TCP memory pressure value, the pressure mode activation threshold value, and the maximum usage value. net. ipv4.tcp _ tw_reuse = 1 # enable fast recovery of Time-Wait sockets in TCP connections. The default value is 0, indicating to disable net. ipv4.tcp _ tw_recycle = 1 # Enable reuse and allow time-Wait sockets to be re-used for new TCP connections. The default value is 0, indicating that it is disabled. net. ipv4.tcp _ timestamps = 0 # disable Net. ipv4.tcp _ synack_retries = 1 # Number of SYN + ACK packets sent before the kernel disconnects. net. ipv4.tcp _ syn_retries = 1 # Number of SYN packets sent by the kernel before the connection is established. net. ipv4.tcp _ abort_on_overflow = 0 # A boolean sign that controls the kernel behavior when many connection requests exist. net. core. rmem_max = 16777216 # specifies the maximum buffer size of the received socket (in bytes). Net. core. wmem_max = 16777216 # specify the maximum size (in bytes) of the buffer for sending sockets. net. core. netdev_max_backlog = 262144 # maximum number of packets allowed to be sent to the queue. net. core. somaxconn = 262144 # the maximum number of TCP sockets in the system is not associated with any What is the net. ipv4.tcp _ max_orphans = 3276800 # net. ipv4.tcp _ max_syn_backlog = 262144 # indicates the length of the SYN queue. net. core. wmem_default = 8388608 # specify the default value of the buffer size of the sending socket (in bytes). Net. core. rmem_default = 8388608 # specify the default value of the buffer size of the received socket (in bytes) # net. ipv4.netfilter. ip_conntrack_max = 2097152 # "tasks" (connection trace entries) That netfilter can simultaneously process in the maximum kernel memory # net. nf_conntrack_max = 655360 # maximum number of allowed trace connection entries # net. netfilter. nf_conntrack_tcp_timeout_esta Blished = 1200 # established timeout EOF/sbin/sysctl-Pecho "system has been optimized. Please use it!"

Centos7.x system optimization script

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.