Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

How to setup failover of Galera cluster(MySQL) across two datacenters

$
0
0

I have two Galera clusters(MySQL) of three nodes each (two + garb node). The clusters are in separate data-centers (dc1 and dc2). The cross cluster replication happens between node1-dc1 and node1-dc2

How to support fail-over in case node1-dc1 goes down and node2-dc1 to be active.

How can I get this done? Recommendations and best practices are also welcome.

This is how replication is set up between node1-dc1 and node1-dc2

1 - On each node add following lines to /etc/my.cnf file and restart mysql service.

# vi /etc/my.cnf
server-id=101       # 102 for the remote galera node
log-slave-updates=1
log-bin=mysql-bin
gtid_mode=ON
enforce-gtid-consistency=1

2 - Add grant to 'replicant' user on both nodes

mysql> GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO replicant@'%' IDENTIFIED BY 'password';

3 - Start replication on both nodes, set MASTER_HOST to IP address of the other node

mysql> STOP SLAVE;
mysql> CHANGE MASTER TO MASTER_HOST = 'XXX.YYY.ZZZ.XXX', MASTER_PORT = 3306, MASTER_USER = 'replicant', MASTER_PASSWORD = 'password', MASTER_AUTO_POSITION = 1;
mysql> START SLAVE;

Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>