前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Mycat HA(高可用) 与 LB(负载均衡)13

Mycat HA(高可用) 与 LB(负载均衡)13

作者头像
franket
发布2021-12-02 09:50:35
4500
发布2021-12-02 09:50:35
举报
文章被收录于专栏:技术杂记

正确的写法是

代码语言:javascript
复制
#contimeout 5000
  timeout connect 5000
#clitimeout 50000
  timeout client 50000
#srvtimeout 50000
  timeout server 50000

Note: mycat官方文档中是使用 listen all_mycat 192.168.100.101:8888 的方式对ip进行绑定,但这种方式已经不被支持,如果使用这种方式,会有如下报错

代码语言:javascript
复制
[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]# 

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 启动haproxy
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档