haproxy 端口资源耗尽,扩大tcp可用端口范围

haproxy TCP源端口耗尽问题
https://www.centos.bz/2018/01/haproxy-tcp%E6%BA%90%E7%AB%AF%E5%8F%A3%E8%80%97%E5%B0%BD%E9%97%AE%E9%A2%98/

查看
sysctl net.ipv4.ip_local_port_range
net.ipv4.ip_local_port_range = 32768 61000
增加到64K个源端口

vi /etc/sysctl.conf
net.ipv4.ip_local_port_range = 1025 65000
生效
sysctl -p

2、允许处于TIME_WAIT状态的源端口重用(这个如果网间有nat要慎用)
[haproxy ~]# vi /etc/sysctl.conf
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

3、使用多个IP连接单一dstIP:port,并让haproxy来管理源端口
配置示例:

....
server mysql1 10.0.0.1:3306 check source 10.0.0.100:1025-65000
server mysql1_bis 10.0.0.1:3306 check source 10.0.0.101:1025-65000
....

© 2018, 新之助meow. 原创文章转载请注明: 转载自http://www.xinmeow.com

0.00 avg. rating (0% score) - 0 votes
点赞