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的复制是异步复制,主库和从库的数据之间存在一定的延迟,比如网络故障等各种原因,这样子容易存在隐患就是:当在主库写入一个事务成功后并提交了,但是由于从库延迟没有 ...
随机推荐
- 如何启用SAP C4C OData Event Notification
当我们在试图使用SAP C4C OData事件通知这个功能时,如果遇到下列提示消息,说明这个功能在business configuration里没有开启: The OData Event Notifi ...
- CRM WebClient UI里的文件是如何上传到Netweaver后台的
使用Chrome开发者工具调试CRM WebClient UI里附件上传的功能: 从本地选择一个文件,断点触发: 前端取得用户选中上传的文件名: Jerry.txt 点Attach按钮后,触发ABAP ...
- Python 看书的一些记录 运算符重载
1.类和模块有什么关系? (1)类是模块的一部分,是模块对象的属性. (2)类和模块都是命名空间,但是类是对于语法的.模块是对于文件的 (3)类支持多个实例,但是模块被导入时只有一个. 2.什么是抽象 ...
- 搭建FTP服务
(一)FTP服务概述 FTP服务概述:名称.功能.特点.端口 VSFTP:very secure FTP 端口:21 服务安装#yum install vsftpd lftp -y ##lftp ...
- js中this的运用
this 永远指向函数运行时所在的对象,而不是函数创建时所在的对象 匿名函数和不处于任何对象中的函数,This指向window call, apply, with指的This是谁就是谁. 普通函数调用 ...
- ES6初识-Proxy和Reflect
{ let obj={ time:'2017-03-11', name:'net', _r:123 }; let monitor=new Proxy(obj,{ // 拦截对象属性的读取 get( ...
- 关于discuz 不能全文搜索的问题
这个问题客服反馈很多次了,以为discuz 默认搜索只能搜标题,除非配置了sphinx全文搜索引擎. 但是之前比较老的员工说以前能用的,也就是discuz老版本. 今天突然想到是不是discuz纵横搜 ...
- BZOJ1901: Zju2112 Dynamic Rankings(整体二分 树状数组)
Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 9094 Solved: 3808[Submit][Status][Discuss] Descript ...
- datatable中reload和load的区别
ajax.reload()用于datatable表某个数据的变化而重新加载 ajax.url(url).load() 用于切换url时,datatable重新获取数据,加载.
- VMware中Ubuntu开机时停在启动界面,不进入X-window的解决办法
启动Ubuntu虚拟机时,停在这个画面不动: 试了若干次,都是这样.尝试了新建一个虚拟机然后把.vmdk文件拷过去启动,无法解决. 尝试重启,在这个界面按esc进入grub: 选择恢复模式 recov ...