#!/bin/bash # Checking echo "Checking..." if [ -n "`grep 'Aliyun Linux release' /etc/issue`" -o -e /etc/redhat-release ];then OS=CentOS [ -n "`grep ' 7\.' /etc/redhat-release`" ] && CentOS_RHEL_version=7 fi if [ "$OS" != 'CentOS' ] || [ "$CentOS_RHEL_version" != '7' ];then echo "${CFAILURE}Error: This script only support CentOS 7${CEND}"; kill -9 $$ fi # Close SELINUX setenforce 0 sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config # /etc/security/limits.conf [ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf sed -i '/^# End of file/,$d' /etc/security/limits.conf cat >> /etc/security/limits.conf <> /etc/sysctl.conf << EOF fs.file-max = 65535 net.ipv4.tcp_fin_timeout = 30 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 0 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_max_syn_backlog = 65536 net.ipv4.tcp_max_tw_buckets = 20000 net.ipv4.route.gc_timeout = 100 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syncookies = 1 net.core.somaxconn = 65535 net.core.netdev_max_backlog = 262144 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_max_orphans = 262144 net.core.rmem_max = 67108864 net.core.wmem_max = 67108864 net.core.rmem_default = 65536 net.core.wmem_default = 65536 net.ipv4.tcp_rmem = 4096 87380 67108864 net.ipv4.tcp_wmem = 4096 65536 67108864 net.ipv4.tcp_mtu_probing = 1 #net.ipv4.tcp_congestion_control = hybla net.ipv4.tcp_fastopen = 3 net.nf_conntrack_max = 6553500 net.netfilter.nf_conntrack_max = 6553500 net.netfilter.nf_conntrack_tcp_timeout_established = 180 EOF sysctl -p /etc/sysctl.conf