Xtradb after the cluster deployment is complete, 3 machine can read and write at the same time, it needs to be built in front Haproxy For load Balancing.
official website haproxy Configuration reference address:
Https://www.percona.com/doc/percona-xtradb-cluster/5.6/howtos/virt_sandbox.html
Haproxy Server Configuration
take a machine as a haproxy, here is 192.168.6.219.
Installing Haproxy
Yum Install Haproxy-y
Configuration file:
[Email protected] ~]# cat/etc/haproxy/haproxy.cfg
Global
Log 127.0.0.1 Local0
Log 127.0.0.1 Local1 Notice
Maxconn 4096
Chroot/usr/share/haproxy
User Haproxy
Group Haproxy
Daemon
Defaults
Log Global
Mode http
Option Tcplog
Option Dontlognull
Retries 3
Option Redispatch
Maxconn 2000
Contimeout 5000
Clitimeout 50000
Srvtimeout 50000
Frontend Pxc-front
Bind *:3307
Mode TCP
Default_backend Pxc-back
Frontend Stats-front
Bind *:8080
Mode http
Default_backend Stats-back
Frontend Pxc-onenode-front
Bind *:3308
Mode TCP
Default_backend Pxc-onenode-back
Backend Pxc-back
Mode TCP
Balance Leastconn
Option Httpchk
Server C1 192.168.70.71:3306 Check Port 9200 Inter 12000 rise 3fall 3
Server C2 192.168.70.72:3306 Check Port 9200 Inter 12000 rise 3fall 3
Server C3 192.168.70.73:3306 Check Port 9200 Inter 12000 rise 3fall 3
Backend Stats-back
Mode http
Balance Roundrobin
Stats Uri/haproxy/stats
Stats Auth Pxcstats:secret
Backend Pxc-onenode-back
Mode TCP
Balance Leastconn
Option Httpchk
Server C1 192.168.70.71:3306 Check Port 9200 Inter 12000 rise 3fall 3
Server C2 192.168.70.72:3306 Check Port 9200 Inter 12000 rise 3fall 3
Server C3 192.168.70.73:3306 Check Port 9200 Inter 12000 rise 3fall 3
Start Haproxy
/etc/init.d/haproxy start
Web Access
The 8080 ports and /haproxy/stats configured above
access URL:192.168.6.219:8080/haproxy/stats
User name password is the Pxcstats:secret configured above
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/71/51/wKioL1XLHSPRsohPAAIHV_hx58I687.jpg "title=" QQ picture 20150812180419.png "alt=" Wkiol1xlhsprsohpaaihv_hx58i687.jpg "/>
Xtradbon the serverxinetdConfiguration
On all xtradb servers, configure xinetd to open the 9200 port for monitoring.
Yum instal xinetd
Configuring mysqlchk Monitoring
[Email protected] mysql]# Cat/etc/xinetd.d/mysqlchk
# Default:on
# Description:mysqlchk
Service Mysqlchk
{
# This was a config for xinetd, place it in/etc/xinetd.d/
Disable = no
Flags = Reuse
Socket_type = Stream
Type = Unlisted
Port = 9200
wait = no
user = Nobody
Server =/usr/bin/clustercheck
Log_on_failure + = USERID
Only_from = 0.0.0.0/0
#
# passingarguments to Clustercheck
# <user><pass> <available_when_donor=0|1> <log_file><available_when_readonly=0|1> <defaults_extra_file> "
# Recommended:server_args = user Pass 1/var/log/log-file 0/etc/my.cnf.local "
# Compatibility:server_args = user Pass 1/var/log/log-file 1/etc/my.cnf.local "
# 55-to-56upgrade:server_args = user Pass 1/var/log/log-file 0/etc/my.cnf.extra "
#
# recommended Toput the IPs that need
# to connectexclusively (security purposes)
Per_source = UNLIMITED
}
This configuration is installed by default when XTRADB server is installed.
Restart xinetd service
/etc/init.d/xinetd restart
Haproxy detects the 9200 port on the XTRADB server every time , and when the Clustercheck command executes The Haproxy test will remove the machine from load balancing to achieve an automatic failover effect.
This article from "Yang Cloud" blog, reproduced please contact the author!
Xtradb+haproxy high-Availability DB cluster (ii) HAPROXY load Balancing Chapter