MySQL增强半同步几个重要参数搭配的测试
Hostname | IP/Port | Identity | OS Version | MySQL Version | GTID Mode | Binlog Format | Semi-Sync status |
zlm2 | 192.168.1.101/3306 | master | CentOS 7.0 | 5.7.21 | on | row | on |
zlm3 | 192.168.1.102/3306 | slave1 | CentOS 7.0 | 5.7.21 | on | row | on |
zlm4 | 192.168.1.103/3306 | slave2 | CentOS 7.0 | 5.7.21 | on | row | on |
//Master
(zlm@192.168.1.101 )[(none)]>show variables like 'rpl_semi%';
+-------------------------------------------+------------+
| Variable_name | Value |
+-------------------------------------------+------------+
| rpl_semi_sync_master_enabled | OFF |
| rpl_semi_sync_master_timeout | |
| rpl_semi_sync_master_trace_level | |
| rpl_semi_sync_master_wait_for_slave_count | |
| rpl_semi_sync_master_wait_no_slave | ON |
| rpl_semi_sync_master_wait_point | AFTER_SYNC |
+-------------------------------------------+------------+
rows in set (0.00 sec) //rpl_semi_sync_master_enabled --Specify whether to use the feature of semi-sync(master side,default "off").
//rpl_semi_sync_master_timeout --Specify the threshold of timeout between master and slave(default value is "10000" means 10s).
//rpl_semi_sync_master_trace_level --Specify the debug trace level on master(default "32",others "1","16","64").
//rpl_semi_sync_master_wait_for_slave_count --Specify how many slaves the master should wait when timeout happens(default "1").
//rpl_semi_sync_master_wait_no_slave --Specify whether the master switches to normal replication(default "on").When setting "on",it permits the amount of slave can be less than the value of "rpl_semi_sync_master_wait_for_slave_count" you specified and prevents it becoming normal replication.
//rpl_semi_sync_master_wait_point --Specify the ACK mode(default "after-sync").It's the most important variable of semi-sync. //Slave1
(zlm@192.168.1.102 )[(none)]>show variables like 'rpl_semi%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled | OFF |
| rpl_semi_sync_slave_trace_level | |
+---------------------------------+-------+
rows in set (0.00 sec) //There're only two variables after install the rpl_semi_sync_slave plugin.
//rpl_semi_sync_slave_enabled -- Specify whether use the feature of semi-sync(slave side,default "off").
//rpl_semi_sync_slave_trace_level -- Specify the debug trace level on slave(default "32").
//Master
(zlm@192.168.1.101 )[(none)]>set rpl_semi_sync_master_enabled=on;
ERROR (HY000): Variable 'rpl_semi_sync_master_enabled' is a GLOBAL variable and should be set with SET GLOBAL
(zlm@192.168.1.101 )[(none)]>set global rpl_semi_sync_master_enabled=on;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.101 )[(none)]>show variables like 'rpl_semi_sync_master_enabled';
+------------------------------+-------+
| Variable_name | Value |
+------------------------------+-------+
| rpl_semi_sync_master_enabled | ON |
+------------------------------+-------+
row in set (0.01 sec) //Slave1
(zlm@192.168.1.102 )[(none)]>set @@global.rpl_semi_sync_slave_enabled=on;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.102 )[(none)]>show variables like 'rpl_semi_sync%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled | ON |
| rpl_semi_sync_slave_trace_level | |
+---------------------------------+-------+
rows in set (0.00 sec) //Slave2
(zlm@192.168.1.103 )[(none)]>set @@global.rpl_semi_sync_slave_enabled=on;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.103 )[(none)]>show variables like 'rpl_semi_sync%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| rpl_semi_sync_slave_enabled | ON |
| rpl_semi_sync_slave_trace_level | |
+---------------------------------+-------+
rows in set (0.01 sec) //Master
(zlm@192.168.1.101 )[(none)]>show global status like 'Rpl_semi_sync_master_clients';
+------------------------------+-------+
| Variable_name | Value |
+------------------------------+-------+
| Rpl_semi_sync_master_clients | | //It means there're two slaves using semi-sync replicaiton follow master now.
+------------------------------+-------+
row in set (0.00 sec)
[root@zlm2 :: ~/sysbench-1.0/src/lua]
#sysbench oltp_insert.lua --mysql-host=192.168.1.101 --mysql-port= --mysql-user=zlm --mysql-password=zlmzlm --mysql-db=sysbench --tables= --table-size= --mysql-storage-engine=innodb prepare
sysbench 1.0. (using bundled LuaJIT 2.1.-beta2) Creating table 'sbtest1'...
Inserting records into 'sbtest1'
Creating a secondary index on 'sbtest1'...
Creating table 'sbtest2'...
Inserting records into 'sbtest2'
Creating a secondary index on 'sbtest2'...
Creating table 'sbtest3'...
Inserting records into 'sbtest3'
Creating a secondary index on 'sbtest3'...
Creating table 'sbtest4'...
Inserting records into 'sbtest4'
Creating a secondary index on 'sbtest4'...
Creating table 'sbtest5'...
Inserting records into 'sbtest5'
Creating a secondary index on 'sbtest5'... [root@zlm2 :: ~/sysbench-1.0/src/lua]
#sysbench oltp_insert.lua --mysql-host=192.168.1.101 --mysql-port= --mysql-user=zlm --mysql-password=zlmzlm --mysql-db=sysbench --threads= --time= --report-interval= --rand-type=uniform run
sysbench 1.0. (using bundled LuaJIT 2.1.-beta2) Running the test with following options:
Number of threads:
Report intermediate results every second(s)
Initializing random number generator from current time Initializing worker threads... Threads started! [ 30s ] thds: tps: 931.95 qps: 931.95 (r/w/o: 0.00/931.95/0.00) lat (ms,%): 6.09 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: tps: 971.62 qps: 971.62 (r/w/o: 0.00/971.62/0.00) lat (ms,%): 5.18 err/s: 0.00 reconn/s: 0.00
[ 90s ] thds: tps: 949.33 qps: 949.33 (r/w/o: 0.00/949.33/0.00) lat (ms,%): 4.41 err/s: 0.00 reconn/s: 0.00
(zlm@192.168.1.101 )[(none)]>show global status like 'Rpl_semi_sync%';
+--------------------------------------------+------------+
| Variable_name | Value |
+--------------------------------------------+------------+
| Rpl_semi_sync_master_clients | |
| Rpl_semi_sync_master_net_avg_wait_time | |
| Rpl_semi_sync_master_net_wait_time | |
| Rpl_semi_sync_master_net_waits | |
| Rpl_semi_sync_master_no_times | |
| Rpl_semi_sync_master_no_tx | |
| Rpl_semi_sync_master_status | ON |
| Rpl_semi_sync_master_timefunc_failures | |
| Rpl_semi_sync_master_tx_avg_wait_time | |
| Rpl_semi_sync_master_tx_wait_time | |
| Rpl_semi_sync_master_tx_waits | |
| Rpl_semi_sync_master_wait_pos_backtraverse | |
| Rpl_semi_sync_master_wait_sessions | |
| Rpl_semi_sync_master_yes_tx | |
+--------------------------------------------+------------+
rows in set (0.00 sec)
(zlm@192.168.1.101 )[(none)]>set @@global.rpl_semi_sync_master_timeout=;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.101 )[(none)]>show global variables like 'rpl_semi_sync_master_timeout';
+------------------------------+-------+
| Variable_name | Value |
+------------------------------+-------+
| rpl_semi_sync_master_timeout | |
+------------------------------+-------+
row in set (0.00 sec)
(zlm@192.168.1.102 )[(none)]>system date
Mon Jul :: CEST
(zlm@192.168.1.102 )[(none)]>stop slave; //The stopping time was 11:20:40 around.
Query OK, rows affected (0.84 sec)
(zlm@192.168.1.101 )[(none)]>show global status like 'Rpl_semi_sync%';
+--------------------------------------------+------------+
| Variable_name | Value |
+--------------------------------------------+------------+
| Rpl_semi_sync_master_clients | | //The amount of client turned into "1".
| Rpl_semi_sync_master_net_avg_wait_time | |
| Rpl_semi_sync_master_net_wait_time | |
| Rpl_semi_sync_master_net_waits | |
| Rpl_semi_sync_master_no_times | |
| Rpl_semi_sync_master_no_tx | |
| Rpl_semi_sync_master_status | ON | //Although the amount of client has been less than "slave_count" but it still work in semi-sync mode.
| Rpl_semi_sync_master_timefunc_failures | |
| Rpl_semi_sync_master_tx_avg_wait_time | |
| Rpl_semi_sync_master_tx_wait_time | |
| Rpl_semi_sync_master_tx_waits | |
| Rpl_semi_sync_master_wait_pos_backtraverse | |
| Rpl_semi_sync_master_wait_sessions | |
| Rpl_semi_sync_master_yes_tx | |
+--------------------------------------------+------------+
rows in set (0.00 sec) --16T11::39.628398+: [ERROR] mysqld: Got an error reading communication packets //It's the time I stopped the slave on slave1.
--16T11::40.355498+: [ERROR] Semi-sync master failed on net_flush() before waiting for slave reply
--16T11::40.355532+: [Note] Stop semi-sync binlog_dump to slave (server_id: )
--16T11::41.358003+: [Note] Aborted connection to db: 'unconnected' user: 'repl' host: 'zlm3' (Found net error)
--16T11::43.367327+: [Note] InnoDB: page_cleaner: 1000ms intended loop took 6128ms. The settings might not be optimal. (flushed= and evicted=, during the time.)
--16T11::59.683904+: [Note] InnoDB: page_cleaner: 1000ms intended loop took 15315ms. The settings might not be optimal. (flushed= and evicted=, during the time.)
--16T11::05.709621+: [Note] InnoDB: page_cleaner: 1000ms intended loop took 5025ms. The settings might not be optimal. (flushed= and evicted=, during the time.)
--16T11::40.353597+: [Warning] Timeout waiting for reply of binlog (file: mysql-bin., pos: ), semi-sync up to file mysql-bin., position .
--16T11::40.353630+: [Note] Semi-sync replication switched OFF. //Until the timeout was accumulated to 60s(11:21:40),the semi-sync mode reverts "OFF" what means the master work as asynchronous replication. (zlm@192.168.1.101 )[(none)]>show global status like 'Rpl_semi_sync%';
+--------------------------------------------+------------+
| Variable_name | Value |
+--------------------------------------------+------------+
| Rpl_semi_sync_master_clients | |
| Rpl_semi_sync_master_net_avg_wait_time | |
| Rpl_semi_sync_master_net_wait_time | |
| Rpl_semi_sync_master_net_waits | |
| Rpl_semi_sync_master_no_times | |
| Rpl_semi_sync_master_no_tx | |
| Rpl_semi_sync_master_status | OFF | //Now the status became "OFF".
| Rpl_semi_sync_master_timefunc_failures | |
| Rpl_semi_sync_master_tx_avg_wait_time | |
| Rpl_semi_sync_master_tx_wait_time | |
| Rpl_semi_sync_master_tx_waits | |
| Rpl_semi_sync_master_wait_pos_backtraverse | |
| Rpl_semi_sync_master_wait_sessions | |
| Rpl_semi_sync_master_yes_tx | |
+--------------------------------------------+------------+
rows in set (0.00 sec)
(zlm@192.168.1.101 )[(none)]>set @@global.rpl_semi_sync_master_wait_no_slave=off;
Query OK, rows affected (0.00 sec) (zlm@192.168.1.101 )[(none)]>show global variables like 'rpl_semi%';
+-------------------------------------------+------------+
| Variable_name | Value |
+-------------------------------------------+------------+
| rpl_semi_sync_master_enabled | ON |
| rpl_semi_sync_master_timeout | |
| rpl_semi_sync_master_trace_level | |
| rpl_semi_sync_master_wait_for_slave_count | |
| rpl_semi_sync_master_wait_no_slave | OFF |
| rpl_semi_sync_master_wait_point | AFTER_SYNC |
+-------------------------------------------+------------+
rows in set (0.00 sec)
//Slave
(zlm@192.168.1.102 )[(none)]>start slave;
Query OK, rows affected (0.01 sec) //Error log of master
--16T11::22.727473+: [Note] Start binlog_dump to master_thread_id() slave_server(), pos(, )
--16T11::31.005135+: [Note] InnoDB: page_cleaner: 1000ms intended loop took 8431ms. The settings might not be optimal. (flushed= and evicted=, during the time.)
--16T11::31.838932+: [Note] Start semi-sync binlog_dump to slave (server_id: ), pos(, )
--16T11::50.117239+: [Note] InnoDB: page_cleaner: 1000ms intended loop took 6667ms. The settings might not be optimal. (flushed= and evicted=, during the time.)
--16T11::59.977585+: [Note] Semi-sync replication switched ON at (mysql-bin., )
(zlm@192.168.1.102 )[(none)]>system date
Mon Jul :: CEST
(zlm@192.168.1.102 )[(none)]>stop slave; //The stopping time was 11:35:58 around.
Query OK, rows affected (1.60 sec)
(zlm@192.168.1.101 )[(none)]>show global status like 'Rpl_semi_sync%';
+--------------------------------------------+------------+
| Variable_name | Value |
+--------------------------------------------+------------+
| Rpl_semi_sync_master_clients | |
| Rpl_semi_sync_master_net_avg_wait_time | |
| Rpl_semi_sync_master_net_wait_time | |
| Rpl_semi_sync_master_net_waits | |
| Rpl_semi_sync_master_no_times | |
| Rpl_semi_sync_master_no_tx | |
| Rpl_semi_sync_master_status | ON |
| Rpl_semi_sync_master_timefunc_failures | |
| Rpl_semi_sync_master_tx_avg_wait_time | |
| Rpl_semi_sync_master_tx_wait_time | |
| Rpl_semi_sync_master_tx_waits | |
| Rpl_semi_sync_master_wait_pos_backtraverse | |
| Rpl_semi_sync_master_wait_sessions | |
| Rpl_semi_sync_master_yes_tx | |
+--------------------------------------------+------------+
rows in set (0.00 sec) --16T11::58.920988+: [ERROR] mysqld: Got an error reading communication packets
--16T11::00.321218+: [Note] InnoDB: page_cleaner: 1000ms intended loop took 14988ms. The settings might not be optimal. (flushed= and evicted=, during the time.)
--16T11::11.150976+: [Note] InnoDB: page_cleaner: 1000ms intended loop took 8718ms. The settings might not be optimal. (flushed= and evicted=, during the time.)
--16T11::28.973672+: [Note] Stop semi-sync binlog_dump to slave (server_id: )
--16T11::29.012288+: [Note] Semi-sync replication switched OFF. //The master didn't wait the timeout occur and revert to aynchronous replication directly within about merely 30s. (zlm@192.168.1.101 )[(none)]>show global status like 'Rpl_semi_sync%';
+--------------------------------------------+------------+
| Variable_name | Value |
+--------------------------------------------+------------+
| Rpl_semi_sync_master_clients | |
| Rpl_semi_sync_master_net_avg_wait_time | |
| Rpl_semi_sync_master_net_wait_time | |
| Rpl_semi_sync_master_net_waits | |
| Rpl_semi_sync_master_no_times | |
| Rpl_semi_sync_master_no_tx | |
| Rpl_semi_sync_master_status | OFF |
| Rpl_semi_sync_master_timefunc_failures | |
| Rpl_semi_sync_master_tx_avg_wait_time | |
| Rpl_semi_sync_master_tx_wait_time | |
| Rpl_semi_sync_master_tx_waits | |
| Rpl_semi_sync_master_wait_pos_backtraverse | |
| Rpl_semi_sync_master_wait_sessions | |
| Rpl_semi_sync_master_yes_tx | |
+--------------------------------------------+------------+
rows in set (0.00 sec)
- The behavior of semi-sync replication depends on the variables that you specified.
- If the value of "rpl_semi_sync_master_wait_no_slave" is "on",the status of semi-sync won't change until it reaches the value of timeout,even though the amount of slaves are less than it in "rpl_semi_sync_master_slave_count".
- If the value of "rpl_semi_sync_master_wait_no_slave" is "off",master won't wait for timeout before it reverts to normal replication when slave decreases to less than the value above.
- In order to observe the result conveniently,I increase the value of "rpl_semi_sync_master_timeout" to 60s.
- In most high consistent scenarios,the value can be tremendous enough to avoid degenerating to asynchronous replication.
- If the degeneration is due to network failure such as instant glitch.The semi-sync status will be ok after the network becomes normal.
- I'm afraid the best practice is to set "rpl_semi_sync_master_wait_no_slave" to "on" and the "rpl_semi_sync_master_timeout" to a comparative value.
MySQL增强半同步几个重要参数搭配的测试的更多相关文章
- Bullet:MySQL增强半同步参数rpl_semi_sync_master_wait_point值AFTER_SYNC和AFTER_COMMIT的对比实验
MySQL 5.7.22启用增强半同步复制 MySQL对该参数值的描述 Semisync can wait for slave ACKs at one of two points, AFTER_SYN ...
- MySQL增强半同步的搭建实验,和一些参数的个人理解
关于参数理解,已补充实验,可以查看: rpl_semi_sync_master_wait_no_slave 参数研究实验 环境信息 role ip port hostname master 192.1 ...
- MySQL 5.7的复制架构,在有异步复制、半同步、增强半同步、MGR等的生产中,该如何选择?
一.生产环境中: 几种复制场景都有存在的价值.下面分别描述一下: 从成熟度上来选择,推荐:异步复制(GTID+ROW) 从数据安全及更高性能上选择:增强半同步 (在这个结构下也可以把innodb_fl ...
- (MHA+MYSQL-5.7增强半同步)高可用架构设计与实现
架构使用mysql5.7版本基于GTD增强半同步并行复制配置 reploication 一主两从,使用MHA套件管理整个复制架构,实现故障自动切换高可用 优势: ...
- PostgreSQL的同步级别与MySQL的半同步after_sync比较
MySQL的半同步中通过binlog进行流复制,同步级别和PostgreSQL对比可以发现: PostgreSQL MySQL off local ...
- MySQL的半同步是什么?
前言 年后在进行腾讯二面的时候,写完算法的后问的第一个问题就是,MySQL的半同步是什么?我当时直接懵了,我以为是问的MySQL的两阶段提交的问题呢?结果确认了一下后不是两阶段提交,然后面试官看我连问 ...
- mysql的半同步复制
1. binlog dump线程何时向从库发送binlog mysql在server层进行了组提交之后,为了提高并行度,将提交阶段分为了 flush sync commit三个阶段,根据sync_bi ...
- MySQL 5.7 新特性之增强半同步复制
1. 背景介绍 半同步复制 普通的replication,即mysql的异步复制,依靠mysql二进制日志也即binary log进行数据复制.比如两台机器,一台主机(master),另外一台是从机( ...
- MySQL主从复制半同步复制原理及搭建
在MySQL5.5之前的版本中,MySQL的复制是异步复制,主库和从库的数据之间存在一定的延迟,比如网络故障等各种原因,这样子容易存在隐患就是:当在主库写入一个事务成功后并提交了,但是由于从库延迟没有 ...
随机推荐
- MSD_radix_sort
一.这次是在上一次尝试基础上进行的,预期是达到上次性能的9倍. MSD的基本手法就是不断切片.每一步都是把整体数据切割成256片,如上图所示,实际情况切片未必均匀,有的slice内可能一个元素也没有. ...
- vue.js--基础 v-bind绑定属性使用
背景:因为10月要休产假了,8月的时间我工作很少,因为最开始做平台我一直做的是后端,前端很少接触,所以现在有时间,就学习前端基础,前端使用的vue.js+element,因为没有基础,所以下了一个视频 ...
- 字符串处理(POJ1782)
题目链接:http://poj.org/problem?id=1782 解题报告: #include <iostream> #include <cstdio> #include ...
- nbu8.1配置群集SQL Server实例的备份
1.About SQL Server high availability (HA) environments SQL Server Intelligent policies support the f ...
- 2017.10.21 Java中的数据源与连接池技术
1.数据源技术就是预先建立好一定的数量的数据库连接,并将这些连接保存在连接池中,有连接池负责对这些数据库连接管理,当访问数据库时,只需要从连接池中取出有空闲状态的数据库连接:当程序访问数据库结束时,释 ...
- 安装juicer
由于我第一次安装 JUICER时遇到了很多问题,现在把这些问题都记录下来,给同样第一次安装使用的同学一点借鉴. 前面已经安装了Torch3和Tracter,这都是为安装Juicer做的准备,现在安装J ...
- C#中索引器的实现过程,是否只能根据数字进行索引?
描述一下C#中索引器的实现过程,是否只能根据数字进行索引? 答:索引器是一种特殊的类成员,它能够让对象以类似数组的方式来存取, 使程序看起来更为直观,更容易编写,可以用任意类型.
- input的类型为number,限制输入的数字位数
<input type="text" maxlength="5" /> 效果ok,当 <input type="number& ...
- 当Java遇见了Html--Jsp九大内置对象篇
jsp内置对象对象是web容器创建的一组对象,不使用new关键词久可以使用的内置对象. 九大内置对象包括以下: out --JspWriter request --ServletRequest rep ...
- ES6初识- Class
{ //基本定义和生成实例 class Parent{ //构造函数 constructor(name='lisi'){ this.name=name; } //属性get,set get longN ...