优化Linux 内核参数
Linux是一套免费使用和自由传播的操作系统内核,是一个基于POSIX和Unix的多用户、多任务、支持多线程和多CPU的操作系统内核。它能运行主要的Unix工具软件、应用程序和网络协议。它支持32位和64位硬件。Linux继承了Unix以网络为核心的设计思想,是一个性能稳定的多用户网络操作系统内核
下面是优化内核参数 已提高系统负载 复制下列框中内容直接粘贴在Shell中直接执行即可
sysctl -w fs.file-max=999999
sysctl -w kernel.pid_max=999999
sysctl -w kernel.threads-max=9999999
sysctl -w vm.max_map_count=999999
echo "* soft nofile 999999" >> /etc/security/limits.conf
echo "* hard nofile 999999" >> /etc/security/limits.conf
systemctl restart sshd
chmod +x /etc/rc.local
ulimit -SHn 999999
ulimit -u 9999999
echo "ulimit -SHn 999999" >> /etc/rc.local
echo "ulimit -u 9999999" >> /etc/rc.local
ulimit -Hn
ulimit -Sn
cat /proc/sys/fs/file-max
第二版优化 如下
ifconfig bond0 txqueuelen 5000
echo "/sbin/ifconfig bond0 txqueuelen 5000" >> /etc/rc.local
sysctl net.ipv4.ip_local_port_range="15000 61000"
sysctl net.ipv4.tcp_fin_timeout=30
sysctl net.ipv4.tcp_tw_recycle=1
sysctl net.ipv4.tcp_tw_reuse=1
sysctl net.core.netdev_max_backlog=400000
sysctl -w net.core.optmem_max=204800
sysctl -w net.core.rmem_default=204800
sysctl -w net.core.rmem_max=204800
sysctl -w net.core.somaxconn=262114
sysctl -w net.ipv4.tcp_ecn=0
sysctl -w net.ipv4.tcp_max_syn_backlog=8192
sysctl -w net.ipv6.conf.all.disable_ipv6=1
sysctl -w net.ipv6.conf.default.disable_ipv6=1
sysctl -w net.ipv6.conf.lo.disable_ipv6=1
sysctl -w net.ipv4.tcp_keepalive_time=7200
sysctl -w net.ipv4.tcp_max_tw_buckets=262144
sysctl -w net.ipv4.tcp_rmem="10240 87380 12582912"
sysctl -w net.ipv4.tcp_wmem="10240 87380 12582912"
sysctl -w net.ipv4.tcp_syncookies=1
sysctl -w net.ipv4.tcp_max_orphans=262114
sysctl -w fs.file-max=999999
sysctl -w kernel.pid_max=999999
sysctl -w kernel.threads-max=9999999
sysctl -w vm.max_map_count=999999
echo "* soft nofile 999999" >> /etc/security/limits.conf
echo "* hard nofile 999999" >> /etc/security/limits.conf
systemctl restart sshd
chmod +x /etc/rc.local
ulimit -SHn 999999
ulimit -u 9999999
echo "ulimit -SHn 999999" >> /etc/rc.local
echo "ulimit -u 9999999" >> /etc/rc.local
ulimit -Hn
ulimit -Sn
cat /proc/sys/fs/file-max