doondroar 发表于 2014-7-28 11:25:14

haproxy负载均衡中mysql数据库读写分离怎么实现?

后端两台mysql服务器:
192.168.10.21和192.168.10.22
后端两台mysql服务器用xinetd分别开通两个服务:
1、mysql状态监测服务,端口9200,正常返回200,异常返回503;
2、mysql同步监测服务,端口9201,正常返回200,异常返回503;
一台负载均衡服务器(安装haproxy):
192.168.10.50
现在我想在haproxy服务器上用同一个端口(3306)实现负载均衡和读写分离,我如下设置策略,不知道可以吗?
listencluster_db_read/write 192.168.10.50:3306
      mode tcp
      log 127.0.0.1 local0 info
      option tcpka
      #option mysql-check
      balance roundrobin
      optionhttpchk GET /dbs
      serverdb01 192.168.10.21:3306 weight 1 check port 9200 inter 2000 rise 2 fall 5
      serverdb01 192.168.10.21:3306 weight 1 check port 9201 inter 2000 rise 2 fall 5
      serverdb02 192.168.10.22:3306 weight 1 check port 9200 inter 2000 rise 2 fall 5 backup
      serverdb02 192.168.10.22:3306 weight 1 check port 9201 inter 2000 rise 2 fall 5 backup

kider 发表于 2014-7-28 11:53:37

没细细研究过haproxy
页: [1]
查看完整版本: haproxy负载均衡中mysql数据库读写分离怎么实现?