Master-slave switch in MySQL cluster

The first case: the host is not down, and the normal switch

The first step is to stop the master-slave operation

Execute on the slave,

SHOW PROCESSLIST

It is found that Has read all relay log waiting for the slave I/O thread to update it and other words indicate that it has been synchronized at this time.

 

Perform again.

STOP SLAVE;

RESET MASTER;

RESET SLAVE;

On the host,

RESET MASTER;

 Restart mysql separately on all machines

systemctl restart mariadb

It can be found that there is no relevant information on the slave.

 

Execute RESET MASTER on the master and slave; after that, check the status of the master

show master status;

 

It can be seen that everything is restored as before. There is no longer a master and a slave. Then it can be set according to the way of setting master and slave.

The second step is to set the master-slave operation

Just like the master-slave has never been set before, reset the master-slave.

Please refer to another article

https://blog.csdn.net/Kangyucheng/article/details/108265828

The second case: the host is down

When the host is down, there is no need to operate the host.

Execute on the slave that needs to be set as the master.

STOP SLAVE;

RESET MASTER;

This machine is now the host. With this machine as the host, you can set the master and slave.

If there are other slaves, just reset their status and set the master for them.

Guess you like

Origin blog.csdn.net/Kangyucheng/article/details/108273924