Master_1: 192.168.1.200
Master_2: 192.168.1.144
VIP:192.168.1.151
Master_1:
Master_2:
Step 1: install MySQL on 192.168.1.200 and 192.168.1.144, here I am using the binary file to install.
Master_1
Master_2
MySQL configure
file on Master_1
MySQL
configure file on Master_2
Step 2: Check the master-slave running status on both side
Master_1:
Master_2:
Now the multiple master running well already, next we will install and configure the keepalived
Step 3: install keepalived on both 2 nodes.
yum install default path is /etc/keepalived/
Step 4: create MySQL notify down shell script on both nodes.
Step 5: vi /etc/keepalived/keepalived.conf and do keepalived configuration on master_1
Step 6: vi /etc/keepalived/keepalived.conf and do keepalived configuration on master_2
Step 7: startup keepalived on master_1, from log message can see the virtual ip 192.168.1.151 up already.
Step 8: startup keepalived on master_2
Step 9: create a MySQL user for both master_1 and master_2
Step 10: try to test mysql VIP connection from a client
Step 11: test keepalived failover
Keep ping the VIP through client side, and stop the keepalived service on master_1(192.168.1.200), see whether can failover to master_2(192.168.1.144)
Master_1 stop keepalived service, log show VIP remove from 192.168.1.200 already.
Check on Master_2, message show VIP 192.168.1.151 add to master_2 already.
Start keepalived on master_1 again, the VIP switch from master_2 to master_1
Step 12: Test MySQL failover
1: Stop mysql service on master_1, check VIP whether can failover to master_2
Stop MySQL on master_1, log show keepalived service auto stopped on master_1
VIP
failover to Master_2 already.
2:start
mysql and keepalived service on master_1, see whether VIP switch to master_1
The
failover usually 3-5 seconds, when do switching, MySQL query will encounter error message.
The End