Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report