说明:最近部署了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上面。这种架构基本可以保证大部分公司的应用需求;

来源:http://blog.itpub.net/12679300/viewspace-1319263/

主从同步设置的重要参数log_slave_updates的更多相关文章

  1. mycat数据库集群系列之mysql主从同步设置

    最近在梳理数据库集群的相关操作,现在花点时间整理一下关于mysql数据库集群的操作总结,恰好你又在看这一块,供一份参考.本次系列终结大概包括以下内容:多数据库安装.mycat部署安装.数据库之读写分离 ...

  2. MySQL 5.5主从同步设置教程

    先修改Master(10.1.123.197)的 my.cnf 配置 在 [mysqld] 中新增以下内容 log-bin=mysql-bin log-bin-index=mysql-bin.inde ...

  3. Mysql 主从同步原理简析

    在开始讲述原理的情况下,我们先来做个知识汇总,究竟什么是主从,为什么要搞主从,可以怎么实现主从,mysql主从同步的原理1.什么是主从其实主从这个概念非常简单主机就是我们平常主要用来读写的服务,我们称 ...

  4. centos 6.5 中设置mysql 5.1.73 主从同步配置过程

    本文章给大家介绍centos 6.5设置mysql主从同步过程记录,希望文章对各位会带来帮助.  涉及到的centos系统均为虚拟机,VM下安装的版本. 在centos 6.5上设置了mysql主从功 ...

  5. MySQL Replication 详解MySQL数据库设置主从同步的方法

    MySQL同步的流程大致如下:  1.主服务器(master)将变更事件(更新.删除.表结构改变等等)写入二进制日志(master log). 2.从服务器(slave)的IO线程从主服务器(binl ...

  6. 记录一下mariadb设置主从同步的过程[虚拟机测试]

    背景:因为工作的关系,需要找寻实时同步数据到另外系统的服务器的数据库上,查询下来,用mariadb进行跨服务器的同步数据动作,用主从同步比较多,也比较保险 也有使用shell脚本的,定时定候的执行my ...

  7. redis主从同步收到以下参数影响

      repl-ping-slave-period主从心跳ping的时间间隔.默认10 repl-timeout  从节点超时时间.默认60 repl-backlog-size  主节点保存操作日志的大 ...

  8. MySQL数据库设置主从同步

    MySQL主从同步的机制: MySQL同步的流程大致如下: 1.主服务器(master)将变更事件(更新.删除.表结构改变等等)写入二进制日志(master log). 2.从服务器(slave)的I ...

  9. mysql主从同步参数

    默认情况下,mysql的主从同步,会启用三个线程,两个IO线程和一个SQL线程.主从同步的主要文件就是binlog文件,从库从主库的binlog中读取数据,然后记录在从库自己的relaylog中,然后 ...

随机推荐

  1. Method for address space layout randomization in execute-in-place code

    The present application relates generally to laying out address space for execute-in-place code and, ...

  2. 转 openssl 建立服务器证书

    openssl 建立服务器证书 ##  1,建立目录和文件     set path=D:/openssl/bin     D:     cd D:/openssl/conf/     ren ope ...

  3. openGLES(三)

    着色器语言 ​ 着色器语言基于c/c++语言,但是还是有区别的,它不是面向对象 数据类型概述 ​ 内建的数据类型:浮点型(float).布尔型(bool).整形(int),矩阵(matrix)以及向量 ...

  4. vue实现多语言国际化(vue-i18n),结合element ui、vue-router、echarts以及joint等。

    老板说我们的项目要和国际接轨,于是乎,加上了多语言(vue-i18n).项目用到的UI框架是element ui ,后续echarts.joint等全都得加上多语言. 一.言归正传,i18n在vue项 ...

  5. css实现背景半透明文字不透明的效果

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. Hibernate3.5.4---java application的xml和annotation环境搭建(hibernate.cfg.xml配置文件说明,映射文件Student.hbm.xml说明

    http://blog.csdn.net/centre10/article/details/6050466 来自于:http://blog.csdn.net/centre10/article/deta ...

  7. Codeforces Round #426 (Div. 1) A.The Meaningless Game (二分+数学)

    题目链接: http://codeforces.com/problemset/problem/833/A 题意: 给你 \(a\) 和 \(b\),两个人初始化为 \(1\).两个人其中一方乘以 \( ...

  8. Perl——正则表达式(四) 查找替换s///

    转自http://blog.csdn.net/blog_abel/article/details/40589227 侵删 一. 介绍 使用 s/regex/replacement/modifiers  ...

  9. 【57.97%】【codeforces Round #380A】Interview with Oleg

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  10. [WASM] Read WebAssembly Memory from JavaScript

    We use an offset exporting function to get the address of a string in WebAssembly memory. We then cr ...