正确的写法是
代码语言:javascript复制#contimeout 5000
timeout connect 5000
#clitimeout 50000
timeout client 50000
#srvtimeout 50000
timeout server 50000
代码语言:javascript复制Note: mycat官方文档中是使用 listen all_mycat 192.168.100.101:8888 的方式对ip进行绑定,但这种方式已经不被支持,如果使用这种方式,会有如下报错
[root@h101 haproxy]# /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
[ALERT] 063/223814 (22295) : parsing [/usr/local/haproxy/haproxy.cfg:29] : 'listen' cannot handle unexpected argument '192.168.100.101:8888'.
[ALERT] 063/223814 (22295) : parsing [/usr/local/haproxy/haproxy.cfg:29] : please use the 'bind' keyword for listening addresses.
[WARNING] 063/223814 (22295) : parsing [/usr/local/haproxy/haproxy.cfg:36] : overwriting 'timeout server' which was already specified
[ALERT] 063/223814 (22295) : Error(s) found in configuration file : /usr/local/haproxy/haproxy.cfg
[WARNING] 063/223814 (22295) : config : proxy 'all_mycat' has no 'bind' directive. Please declare it as a backend if this was intended.
[WARNING] 063/223814 (22295) : config : missing timeouts for proxy 'all_mycat'.
| While not properly invalid, you will certainly encounter various problems
| with such a configuration. To fix this, please ensure that all following
| timeouts are set to a non-zero value: 'client', 'connect', 'server'.
[WARNING] 063/223814 (22295) : config : log format ignored for proxy 'all_mycat' since it has no log address.
[ALERT] 063/223814 (22295) : Fatal errors found in configuration.
[root@h101 haproxy]#
正确的写法是使用 bind
代码语言:javascript复制listen all_mycat
bind *:8888
mode tcp
option tcplog
balance roundrobin
server mycat_101 192.168.100.101:8066 check port 8066 inter 5s rise 2 fall 3
server mycat_102 192.168.100.102:8066 check port 8066 inter 5s rise 2 fall 3
timeout server 20000
详细内容可以参考 Haproxy 配置
启动haproxy
代码语言:javascript复制[root@h101 haproxy]# /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
[root@h101 haproxy]# ps faux | grep -v grep | grep haproxy
haproxy 23083 0.0 0.0 14260 936 ? Ss 22:43 0:00 /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfg
[root@h101 haproxy]# netstat -ant | grep -E "(8066|9066|8888|9999|1234)"
tcp 0 0 0.0.0.0:1234 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9999 0.0.0.0:* LISTEN
tcp 0 0 :::8066 :::* LISTEN
tcp 0 0 :::9066 :::* LISTEN
[root@h101 haproxy]#