Mysql的log_slave_updates参数说明

[attach]1267[/attach] 架构说明:最近部署了MySQL的集群环境,详细情况如上图所示MMA和MMB为主主复制,MMA和MSA为主从复制;在测试的过程中发现了以下问题
    []MMA和MMB的主主复制没有问题(从MMA写入数据能同步到MMB,从MMB写入数据也能够同步到MMA);[/][]MMA和MSA主从复制也没有问题,当从MMA写入的时候,数据可以写入到MSA;[/][]但是当从MMB写入的时候,数据就不能写入到MSA;[/]
  问题原因是:MMA Mysql参数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.
    []MMA从MMB同步数据过来的时候,log_slave_updates参数用来控制MMA是否把所有的操作写入到binary log,默认的情况下mysql是关闭的;[/]
    []MSA数据的更新需要通过读取到MMA的binary log才能进行更新,当从MMB写入数据的时候MMA是没有写binary log的,所以MRA也就没有更新操作。[/]
  问题的解决方法: [attach]1268[/attach] log_slave_updates:默认值为OFF;    Dynamic Variable:NO    处理方法:修改配置文件my.cnf,在mysql数据库MMA的配置文件[mysqld]下增加一行log_slave_updates=1,然后暂停所有数据库的同步> stop slave;  最后重启MMA数据库让参数生效,打开所有数据库的同步> start slave;   总结: 设置完该参数后,数据库的架构MMA和MMB为主主同步,MSA通过MMA进行主从同步就完善了! 应用的写操作中MMB上面进行,读操作中MSA上面进行(如果读操作很多的话,可以在MMA上面架设多台只读数据库),当MMB发生故障后,系统的写操作自动迁移到MMA上面。这种架构基本可以保证大部分公司的应用需求。  

0 个评论

要回复文章请先登录注册