当前位置: 首页 > MySQL数据库

MySQL半同步SLAVE是什么

时间:2026-01-28 14:10:00

Mysql半同步SLAVE,类似于ORACLE安全模式的DATAGUARD(但不完全是);
为什么是半同步呢,因为MYSQL只保证“至少一个”SLAVE接收到日志后返回;
 虽然可能不会有太多的人去用这个东西(因为对网络的要求和机器的稳定性很高);但MYSQL还是补全了这一块的功能缺失

 A commit performed on the master side blocks before returning to the session
 that performed the transaction until at least one slave acknowledges that it has received
 and logged the events for the transaction.
 
 Semisynchronous replication is implemented through an optional plugin component.
 See Section 17.3.8, “Semisynchronous Replication”.
 http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html


The slave acknowledges receipt of a transaction's events only after the events have been written to its relay log and flushed to disk.
只有SLAVE接收到日志写入到RELAY-LOG,并刷新到磁盘才算同步成功;
If a timeout occurs without any slave having acknowledged the transaction, the master reverts to asynchronous replication
如果日志传输过程中发生超时现象;那么SLAVE将恢复到异步方式;
Semisynchronous replication must be enabled on both the master and slave sides. If semisynchronous replication is disabled on the master, or enabled on the master but on no slaves, the master uses asynchronous replication
半同步复制方式必须在MASTER和SLAVE同时打开;否则还是采用异步方式;
While the master is blocking (waiting for acknowledgment from a slave after having performed a commit), it does not return to the session that performed the transaction
在SLAVE接受到日志或超时之前,MASTER对SESSION的COMMIT请求不作返回响应;
The rolled-back transaction is logged even though it has no effect for transactional tables because the modifications to the nontransactional tables cannot be rolled back and must be sent to slaves.
滚回操作,即使对事务表没有影响,也同样会被记录到日志里,因为“修改”会非事务表是不可回滚的,所以必须也传输到SLAVE;
对于自动提交的语句; MASTER将被在每个语句结束后BLOCK住;

## 几个系统变量设置
rpl_semi_sync_master_enabled=1 # 打开MASTER支持semisynchronous replication
rpl_semi_sync_slave_enabled=1  # 打开Slave 支持semisynchronous replication
rpl_semi_sync_master_timeout   # 等待SLAVE超时时间;1MS,默认10000MS
rpl_semi_sync_master_wait_no_slave  # 在超时之前,如果SLAVE都DOWN了,是不是还继续等待直到超时;默认打开 ;

## 几个状态变量
Rpl_semi_sync_master_status   # 查看MASTER是否支持semisynchronous replication
Rpl_semi_sync_slave_status    # 查看SLAVE 是否支持semisynchronous replication
Rpl_semi_sync_master_clients  # 查看后面跟着几个semisynchronous slaves
Rpl_semi_sync_master_yes_tx   # 成功传输了多少个事务;
Rpl_semi_sync_master_no_tx    # 失败传输了多少个事务;


上一篇:MySQL数据库约束条件和自增长序列是什么
下一篇:MySQL REGEXP怎么使用
mysql
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素