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

[MySQL] semi-synchronous and enhanced semi-synchronous replication

2025-03-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

First of all, you need to understand the three stages of transaction commit, which I will not repeat here.

Semi-synchronous replication: the master has already submitted it, but the log has not yet been transferred to the slave database, so it is down at this time. From the point of view of semi-synchronization, the other sessions of the master database seem to be transparent, seeing the data he has submitted, but it will be contradictory if he switches to the slave,slave and does not commit the data at this time. While the enhanced synchronization, alter_sync, and logs are not transferred to the slave database, and the main database is not submitted at this time, the service is down, and other sessions of the master database see the uncommitted data, and it is not transferred to the slave database, so there is no data loss.

Lossless copy, binary has been written, but no commit has been hung up, but the master-slave data is the same, because although there is no submission, binary has been written and has been passed to slave. To build semi-synchronous replication, plug-ins need to be installed for semi-synchronous replication:

In the parameter file, you can specify that plugin_load is loaded every time you start, or you can install the plug-in directly.

Manually:

Install plugin rpl_semi_sync_master SONAME 'semisync_master.so'

Install plugin rpl_semi_sync_slave SONAME 'semisync_slave.so'

Configuration file:

Loose_rpl_semi_sync_master_enabled=1 # means enable

Loose_rpl_semi_sync_slave_enabled=1 # means enable

Loose_ means that without this parameter, it will be ignored.

When the delay of semi-automatic replication is more than 5 seconds, it becomes asynchronous replication, and the IO thread of the standby database automatically becomes semi-synchronous replication when it is traced to less than 5 seconds. Wait ACK means that the IO thread has received it, and the SQL thread has not finished applying it.

It can increase the timeout time to improve data security and ensure that the data is not lost at all, but it also brings the problem of application response, that is, forced semi-synchronous replication.

5.7 enhanced semi-synchronization

Rpl_semi_sync_master_wait_point=AFTER_SYNC enables lossless copy

At least one rpl_semi_sync_master_wait_for_slave_count=1 received this parameter from the library.

MTS multi- threaded slave (parallel replication) 5.7. it is recommended that you must use:

Slave-parallel-type=LOGICAL_CLOCK

[DATABASE] parallel replication of DATABASE, with one database for each Coordinator thread. DATABASE is no longer recommended, and [LOGICAL_CLOCK] the slave library is as parallel as it is on the master library. So there is a problem, the master library group commit, so can the slave library also complete group commit through parallel replication? Yes, because the transactions committed by the group do not conflict with each other

Slave-parallel-workers=32 or 16

MTS still receives state as Waiting for master to send event for an IO thread; SQL thread applies with System lock and waits with state as waiting for an event from Coordinator

In the case of IO bond, the performance improvement of enabling MTS is very obvious. The number of parallelism enabled in pure OLTP environment is 16 or 32, and the performance of the main library is improved by about 5 times.

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