Wondering how to do Galera cluster asynchronous replication? We can help you.
Galera can be used in database replication for frequently copying data from one node to another node.
We do database replication to provide high scalability and availability of the database.
At Bobcares, we often get requests to set up database replication, as a part of our Server Management Services.
Today, let’s see how our Support Engineers set up this.
Galera cluster asynchronous replication for MySQL
Now let’s see how our Support Engineers do MySQL replication with the Galera cluster.
Initially, we will deploy the clusters as required. Here let’s take the instance where we use 6 nodes.
That is 3 for primary and 3 for the disaster recovery site.
Then we take one node and setup an asynchronous replication link.
The parameters inside my.cnf will be seen as given below:
server_id=40 # this number must be different on every node. binlog_format=ROW log_bin = /var/lib/mysql-binlog/binlog log_slave_updates = ON gtid_mode = ON enforce_gtid_consistency = true expire_logs_days = 7
Then we will create a replication user and point the slave to master to replicate the slave.
We can do this using the following commands:
mysql> GRANT REPLICATION SLAVE ON *.* to slave@'%' IDENTIFIED BY 'slavepassword'; mysql> CHANGE MASTER TO MASTER_HOST = 'galera3-primary', MASTER_USER = 'slave', MASTER_PASSWORD = 'slavepassword' , MASTER_AUTO_POSITION=1; mysql> START SLAVE;
Next, we need to set up alternative master nodes in one cluster in case of failure. That is, if the master node in cluster 1 fails then another node in the same cluster must be available for the client.
In addition, we will also consider the situation where the cluster itself fails. In this case, if the primary cluster is not available for the client then the second one will be available.
[Still, having trouble in replicating your Galera cluster? – We can help you.]
In short, we saw how to do Galera cluster asynchronous replication for MySQL. Also, we saw the steps our Support Engineers follow to do this.