1.内核参数 /etc/sysctl.conf
vim /etc/sysctl.conf #进入这个文件修改sysctl -p #让修改的内核信息生效
#################################################kernel.sem = 250 32000 100 128
fs.aio-max-nr = 65536# 推荐值(1024*1024 = 1024K)fs.aio-max-nr = 1048576
# 关闭 SysRq 功能以增强安全性kernel.sysrq = 0kernel.pid_max = 65535# File system parameters# 设置最大打开文件数,适应高并发环境fs.file-max = 2097152
# 设置每个用户的最大文件监视数,适应应用程序可能的大量文件变化监听fs.inotify.max_user_watches = 524288
# 设置每个进程允许打开的文件数量,高于默认值以适应高并发fs.nr_open = 2000500
fs.file-max = 999999net.ipv4.ip_forward = 0net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.default.accept_source_route = 0kernel.sysrq = 0kernel.core_uses_pid = 1net.ipv4.tcp_syncookies = 1kernel.msgmnb = 65536kernel.msgmax = 65536kernel.shmmax = 68719476736kernel.shmall = 4294967296net.ipv4.tcp_max_tw_buckets = 6000net.ipv4.tcp_sack = 1net.ipv4.tcp_window_scaling = 1net.ipv4.tcp_rmem = 10240 87380 12582912net.ipv4.tcp_wmem = 10240 87380 12582912net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.core.netdev_max_backlog = 262144net.core.somaxconn = 40960net.ipv4.tcp_max_orphans = 3276800net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_timestamps = 0net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_mem = 94500000 915000000 927000000net.ipv4.tcp_fin_timeout = 30net.ipv4.tcp_keepalive_time = 30net.ipv4.ip_local_port_range = 1024 65000
2. 资源限制配置文件
cat >> /etc/security/limits.conf * soft core unlimited* hard core unlimited* soft nproc 1048576* hard nproc 1048576* soft nofile 1048576* hard nofile 1048576* soft memlock unlimited* hard memlock unlimited* soft msgqueue unlimited* hard msgqueue unlimitedEOF
领取专属 10元无门槛券
私享最新 技术干货