MySQL半同步安装以及参数
MySQL半同步安装以及参数
基于MySQL5.5
官档地址:
Semisynchronous Replication Administrative Interface
https://dev.mysql.com/doc/refman/5.5/en/replication-semisync-interface.html
控制半同步复制的系统参数
rpl_semi_sync_master_enabled
Controls whether semisynchronous replication is enabled on the master. To enable or disable the plugin, set this variable to 1 or 0, respectively. The default is 0 (off).
控制是否启用半同步复制
rpl_semi_sync_master_timeout
A value in milliseconds that controls how long the master waits on a commit for acknowledgment from a slave before timing out and reverting to asynchronous replication. The default value is 10000 (10 seconds).
等待从库提交并反馈的超时时间,超时则转向异步同步
rpl_semi_sync_slave_enabled
Similar to rpl_semi_sync_master_enabled, but controls the slave plugin.
类似于 rpl_semi_sync_master_enabled,但是用于控制 slave 的插件。
启用半同步复制监视的状态变量
Rpl_semi_sync_master_clients
The number of semisynchronous slaves.
半同步复制的 slave 的数量
Rpl_semi_sync_master_status
Whether semisynchronous replication currently is operational on the master. The value is 1 if the plugin has been enabled and a commit acknowledgment has occurred. It is 0 if the plugin is not enabled or the master has fallen back to asynchronous replication due to commit acknowledgment timeout.
半同步复制目前是否运行在主机上。如果已启用该插件,提交确认发生,值为 1。如果未启用该插件或 master 已经回落到异步复制导致提交确认超时,为 0。
Rpl_semi_sync_master_no_tx
The number of commits that were not acknowledged successfully by a slave.
提交但是没有反馈成功的slave的数量。
Rpl_semi_sync_master_yes_tx
The number of commits that were acknowledged successfully by a slave.
提交后反馈成功的slave的数量。
Rpl_semi_sync_slave_status
Whether semisynchronous replication currently is operational on the slave. This is 1 if the plugin has been enabled and the slave I/O thread is running, 0 otherwise.
是否同步复制目前是业务上的slave。如果已启用该插件,slave的 I/O 线程正在运行,是1 ,否则 0。
安装和配置
前提条件
1. MySQL 5.5 or higher must be installed.
2. The capability of installing plugins requires a MySQL server that supports dynamic loading. To verify this, check that the value of the have_dynamic_loading system variable is YES. Binary distributions should support dynamic loading.
3. Replication must already be working.
安装
1.设置主从库参数文件
[mysqld]
plugin_dir=/path/to/plugin/directory
主库:
INSTALL PLUGIN rpl_semi_sync_master SONAME 'semisync_master.so';
从库:
INSTALL PLUGIN rpl_semi_sync_slave SONAME 'semisync_slave.so';
查询安装情况
mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE '%semi%';
+----------------------+---------------+
| PLUGIN_NAME | PLUGIN_STATUS |
+----------------------+---------------+
| rpl_semi_sync_master | ACTIVE |
+----------------------+---------------+
安装完成后,半同步默认是关闭的,需要在主从库上面都开启,才能使用,只开启主或者从,都无法使用
mysql运行时,可以使用以下参数
主库:
SET GLOBAL rpl_semi_sync_master_enabled = {0|1}; #默认是0,1是启用,0是关闭
SET GLOBAL rpl_semi_sync_master_timeout = N; #单位milliseconds(毫秒),10000毫秒=10秒
从库:
SET GLOBAL rpl_semi_sync_slave_enabled = {0|1};
如果要在mysql运行时启用半同步,必须重启IO_THREAD,slave会重新连上master并且被注册为 semisynchronous slave
STOP SLAVE IO_THREAD;
START SLAVE IO_THREAD;
如果不重启的话,slave将会继续使用 异步复制
可以重启mysql时
配置my.cof参数
主库:
[mysqld]
rpl_semi_sync_master_enabled=1
rpl_semi_sync_master_timeout=1000 # 1 second
从库:
[mysqld]
rpl_semi_sync_slave_enabled=1
监控
mysql> SHOW VARIABLES LIKE 'rpl_semi_sync%';
mysql> SHOW STATUS LIKE 'Rpl_semi_sync%';
卸载
主库:
UNINSTALL PLUGIN rpl_semi_sync_master;
从库:
UNINSTALL PLUGIN rpl_semi_sync_slave;
MySQL半同步安装以及参数的更多相关文章
- centos7下mysql半同步复制原理安装测试详解
原理简介: 在MySQL5.5之前,MySQL的复制其实都是异步复制(见下图),主库和从库的数据之间存在一定的延迟,这样存在一个隐患:当在主库上写入一个事务并提交成功,而从库尚未得到主库推送的BinL ...
- 安装MySQL半同步复制
一.简介 从MySQL5.5开始,MySQL以插件的形式支持半同步复制.如何理解半同步呢?首先我们来看看异步,全同步的概念 异步复制(Asynchronous replication) MySQL默认 ...
- MySQL半同步复制
从MySQL5.5开始,MySQL以插件的形式支持半同步复制.如何理解半同步呢?首先我们来看看异步,全同步的概念 异步复制(Asynchronous replication) MySQL默认的复制即是 ...
- Mysql半同步复制模式说明及配置示例 - 运维小结
MySQL主从复制包括异步模式.半同步模式.GTID模式以及多源复制模式,默认是异步模式 (如之前详细介绍的mysql主从复制).所谓异步模式指的是MySQL 主服务器上I/O thread 线程将二 ...
- MySQL半同步复制(5.5之后引入)
半同步复制架构在主库提交一个事务后,commit完成即反馈客户端,无需等待推送binlog完成,如图: 半同步复制在主库完成一个事务后,需等待事务信息写入binlog日志并且至少有一个从库写入rela ...
- MySQL半同步复制搭建
默认情况下,MySQL 5.5/5.6/5.7和MariaDB 10.0/10.1的复制是异步的,异步复制可以提供最佳性能,主库把binlog日志发送给从库,这一动作就结束了,并不会验证从库是否接收完 ...
- (5.5)mysql高可用系列——MySQL半同步复制(实践)
关键词,mysql半同步复制 [0]实验环境 操作系统:CentOS linux 7.5 数据库版本:5.7.24 数据库架构:主从复制,主库用于生产,从库用于数据容灾和主库备机,采用默认传统的异步复 ...
- 14.6、mysql半同步插件的使用
1.半同步介绍: (1)从MySQL5.5开始,MySQL以插件的形式支持半同步复制.如何理解半同步呢?首先我们来看看异步,全同步的概念: 1)异步复制(Asynchronous replicatio ...
- mysql半同步复制问题排查
1.问题背景 默认情况下,线上的mysql复制都是异步复制,因此在极端情况下,主备切换时,会有一定的概率备库比主库数据少,因此切换后,我们会通过工具进行回滚回补,确保数据不丢失.半同步复制则 ...
随机推荐
- Python小数据池,代码块
今日内容一些小的干货 一. id is == 二. 代码块 三. 小数据池 四. 总结 python小数据池,代码块的最详细.深入剖析 一. id is == 二. 代码块 三. 小数据池 四. ...
- Let Encrypt延期(转自虞大胆的叽叽喳喳)
前几天发现我的 letsencrypt 通配符证书快过期了,想为这两张证书续期(renew). 首先运行命令查看我的所有证书: $ certbot-auto certificates 其中证书名 si ...
- JS--理解call、apply和bind
call.apply和bind call,apply是Function原型中的方法,它们的作用一样,区别在于传入参数的方式不同. call(thisArg, arg1, arg2...) 传入的参数不 ...
- 6.C# 释放非托管资源2
C# 释放非托管资源 C#中资源分为托管资源和非托管资源. 托管资源由垃圾回收器控制如何释放,不需要程序员过多的考虑(当然也程序员也可以自己释放). 非托管资源需要自己编写代码来释放.那么编写好的释放 ...
- vue项目中别个访问你的本地调试需要改东西
- MyBatis基础入门《三》Select查询集合
MyBatis基础入门<三>Select查询集合 描述: 代码新增了一个MybatisUtil工具类,查询数据库返回集合的时候,接收数据的三种方式.由于代码会渐渐增多,未涉及改动过的文件不 ...
- LeetCode110.平衡二叉树
一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过1. 示例 1: 给定二叉树 [3,9,20,null,null,15,7] 3 / \ 9 20 / \ 15 7 返回 true . 示例 ...
- SpringBoot的json序列化及时间序列化处理
使用场景:前台的多种时间格式存入后台,后台返回同时的时间格式到前台. 1 在config目录下配置jscksonConfig.java package com.test.domi.config; im ...
- 检索系统向量化计算query-doc相似度
def cal_sim2(A,B): ''' A :query [1,2] B: answers [[1,2],[3,5]] ''' need_norm=False A = np.array(A) B ...
- ASP.NET MVC Action返回结果类型【转】
ASP.NET MVC 目前一共提供了以下几种Action返回结果类型: 1.ActionResult(base) 2.ContentResult 3.EmptyResult 4.HttpUnauth ...