Get the App
SLTechnology News&Howtos  ›  Database  › 

How to implement Master-Slave semi-synchronous replication in MYSQL Architecture

Shulou Source: shulou.com Published: 2022-05-31 17:19:02 09月22日 Update

This article shows you how to carry out master-slave semi-synchronous replication in MYSQL architecture, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The semi-synchronous replication function has been introduced after Mysql version 5.5. the master-slave server must install the semi-synchronous replication plug-in at the same time to turn on the replication function. Under this function, make sure that the binlog content sent from the main library has been written to your own relay log before notifying the waiting thread above the main library that the operation has been completed. If the wait times out and exceeds the time set by the rpl_semi_sync_master_timeout parameter, semi-synchronous replication is turned off and automatically switched to asynchronous replication mode until at least one slave library notifies the master library that the binlog information has been received.

Parameters:

The rpl_semi_sync_master_wait_point parameter, which is used to control the transaction commit mode before the main library returns to the session transaction successfully in semi-synchronous mode.

1) after_commit

2) after_sync

In after_sync mode, even if the master library is down, all transactions that have been committed on the master library can be guaranteed to be synchronized to the relay log of the slave database without losing any data.

The construction of semi-synchronous replication is based on asynchronous replication.

1. Install semi-synchronous replication plug-in and enable semi-synchronous replication function from master to slave

Main library

Mysql > install plugin rpl_semi_sync_master soname 'semisync_master.so'

Mysql > set global rpl_semi_sync_master_enabled=on

Slave library

Mysql > install plugin rpl_semi_sync_master soname 'semisync_slave.so'

Mysql > set global rpl_semi_sync_slave_enabled=on

Check

Mysql > show plugins

two。 Restart the slave library IO thread

Mysql > stop slave io_thread

Mysql > start slave io_thread

3. Check the environment

1) main library

Mysql > show global status like'% semi%'

Check if rpl_semi_sync_master_clients is 1

Whether rpl_semi_sync_master_status is on

2) from the library

Mysql > show global status like'% semi%'

Check whether rpl_semi_sync_slave_status is on

4. Semi-synchronous replication and asynchronous replication conversion

1) check parameters

Mysql > show variables like'% rpl_semi_sync_master_timeout%'

2) stop thread O thread from the library

Mysql > stop slave io_thread

3) View the status of semi-synchronization from the library

Mysql > show global status like'% semi%'

OFF

4) A new data is added to the main database. When the rpl_semi_sync_master_timeout timeout occurs, semi-synchronous replication can be automatically converted to asynchronous replication.

The above is how to do master-slave semi-synchronous replication in MYSQL architecture. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Synchronization checking master-slave function parameters transactions content patterns architecture skills plug-ins data time knowledge threading concise successful concise information and at the same time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Technology macOS Xiaomi Shulou Tech Info