ulimit -SHn 65535
内核优化
net.ipv4.ip_forward = 1 #开启路由功能
net.ipv4.conf.default.rp_filter = 1 #禁用所有IP源路由
net.ipv4.conf.default.accept_source_route = 0 #禁用icmp源路由选项
kernel.sysrq = 0 #关闭SysRq功能,SysRq代表的是Magic System Request Key
kernel.core_uses_pid = 1 #控制core文件的文件名是否添加pid作为扩展
net.ipv4.tcp_syncookies = 1 # tcp syncookie,默认关闭
kernel.msgmnb = 65536 #默认的每个消息队列的最大尺寸(byte),默认为16384
kernel.msgmax = 65536 #消息队列中单条消息的最大尺寸(byte),默认8192
kernel.shmmax = 68719476736 #共享内存中的最大内存块尺寸(byte),默认33554432(32M),这里是65536M
kernel.shmall = 4294967296 #kernel.shmall的单位是页面数,当前的x86体系上这个单位是4K,这里是2048G的共享内存总量,默认2097152
fs.file-max = 6553600 #系统级最大打开文件数,还要结合limits.conf的soft和hard限制
net.ipv4.tcp_max_tw_buckets = 5000 #1st低于此值,TCP没有内存压力,2nd进入内存压力阶段,3rdTCP拒绝分配socket(单位:内存页)
net.ipv4.tcp_sack = 1 #定义SYN重试次数
net.ipv4.tcp_window_scaling = 1 #开启窗口缩放功能
net.ipv4.tcp_rmem = 4096 87380 4194304 #接受缓冲的大小:MIN,DEFAULT,MAX
net.ipv4.tcp_wmem = 4096 16384 4194304 #socket的发送缓存区分配的MIN,DEFAULT,MAX
net.ipv4.tcp_max_syn_backlog = 8192 #syn队列,默认1024,> 1280可能工作不稳定,需要修改内核源码参数
net.core.netdev_max_backlog = 32768 #进入包的最大设备队列.默认是300,对重负载服务器而言,该值太低,可调整到2000.
net.core.somaxconn = 32768 #listen()的默认参数,挂起请求的最大数量.默认是128.对繁忙的服务器,增加该值有助于网络性能
net.core.wmem_default = 8388608 #表示套接字发送缓冲区大小的缺省值,会覆盖net.ipv4.tcp_wmem的DEFAUL值
net.core.rmem_default = 8388608 #表示套接字接收缓冲区大小的缺省值
net.core.rmem_max = 16777216 #表示套接字接收缓冲区大小的最大值
net.core.wmem_max = 16777216 #表示套接字发送缓冲区大小的最大值,会覆盖net.ipv4.tcp_wmem的MAX值
net.ipv4.tcp_timestamps = 0 #禁用时间戳,时间戳可以避免序列号的卷绕
net.ipv4.tcp_synack_retries = 2 #syn-ack握手状态重试次数,默认5,遭受syn-flood攻击时改为1或2
net.ipv4.tcp_syn_retries = 2 #外向syn握手重试次数,默认4
net.ipv4.tcp_tw_recycle = 1 #开启 TCP 连接中 TIME-WAIT sockets 的快速回收,默认为 0 ,表示关闭。
net.ipv4.tcp_tw_reuse = 1 #开启重用。允许将 TIME-WAIT sockets 重新用于新的 TCP 连接,默认为 0 ,表示关闭;
net.ipv4.tcp_mem = 94500000 915000000 927000000 #1低于此值,TCP没有内存压力,2在此值下,进入内存压力阶段,3高于此值,TCP拒绝分配socket.上述内存单位是页
net.ipv4.tcp_max_orphans = 3276800 #选项用于设定系统中最多有多少个TCP套接字不被关联到任何一个用户文件句柄上,如果超过这个数字,孤立连接将立即被复位并打印出警告信息
net.ipv4.tcp_fin_timeout = 30 #修改系統默认的 TIMEOUT 时间
net.ipv4.tcp_keepalive_time = 300 #表示当keepalive起用的时候,TCP发送keepalive消息的频度。缺省是2小时,改为5分钟。
net.ipv4.ip_local_port_range = 1024 65000 #表示用于向外连接的端口范围。缺省情况下过窄:32768到61000,改为1024到65535。
net.ipv4.ip_conntrack_max = 655360 #增大iptables状态跟踪表
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=2...
https://github.com/search?q=2...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=2...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=2...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=2...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=k...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
https://github.com/search?q=%...
net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 180 #设置默认 TCP 连接时长为180秒