码迷,mamicode.com
首页 > 其他好文 > 详细

優化系統核心參數

时间:2021-01-14 10:58:27      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:local   cookie   syn   sys   etc   tcp   net   touch   trie   

#!/bin/bash
echo -e "\033[36m \t\t\t 優化系統核心參數 \t\t\t \033[0m"
  grep ‘keepalive_time = 1200‘ /etc/sysctl.conf &>/dev/null
  if [ $? -ne 0 ];then
  cat >> /etc/sysctl.conf <<EOF

fs.file-max = 65535
net.ipv4.ip_forward = 1
net.ipv4.tcp_synack_retries = 3
net.ipv4.tcp_max_orphans = 8192
net.ipv4.tcp_window_scaling = 03
net.ipv4.tcp_sack = 0
net.ipv4.icmp_echo_ignore_all = 1
net.core.somaxconn= 10240
vm.overcommit_memory=1
vm.swappiness = 0
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 2000

EOF

       

  sysctl -p
  fi
  swapoff -a
  sleep 1
  grep ‘* soft nproc 65535‘ /etc/security/limits.conf &>/dev/null
  if [ $? -ne 0 ];then
  cat >> /etc/security/limits.conf <<EOF

* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535

EOF  

  

  fi
  rc_local=`grep /var/lock/subsys/local /etc/rc.local`
  [ -z "$rc_local" ] && sed -i ‘$atouch /var/lock/subsys/local‘ /etc/rc.local
  sleep 1

 

優化系統核心參數

标签:local   cookie   syn   sys   etc   tcp   net   touch   trie   

原文地址:https://www.cnblogs.com/luoqiangdong/p/14271609.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!