调整Linux内核参数:

# vi /etc/sysctl.conf

# tells the Kernel it's ok if services bind to non-existant IP ADDR

# net.ipv4.ip_nonlocal_bind = 1

# defines the size of the kernel queue for accepting new connections, Defaults to 128

net.core.somaxconn = 40000

# Maximum number of remembered connection requests, Defaults to 1024

net.ipv4.tcp_max_syn_backlog = 40000

# Tuning TCP Ports, increase the range to allow for more connections. 

# The number of avaliable ports limits the number of simultanious open connections.

net.ipv4.ip_local_port_range = 1024 65535

# Tell kernel to reuse faster the connection in TIME_WAIT

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

# Resetting the File Descriptors, the maximum number of open files allowed per process

fs.file-max = 1000000

使设置生效:

# sysctl -p

调整最大打开文件描述符限制

调整文件描述符限制:

# ulimit -n 1000000

# vi /etc/security/limits.conf

# Setting Shell Limits for File Descriptors

* soft nofile 1000000

* hard nofile 1000000

使用PAM模块限制资源:

# vi /etc/pam.d/login

session required pam_limits.so 


作者:​​柒月​