linux 系統調優步驟 例

修改/etc/profile文件,加入:node

  ulimit -u 10240安全

  ulimit -n 4096cookie

  ulimit -d unlimited網絡

  ulimit -m unlimited併發

  ulimit -s unlimitedtcp

  ulimit -t unlimitedide

  ulimit -v unlimitedspa

  修改/etc/rc.d/rc.local,加入:.net

  echo ‘131072′ > /proc/sys/fs/file-maxorm

  echo ‘131072′ > /proc/sys/fs/inode-max

  (1G內存值修改爲:65535 2G內存值修改爲:131072 4G內存值修改爲:262144)

  修改/etc/sysctl.conf文件,加入:

  net.core.rmem_default = 8388608

  net.core.rmem_max = 8388608

  net.core.wmem_default = 8388608

  net.core.wmem_max = 8388608

  net.ipv4.tcp_timestamps = 0

  net.ipv4.tcp_sack =1

  net.ipv4.tcp_window_scaling = 1

  net.core.netdev_max_backlog=3000

  #Modify i-node

  sys.fs.file-max= 65535

  sys.fs.inode-max= 65535

  #Set System Memory

  vm.bdflush="30 500 0 0 500 3000 60 20 0"

  vm.kswapd="1024 32 64"

  #Disable HackAttack!

  net.ipv4.conf.eth0.accept_source_route=0

  net.ipv4.conf.lo.accept_source_route=0

  net.ipv4.conf.default.accept_source_route=0

  net.ipv4.conf.all.accept_source_route=0

  net.ipv4.conf.lo.accept_redirects=0

  net.ipv4.conf.all.accept_redirects=0

  net.ipv4.conf.eth0.accept_redirects=0

  net.ipv4.conf.default.accept_redirects=0

  net.ipv4.conf.lo.secure_redirects=0

  net.ipv4.conf.all.secure_redirects=0

  net.ipv4.conf.eth0.secure_redirects=0

  net.ipv4.conf.default.secure_redirects=0

  net.ipv4.conf.eth0.send_redirects=0

  net.ipv4.conf.lo.send_redirects=0

  net.ipv4.conf.default.send_redirects=0

  net.ipv4.conf.all.send_redirects=0

  net.ipv4.tcp_syncookies=1

  net.ipv4.icmp_echo_ignore_broadcasts=1

  net.ipv4.icmp_ignore_bogus_error_responses=1

  #Web Servers

  net.ipv4.tcp_tw_reuse=1

  net.ipv4.tcp_tw_recycle=1

  net.ipv4.tcp_fin_timeout=30

  net.ipv4.tcp_keepalive_time=1800

  net.ipv4.core.wmem_max=16777216

  net.ipv4.core.rmem_max=16777216

  net.ipv4.tcp_rmem="4096 87380 8388608"

  net.ipv4.tcp.wmem="4096 87380 8388608"

  net.ipv4.tcp_max_syn_backlog=8192

  防火牆安全:

  iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT

  也有人寫做

  iptables -A INPUT -p tcp --syn -m limit --limit 1/s -j ACCEPT

  --limit 1/s 限制syn併發數每秒1次,能夠根據本身的須要修改

  防止各類端口掃描

  iptables -A FORWARD -p tcp --tcp-flags SYN,ACK,FIN,RST RST -m limit --limit 1/s -j ACCEPT

  Ping洪水***(Ping of Death)

  iptables -A FORWARD -p icmp --icmp-type echo-request -m limit --limit 1/s -j ACCEPT

  備註說明:(相對比較激進的網絡參數調整)

  # Use TCP syncookies when needed

  net.ipv4.tcp_syncookies = 1

  # Enable TCP window scaling

  net.ipv4.tcp_window_scaling: = 1

  # Increase TCP max buffer size

  net.core.rmem_max = 16777216

  net.core.wmem_max = 16777216

  # Increase Linux autotuning TCP buffer limits

  net.ipv4.tcp_rmem = 4096 87380 8388608

  net.ipv4.tcp_wmem = 4096 65536 8388608

  # Increase number of ports available

  net.ipv4.ip_local_port_range = 1024 65000

相關文章
相關標籤/搜索