mysql-5.6.x半同步复制配置
本文环境
主库:CentOS6.5 x64 192.168.0.65 mysql-5.6.29
备库:CentOS6.5 x64 192.168.0.66 mysql-5.6.29
接上文: mysql-5.6主从同步配置示例http://koumm.blog.51cto.com/703525/1764093
半同步复制的概念:
mysql5.5.x以上版本支持半同步复制,当Slave主机连接到Master时,能够查看其是否处于半同步复制的机制。当Master上开启半同步复制的功能时,至少应该有一个Slave开启其功能。此时,一个线程在Master上提交事务将受到阻塞,直到得知一个已开启半同步复制功能的Slave已收到此事务的所有事件,或等待超时。当一个事务的事件都已写入其relay-log中且已刷新到磁盘上,Slave才会告知已收到。如果等待超时,也就是Master没被告知已收到,此时Master会自动转换为异步复制的机制。当至少一个半同步的Slave赶上了,Master与其Slave自动转换为半同步复制的机制。半同步复制的功能要在Master,Slave都开启,半同步复制才会起作用;否则,只开启一边,它依然为异步复制。
一、半同步主服务器配置
1. mysql主服务器配置
(1) 在主服务器上加入半自动配置文件参数
# vi /etc/my.cnf
[mysqld]
log-bin = master-bin
log-bin-index = master-bin.index
binlog_format = mixed
server-id = 1
expire-logs-days = 7
rpl_semi_sync_master_enabled = 1
rpl_semi_sync_master_timeout = 1000 # 1 second
(2) 安装半同步配置插件
mysql> install plugin rpl_semi_sync_master soname 'semisync_master.so';
(3) 配置半同步插件
mysql> show global variables like '%rpl%';
+------------------------------------+-------+
| Variable_name | Value |
+------------------------------------+-------+
| rpl_recovery_rank | 0 |
| rpl_semi_sync_master_enabled | OFF |
| rpl_semi_sync_master_timeout | 10000 |
| rpl_semi_sync_master_trace_level | 32 |
| rpl_semi_sync_master_wait_no_slave | ON |
+------------------------------------+-------+
(4) 启用半同步插件
mysql> set global rpl_semi_sync_master_enabled =1;
(5) 配置超时
mysql> set rpl_semi_sync_master_timeout 1000;
mysql> show global status like 'rpl_semi%';
+--------------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients | 0 |
| Rpl_semi_sync_master_net_avg_wait_time | 0 |
| Rpl_semi_sync_master_net_wait_time | 0 |
| Rpl_semi_sync_master_net_waits | 0 |
| Rpl_semi_sync_master_no_times | 0 |
| Rpl_semi_sync_master_no_tx | 0 |
| Rpl_semi_sync_master_status | ON |
| Rpl_semi_sync_master_timefunc_failures | 0 |
| Rpl_semi_sync_master_tx_avg_wait_time | 0 |
| Rpl_semi_sync_master_tx_wait_time | 0 |
| Rpl_semi_sync_master_tx_waits | 0 |
| Rpl_semi_sync_master_wait_pos_backtraverse | 0 |
| Rpl_semi_sync_master_wait_sessions | 0 |
| Rpl_semi_sync_master_yes_tx | 0 |
+--------------------------------------------+-------+
14 rows in set (0.00 sec)
其它一些性能及相关参数:
2. 重启主服务器,使配置文件生效
# service mysqld restart
二、半同步从服务器配置
1. mysql从服务器配置
(1) 加入如下半同步配置。
# vi /etc/my.cnf
[mysqld]
log-bin = mysql-bin
binlog_format = mixed
server-id = 11
relay-log = slave-relay-bin
relay-log-index = slave-relay-bin.index
replicate_wild_ignore_table = mysql.%
rpl_semi_sync_slave_enabled = 1
(2) 安装半同步配置插件
mysql> install plugin rpl_semi_sync_slave soname 'semisync_slave.so';
Query OK, 0 rows affected (0.00 sec)
(3) 配置半同步插件
mysql> show global variables like '%rpl%';
+---------------------------------+----------+
| Variable_name | Value |
+---------------------------------+----------+
| rpl_semi_sync_slave_enabled | ON |
| rpl_semi_sync_slave_trace_level | 32 |
| rpl_stop_slave_timeout | 31536000 |
+---------------------------------+----------+
3 rows in set (0.00 sec)
(4) 启用半同步插件
mysql> set global rpl_semi_sync_master_enabled =1;
Query OK, 0 rows affected (0.00 sec)
mysql> show global variables like '%rpl%';
+---------------------------------+----------+
| Variable_name | Value |
+---------------------------------+----------+
| rpl_semi_sync_slave_enabled | ON |
| rpl_semi_sync_slave_trace_level | 32 |
| rpl_stop_slave_timeout | 31536000 |
+---------------------------------+----------+
3 rows in set (0.00 sec)
(5) 重启同步进程
mysql> stop slave;
Query OK, 0 rows affected (0.02 sec)
mysql> start slave;
Query OK, 0 rows affected (0.02 sec)
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.65
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: master-bin.000005
Read_Master_Log_Pos: 120
Relay_Log_File: testdb-relay-bin.000012
Relay_Log_Pos: 284
Relay_Master_Log_File: master-bin.000005
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table: mysql.%
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 120
Relay_Log_Space: 622
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: c8bb22a1-024e-11e6-a1e8-000c29225fa0
Master_Info_File: /usr/local/mysql-5.6.29-linux-glibc2.5-x86_64/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
2. 在主服务器上可以查看有1个从服务器连接过来
mysql> show global status like 'rpl_semi%';
+--------------------------------------------+-------+
| Variable_name | Value |
+--------------------------------------------+-------+
| Rpl_semi_sync_master_clients | 1 |
| Rpl_semi_sync_master_net_avg_wait_time | 0 |
| Rpl_semi_sync_master_net_wait_time | 0 |
| Rpl_semi_sync_master_net_waits | 0 |
| Rpl_semi_sync_master_no_times | 0 |
| Rpl_semi_sync_master_no_tx | 0 |
| Rpl_semi_sync_master_status | ON |
| Rpl_semi_sync_master_timefunc_failures | 0 |
| Rpl_semi_sync_master_tx_avg_wait_time | 0 |
| Rpl_semi_sync_master_tx_wait_time | 0 |
| Rpl_semi_sync_master_tx_waits | 0 |
| Rpl_semi_sync_master_wait_pos_backtraverse | 0 |
| Rpl_semi_sync_master_wait_sessions | 0 |
| Rpl_semi_sync_master_yes_tx | 0 |
+--------------------------------------------+-------+
14 rows in set (0.00 sec)
3. 重启从服务器,使配置文件生效
# service mysqld restart
本文出自 “koumm的linux技术博客” 博客,请务必保留此出处http://koumm.blog.51cto.com/703525/1764324
mysql-5.6.x半同步复制配置相关推荐
- Mysql主从复制的三种同步方式和半同步复制配置
目录 一.MySQL主从复制的三种同步模式 1.异步复制(Asynchronous replication) 2.全同步复制(Fully synchronous replication) 3.半同步复 ...
- MySQL多实例实现半同步复制
MySQL多实例实现半同步复制 MySQL多实例实现半同步复制 主库1:192.168.40.150 主库2:192.168.40.161 从库(2个MySQL实例):192.168.40.162 一 ...
- mysql 半同步 配置_Mysql 半同步复制配置
以下是配置和监控半同步复制: 1. 半同步复制功能以plugin的方式接入MySQL,需要在主库与从库两端同时开启半同步的支持,具体配置如下: On the master mysql> INST ...
- mysql的主从复制和半同步复制的配置
主从复制: 其实就是复制的是主服务器的二进制日志,从服务器然后再重新根据日志操作一遍,从而达到和主服务器里的数据一样,但是时间上会有延迟 mysql主从复制的基本原理 官方文档:https://dev ...
- MySQL半同步复制配置
前言: MySQL默认的主从复制采用的是异步模式,主库提交事务不需要确认是否已经传送到从库端,在主库发生宕机主备切换时,可能导致主库已经提交的事务在从库丢失的情况. 在MySQL 5.7通过插件支持了 ...
- percona mysql.cnf_Percona MySQL5.6 半同步复制
先配置普通的clone 两台服务器,一主一备 主服务器: 10.10.1.30 Slave: 10.10.1.200 修改每台机器的my.cnf文件,分别修改server_id 主服务器server_ ...
- mysql semisync 恢复_mysql半同步复制(semi_sync_replication)搭建及使用
mysql半同步复制(semi_sync_replication)搭建及使用 google为mysql开发了一个补丁一个基于半同步的补丁,应用与mysql5.0.回来mysql打上了该补丁,并在5.5 ...
- mysql5.6semi plugin_mysql5.6 semi replication 半同步复制配置(示例代码)
--###半同步配置 --1.插件位置 mysql> show variables like 'plugin_dir' -> ; +---------------+------------ ...
- mysql 5.5半同步复制_(5.5)mysql高可用系列——MySQL半同步复制(实践)
关键词,mysql半同步复制 [0]实验环境 操作系统:CentOS linux 7.5 数据库版本:5.7.24 数据库架构:主从复制,主库用于生产,从库用于数据容灾和主库备机,采用默认传统的异步复 ...
最新文章
- ACM ICPC 2011-2012 Northeastern European Regional Contest(NEERC)A ASCII Area
- 第一次react-native项目实践要点总结
- 此windows副本不是正版解决方法
- 安装Xen Server创建虚拟机
- php文件上传 github,PHP的cURL文件上传
- 《MySQL——redo log 与 binlog 写入机制》
- ajax——优化0126(增删改查:添加查看详情,返回结果类型为JSON型,在窗口显示)...
- html小游戏代码_厉害!84 行 JavaScript 代码实现塔式堆叠游戏
- 利用PROMPT_COMMAND记录每个用户执行命令的时间ip等信息。
- Android超级好看的动态登陆界面(附有详细代码)
- JS红宝书学习记录(一)
- origin2021绘图软件安装教程
- C语言·abs()函数
- JSON Views 基本用法
- Python:寻找回文素数
- 占坑:fullpage.js 在edge浏览器上上下移动鼠标(不滚动滚轮)会翻页的问题
- 前端学习-品优购实践
- 基于AD Event日志实时检测GPO后门
- Python合并有相同列的两个表格
- 22061周市场回顾