MySQL log_slave_updates 参数【转】
说明:最近部署了mysql的集群环境,详细如下M01和M02为主主复制,M01和R01为主从复制;在测试的过程中发现了以下问题:
1、M01和M02的主主复制是没有问题的(从M01写入数据能同步到M02,从M02写入数据能够同步到M01);
2、主从同步的时候,当从M01写入的时候,数据可以写入到R01;
3、当从M02写入的时候,数据就不能写入到R01;
问题的原因:log_slave_updates参数的状态为NO
mysql的官网说明如下:
|
Normally, a slave does not log to its own binary log any updates that are received from a master server. This option tells the slave to log the updates performed by its SQL thread to its own binary log. For this option to have any effect, the slave must also be started with the --log-bin option to enable binary logging. Prior to MySQL 5.5, the server would not start when using the --log-slave-updates option without also starting the server with the --log-bin option, and would fail with an error; in MySQL 5.5, only a warning is generated. (Bug #44663) --log-slave-updates is used when you want to chain replication servers. For example, you might want to set up replication servers using this arrangement: A -> B -> C Here, A serves as the master for the slave B, and B serves as the master for the slave C. For this to work, B must be both a master and a slave. You must start both A and B with --log-bin to enable binary logging, and B with the --log-slave-updates option so that updates received from A are logged by B to its binary log. |
a) M01同步从M02同步数据过来的时候,log_slave_updates参数用来控制M01是否把所有的操作写入到binary log,默认的情况下mysql是关闭的;
b) R01数据的更新需要通过读取到M01的binary log才能进行更新,这个时候M01是没有写binary log的,所以当数据从M02写入的时候,R01也就没有更新了。。
问题的解决方法:

