时间:2021-07-01 10:21:17 帮助过:26人阅读
#For example:if rpl_semi_sync_master_wait_for_slave_count is 2, then 2 slaves must acknowledge receipt of the transaction before the timeout period configured by rpl_semi_sync_master_timeout for semisynchronous replication to proceed. If less slaves acknowledge receipt of the transaction during the timeout period, the master reverts to normal replication.
超时前至少x个来自slave对的ack应答。如果超时前的应答未及该值,则master转为异步复制。
在slave存活大于等于该值时,master提交不会有任何等待发生,一旦slave存活低于该值,则master会进行等待,直到超时。
| rpl_semi_sync_master_wait_no_slave | ON |
# 这个参数,我在中文网络上就没见到说对的!搞懂了~ 20200117:
这个值影响master根据slave数量决定什么时候转为异步复制。
【在完全无事务进行的空业务环境下进行实验】。
原理:
master会根据一定时间获取连接的slave数量(rpl_semi_sync_master_clients) ,同时用获取到的值与参数(rpl_semi_sync_master_wait_for_slave_count)进行对比,来决定使用怎样的复制方式。
实验:
令存活的slave数量小于参数(rpl_semi_sync_master_wait_for_slave_count)值, 过一定时间后,master检测到真实slave数量(rpl_semi_sync_master_clients)小于参数(rpl_semi_sync_master_wait_for_slave_count)值——
如果该值为ON:
master不会立即将半同步复制转为异步复制(Rpl_semi_sync_master_status=ON)。
此时开启事务,只要在超时时间范围内(rpl_semi_sync_master_timeout)应答该事物的slave达到参数(rpl_semi_sync_master_wait_for_slave_count)值,master就会一直保持半同步。
也就是说,直到事务提交超时前,master都不会根据检测到的slave数量变更复制模式。
如果该值为OFF:
master会立即转为异步复制(Rpl_semi_sync_master_status=OFF)。
也就是说,只要master检测到的slave数量低于count参数的设定,便立即变更复制模式。
off的话, 如果master根据检测slave数量自行降为异步, 那么开始事务的时候就不用等超时(直接异步了,事务不用等待)。 如果是on的话,master会超时后再降为异步,事务会等待。
但是询问发现,生产环境都是ON,且默认值就是ON,为什么呢?这个我还不知道。
【8.0文档】
Controls whether the master waits for the timeout period configured by rpl_semi_sync_master_timeout to expire, even if the slave count drops to less than the number of slaves configured by rpl_semi_sync_master_wait_for_slave_count during the timeout period.
When the value of rpl_semi_sync_master_wait_no_slave is ON (the default), it is permissible for the slave count to drop to less than rpl_semi_sync_master_wait_for_slave_count during the timeout period. As long as enough slaves acknowledge the transaction before the timeout period expires, semisynchronous replication continues.
When the value of rpl_semi_sync_master_wait_no_slave is OFF, if the slave count drops to less than the number configured in rpl_semi_sync_master_wait_for_slave_count at any time during the timeout period configured by rpl_semi_sync_master_timeout, the master reverts to normal replication.
This variable is available only if the master-side semisynchronous replication plugin is installed.
| rpl_semi_sync_master_wait_point | AFTER_SYNC |
#5.7默认AFTER_SYNC,在得到slave的应答后再commit,可选值AFTER_COMMIT。
| rpl_semi_sync_slave_enabled | OFF |
#(从库)是否启动半同步
| rpl_semi_sync_slave_trace_level | 32 |
| sync_binlog | 1 |
| sync_frm | ON |
| sync_master_info | 10000 |
| sync_relay_log | 10000 |
| sync_relay_log_info | 10000 |
4.维护
从库断开后的重连维护:
start slave io_thread;
show slave status \G #查看 Retrieved_Gtid_Set、Executed_Gtid_Set,前者应该接收到master的gtid,后者没有
start slave sql_thread;
show slave status \G #查看 Retrieved_Gtid_Set、Executed_Gtid_Set,此时二者相同,追到master的GTID。
set rpl_semi_sync_slave_enabled = 1; #开启半同步
stop io_thread;
start io_thread;
MySQL增强半同步的搭建实验,和一些参数的个人理解
标签:运行 文件的 das example like io_thread 实例 查看 ESS