当前位置:网站首页>Semi synchronous replication of MySQL master-slave replication
Semi synchronous replication of MySQL master-slave replication
2022-04-22 20:35:00 【Wheat seedling DB treasure】
MySQL Semi synchronous replication of master-slave replication
The disadvantage of asynchronous replication is , When the main warehouse event After writing binary log , I don't know whether the slave library has accepted and applied logs ; If the main library goes down unexpectedly or breaks down , It is very likely that the things submitted by the master library are not transmitted to any slave library machine . Perform active and standby switching under the highly available cluster architecture , It will cause the new master database to lose data .
mysql5.5 The semi synchronous replication function is introduced after version , The master-slave server must install the semi synchronous replication plug-in , To enable the copy function . This function ensures that the data transferred from the main library is received from the library binlog The content has been written into your own relay log Inside the , Will notify the waiting thread on the main library , The operation is completed .
If the wait times out , exceed rpl_semi_sync_master_timeout Parameter setting time , Turn off semi synchronous replication , And automatically converted to asynchronous replication mode , Until at least one slave notifies the master that it has received binlog Information location .
Semi synchronous replication improves the consistency of data between master and slave , Make replication more secure , stay mysql5.7 The version has added rpl_semi_sync_master_wait_point Parameters , It is used to control the return of the main library to session How to commit a transaction before it succeeds .
This parameter has two values :
AFTER_SYNC( The default value ): The master server writes each transaction to its binary log and the slave server , And synchronize the binary log to disk . After synchronization , The master device waits for the slave device to acknowledge the receipt of the transaction . After receiving the confirmation , The master server submits the transaction to the storage engine , And return the result to the client , Then the client can continue .
AFTER_COMMIT: The master server writes each transaction to its binary log and the slave server , Synchronize binary logs , And submit the transaction to the storage engine . After the master commits, wait for the slave server to confirm the receipt of the transaction . After receiving the confirmation , The host returns the result to the client , Then the client can continue .
2.1 Semi synchronous installation
Install the replication plug-in and enable the semi synchronous replication function on the main database :
INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
set global rpl_semi_sync_master_enabled=on;

show variables like '%rpl_semi_sync_master%';

Add main library parameter file :
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=1000
show plugins;

SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE '%semi%';

Similarly, the slave library can also install plug-ins and enable semi synchronous replication :
Install the replication plug-in from the library and enable the semi synchronous replication function :
INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
set global rpl_semi_sync_slave_enabled=on;

Add parameter file of standby database :
rpl_semi_sync_slave_enabled=1
Because it used to be asynchronous replication , The slave library needs to be restarted IO Threads , Activate semi synchronous replication .
STOP SLAVE IO_THREAD;
START SLAVE IO_THREAD;

View the main library :
There is already a slave library connected to the master library . And it's semi synchronous .
show variables like '%rpl_semi_sync_master%';

2.2 Switch from semi synchronous mode to asynchronous mode
1、 The main library timeout exceeds the specified parameter time
rpl_semi_sync_master_timeout Time is 10s. It is recommended to set as large as possible in production .
set global rpl_semi_sync_master_timeout=xxx;

2、 Manual switching
Main library
set rpl_semi_sync_master_enabled=off;
Slave Library :
set rpl_semi_sync_slave_enabled=off
Close slave Library I/O thread
stop salve io_thread;
start salve io_thread;
About Me
........................................................................................................................ ● The author of this article : Wheat seedling , Some content is organized from the network , In case of infringement, please contact wheat seedling to delete ● this paper pdf edition 、 Personal profile and address of wheat seedling cloud disk : http://blog.itpub.net/26736162/viewspace-1624453/ ● Database of written interview questions and Solutions : http://blog.itpub.net/26736162/viewspace-2134706/ ● DBA Baodian's headline address today : http://www.toutiao.com/c/user/6401772890/#mid=1564638659405826 ........................................................................................................................ ● QQ Group number : 230161599 ( full ) 、618766405
● On 2019-07-01 06:00 ~ 2019-07-31 24:00 Completed in Xi'an ● Last modified :2019-07-01 06:00 ~ 2019-07-31 24:00 ● The content of the article comes from the study notes of Wheat Seedling , Partially collated from the network , If there is any infringement or improper place, please understand ● copyright , Welcome to share this article , Reprint please keep the source ........................................................................................................................ Use tiny Trust client Scan the following two-dimensional code to pay attention to the micro structure of wheat seedlings The public letter no. ( xiaomaimiaolhr )
........................................................................................................................ |
版权声明
本文为[Wheat seedling DB treasure]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221935230356.html
边栏推荐
- Redis's key and value best practices
- 华为机试题——HJ62 查找输入整数二进制中1的个数
- Windows install redis
- Use of list
- Character array and string: delete all spaces in the string. (10 points) write a function to delete all spaces in the string.
- Countdown case
- 【dfs】386. 字典序排数
- 转载:程序员的发展方向
- Message queuing best practices
- Your so-called comfort is slowly destroying you!
猜你喜欢

木瓜移动课堂:产品更新,Facebook新增素材预审功能,力控广告违规~
![[suggestions collection] no highlights in the interview](/img/65/40d65aad750ce99ee7ef134e4f3ee3.png)
[suggestions collection] no highlights in the interview

Fault analysis | federated storage engine table causes the monitoring thread to be in the opening table state

@Requestmapping get request parameters

2020团队设计天梯赛(部分)

动态数据库工具——Database Inspector

Matlab learning notes - calculate eigenvectors and manually execute PCA

Boot implementation of IAP

Add / remove / filter / sort array elements

MySQL高可用架构设计分析
随机推荐
Perfect forwarding implementation mechanism
October's Android interview failed miserably in byte three, and fortunately won Xiaomi offer
D trigger in FPGA
Dynamic database tool -- database inspector
Incorrect string value: ‘\xF0\x9F\x92\x95\’
IOS development - Database - common operations (02)
专访木瓜移动刘凡:木瓜移动如何为行业聚能?
Mastering the tips of these references will help you get twice the result with half the effort~
Website: fakeimg Pl (text -- > picture)
H. Maximal AND
Use of swift protocol
(L2-026)小字辈(带权并查集)
IOS开发之——数据库-常见操作(02)
UML (Unified Modeling Language) knowledge learning
MySQL主从复制之异步复制
对话木瓜移动创始人沈思 l 从硅谷到北京
Fault analysis | federated storage engine table causes the monitoring thread to be in the opening table state
(l2-026) small generation (with weight and search set)
2020 team design ladder competition (part)
Da14580 sends data as server
