# 查看系统默认的值
ulimit -n
# 设置最大打开文件数
ulimit -n 1000000
# 用户级别设置 /etc/security/limits.conf (重启服务器或重新登陆生效)
root soft nofile 1040000
root hard nofile 1040000
root soft nofile 1040000
root hard nproc 1040000
root soft core unlimited
root hard core unlimited
* soft nofile 1040000
* hard nofile 1040000
* soft nofile 1040000
* hard nproc 1040000
* soft core unlimited
* hard core unlimited
# 系统全局设置 /proc/sys/fs/file-max (大于limits)
9223372036854775807
# 系统全局设置 /etc/sysctl.conf
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
# 运行【 sudo sysctl -p 】生效