log_slave_updates:默认值为OFF;
Dynamic Variable:NO
处理方法:修改/etc/my.cnf,增加一行log_slave_updates=1,重启数据库后就可以了;
总结:设置完该参数后,数据库的架构就可以设置成M01和M02为主主同步,R01通过M01进行主从同步;
应用的写操作中M02上面进行,读操作中R01上面进行(如果读操作很多的话,可以在M01上面架设多台只读数据库),当M02发生故障后,系统的写操作自动迁移到M01上面。这种架构基本可以保证大部分公司的应用需求;
官网说明: Normally, a slave does not log to its own binary log any updates that are received from a master server. This option tells the slave to log the updates performed by its SQL thread to its own binary log. For this option to have any effect, the slave must also be started with the --log-bin option to enable binary logging. Prior to MySQL 5.5, the server would not start when using the --log-slave-updates option without also starting the server with the --log-bin option, and would fail with an error; in MySQL 5.5, only a warning is generated. (Bug #) --log-slave-updates is used when you want to chain replication servers. For example, you might want to set up replication servers using this arrangement: A -> B -> C Here, A serves as the master for the slave B, and B serves as the master for the slave C. For this to work, B must be both a master and a slave. You must start both A and B with --log-bin to enable binary logging, and B with the --log-slave-updates option so that updates received from A are logged by B to its binary log. 通常情况,从服务器从主服务器接收到的更新不记入它的二进制日志。该选项告诉从服务器将其SQL线程执行的更新记入到从服务器自己的二进制日志。为了使该选项生效,还必须用--logs-bin选项启动从服务器以启用二进制日志。如果想要应用链式复制服务器,应使用--logs-slave-updates。例如,可能你想要这样设置: A -> B -> C 也就是说,A为从服务器B的主服务器,B为从服务器C的主服务器。为了能工作,B必须既为主服务器又为从服务器。你必须用--logs-bin启动A和B以启用二进制日志,并且用--logs-slave-updates选项启动B。
转自
主从同步设置的重要参数log_slave_updates_ITPUB博客 http://blog.itpub.net/12679300/viewspace-1319263/
Mysql log_slave_updates 参数 - 泽锦 - 博客园 https://www.cnblogs.com/zejin2008/p/4656251.html
MySQL log_slave_updates 参数【转】的更多相关文章
- Mysql log_slave_updates 参数
官网说明: Normally, a slave does not log to its own binary log any updates that are received from a mast ...
- MySql配置参数很全的Mysql配置参数说明
MySql配置参数 很全的Mysql配置参数说明 1. back_log 指定MySQL可能的连接数量.当MySQL主线程在很短的时间内得到非常多的连接请求,该参数就起作用,之后主线程花些时间(尽管很 ...
- 【查阅】mysql配置文件/参数文件重要参数笔录(my.cnf)
持续更新,积累自己对参数的理解 [1]my.cnf参数 [client]port = 3306socket = /mysql/data/3306/mysql.sockdefault-character ...
- 1201MySQL配置文件mysql.ini参数详解
转自http://www.cnblogs.com/feichexia/archive/2012/11/27/mysqlconf.html my.ini(Linux系统下是my.cnf),当mysql服 ...
- (转)MySQL配置文件mysql.ini参数详解、MySQL性能优化
本文转自:http://www.cr173.com/html/18331_1.html my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数 ...
- MySQL配置文件mysql.ini参数详解、MySQL性能优化
my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数. my.ini分为两块:Client Section和Server Section. ...
- MySQL配置文件mysql.ini参数详解
my.ini(Linux系统下是my.cnf),当mysql服务器启动时它会读取这个文件,设置相关的运行环境参数. my.ini分为两块:Client Section和Server Section. ...
- 在Linux最大打开文件数限制下 MySQL 对参数的调整
http://www.actionsky.com/docs/archives/78 2016年4月7日 周文雅 目录 1 起因 2 说明 3 MySQL调整参数的方式 3.1 计算 request ...
- skip-grant-tables:非常有用的mysql启动参数
skip-grant-tables:非常有用的mysql启动参数 介绍一个非常有用的mysql启动参数—— --skip-grant-tables.顾名思义,就是在启动mysql时不启动grant ...
随机推荐
- MyBatis-Plugins 的创建流程与执行顺序
一.插件的解析,所有插件都会被添加到 InterceptorChain 类中,用于后续处理 org.apache.ibatis.builder.xml.XMLConfigBuilder private ...
- wav音频文件格式解析【个人笔记】(自用)
1. WAV格式 wav是微软开发的一种音频文件格式,注意,wav文件格式是无损音频文件格式,相对于其他音频格式文件数据是没有经过压缩的,通常文件也相对比较大些.. 支持多种音频数字,取样频率和声道, ...
- java.io.OutputStream & java.io.FileOutputStream
java.io.OutputStream & java.io.FileOutputStream 1.Java.io.OutputStream(字节输出流) 字节输出流,这是一个抽象类,是表示输 ...
- Iterator迭代器
java.util.Iterator 迭代器iterator,是一个接口,不能够直接使用,需要使用Iterator接口的实现类对象,而获取实现类的的对象的方式为: Collection接口中有一个方法 ...
- 数据库范式:1NF,2NF,3NF,BCNF浅析
在设计与操作维护数据库时,最关键的问题就是要确保数据能够正确地分布到数据库的表中.使用正确的数据结构,不仅有助于对数据库进行相应的存取操作,还可以极大地简化应用程序中的其他内容(查询.窗体.报表.代码 ...
- 基于DSP的IS95正向业务信道模块设计
**定时20ms循环处理话音数据包*** *伪指令不占空间不影响执行速度,只是定义和描述但对汇编链接有重要指示作用 ********************************* .title & ...
- GCC编译器原理(二)------编译原理一:目标文件
一.目标文件 在 UNIX® 和 Linux® 中,任何事物都是文件.UNIX 和 Linux 编程实际上是编写处理各种文件的代码.系统由许多类型的文件组成,但目标文件具有一种特殊的设计,提供了灵活和 ...
- CRLF Injection漏洞的利用与实例分析
CRLF Injection很少遇见,这次被我逮住了.我看zone中(http://zone.wooyun.org/content/13323)还有一些同学对于这个漏洞不甚了解,甚至分不清它与CSRF ...
- mysql 约束和外键约束实例
1.约束保证数据的完整性和一致性. 2.约束分为表级约束和列级约束.(根据约束所针对的字段的数目的多少来决定) 列级约束:对一个数据列建立的约束 表级约束:对多个数据列建立的约束 列级约束即可以在列定 ...
- TF, IDF和TF-IDF
在相似文本的推荐中,可以用TF-IDF来衡量文章之间的相似性. 一.TF(Term Frequency) TF的含义很明显,就是词出现的频率. 公式: 在算文本相似性的时候,可以采用这个思路,如果两篇 ...