首页 > 数据库技术 > 详细

Mysql-主主同步

时间:2015-08-25 12:14:41      阅读:263      评论:0      收藏:0      [点我收藏+]

主主复制架构


主服:192.168.1.84

副主服:192.168.1.85


1.主服配置文件

在[mysqld]中添加

sync_binlog = 1

任何一个事物提交之后就立即写入到磁盘中的二进制文件

innodb_flush_log_at_trx_commit = 1

任何一个事物提交之后就立即写入到磁盘中的日子文件

2.副主服配置文件

在[mysqld]中添加

skip_slave_start = 1   或配置前执行  mysql > stop slave;

设定从服务器开启的时候,从服务器进程不开启,这样可以使我们有时间对从服务器进行配置

read_only = 1

设定从服务器只能进行读操作,不能进行写操作,保证数据同步(此时用super用户仍能进行写操作)

3.主服配置文件

在[mysqld]中添加

auto-increment-increment = 2

auto-increment-offset = 1

4.副主服配置文件

在[mysqld]中添加

log-bin = mysql-bin

auto-increment-increment = 2

auto-increment-offset = 2

重启主、副主服务器

5.主、从

mysql> grant replication client,replication slave on *.* to repl@‘192.168.1.84‘ identified by ‘123456‘;

mysql> grant replication client,replication slave on *.* to repl@‘192.168.1.85‘ identified by ‘123456‘;


双双配置主从为--主主同步(参考我的博客mysql-主从同步:http://7476463.blog.51cto.com/7466463/1685870


mysql> show slave status\G

如果出现如下两行,则说明工作正常:

Slave_IO_Running: Yes

Slave_SQL_Running: Yes


本文出自 “SQL” 博客,谢绝转载!

Mysql-主主同步

原文:http://7476463.blog.51cto.com/7466463/1687786

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!