haproxy load balancing cluster of mysql:
Reference website: https://www.cnblogs.com/jave1ove/p/5980053.html
Note:
MySQL cluster model, I used to mysql cluster (ndb engine)
Installation haproxy slightly
we /etc/haproxy/hapory.cfg
global
log 127.0.0.1 local2 info
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode http
log global
option tcplog (此处需改为tcplog)
option dontlognull
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 5m
timeout server 5m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
MySQL the listen
the bind 0.0.0.0:3306
MODE TCP
Balance of the RoundRobin (polling of the RoundRobin)
Server 10.0.0.2 10.0.0.2:3306
Server 10.0.0.3 10.0.0.3:3306
listen stats
bind 0.0.0.0:8888
mode http
option httplog
maxconn 10
stats refresh 30s
stats uri /stats
:wq
service haproxy restart
That the use of proxy server port 3306 (3306 is occupied, it is also possible to use other ports, such as 3307) to access the cluster port 3306, when write access ip ip haproxy of
Reproduced in: https: //blog.51cto.com/yangzhiming/2409836