#修改/etc/sysctl.conf 文件中的一些默认的配置 if [ grep -v "^\s*#" /etc/sysctl.conf|grep -c "net.ipv4.ip_forward\s\+=\+0" ];then cat >>/etc/sysctl.conf << EOF net.ipv4.ip_forward = 0 net.ipv4.tcp_max_tw_buckets = 5000 fs.file-max = 65535 net.ipv4.ip_local_port_range = 1024 65000 net.ipv4.tcp_syncookies = 1 vm.overcommit_memory = 1 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_tw_recycle = 1 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 1 net.ipv4.tcp_syn_retries = 1 net.ipv4.tcp_abort_on_overflow = 0 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.core.netdev_max_backlog = 262144 net.core.somaxconn = 65535 vm.max_map_count=655360 net.ipv4.tcp_max_orphans = 3276800 net.ipv4.tcp_max_syn_backlog = 262144 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 EOF sysctl -p #effective fi #修改open files数目 if [ grep -v '^\s*#' /etc/security/limits.conf |grep -c 'soft nofile' -eq 0 ];then cat >> /etc/security/limits.conf <<EOF

  • soft nofile 65535
  • hard nofile 65535 EOF ulimit -HSn 65535 fi

if [ grep -v '^\s*#' /etc/security/limits.d/20-nproc.conf |grep -c 'soft nofile' -eq 0 ];then rm -rf /etc/security/limits.d/20-nproc.conf cp $PACKAGE_DIR/20-nproc.conf /etc/security/limits.d/ fi

if [ grep -v '^\s*#' /etc/systemd/system.conf |grep -c 'DefaultLimitCORE=infinity' -eq 0 ];then cat >> /etc/systemd/system.conf <<EOF

DefaultLimitCORE=infinity DefaultLimitNOFILE=100000 DefaultLimitNPROC=100000

EOF

fi

if [ grep -v '^\s*#' /etc/systemd/user.conf |grep -c 'DefaultLimitCORE=infinity' -eq 0 ];then cat >> /etc/systemd/user.conf <<EOF

DefaultLimitCORE=infinity DefaultLimitNOFILE=100000 DefaultLimitNPROC=100000

EOF