码迷,mamicode.com
首页 > 数据库 > 详细

mysql 双向同步

时间:2015-01-21 19:41:10      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

1.在两台mysql上创建用户,设置权限
  A上添加:
    grant replication slave,replication client,reload,super on *.* to sync_user@192.168.2.220 identified by 123456 with grant option;//用于B访问

  B上:
    grant replication slave,replication client,reload,super on *.* to sync_user@192.168.2.67 identified by 123456 with grant option;//用于A访问

执行  #flush privileges; 更新数据库使用户生效。

create database testsync;
use testsync;

create table t_user (
    id int primary key auto_increment,
    username varchar(20),
    age int
);

在[mysqld]下面添加以下配置
# test synchronized at 67
log-bin
server-id       = 1
master-host     =192.168.2.220
master-user     =sync_user
master-pass     =123456
master-port     =3306
master-connect-retry  =60
replicate-do-db        =testsync
replicate-do-db        =testsync2
replicate-ignore-db    =mysql,information_schema,performance_schema
auto_increment_increment=1

# test synchronized at 220
log-bin
server-id       = 2
master-host     =192.168.2.67
master-user     =sync_user
master-pass     =123456
master-port     =3306
master-connect-retry  =60
replicate-do-db        =testsync
replicate-do-db        =testsync2
replicate-ignore-db    =mysql,information_schema,performance_schema
auto_increment_increment=2


show processlist;

insert into t_user values(null, frank, 23);
select * from t_user;




server-id= 2
binlog-do-db=happy
binlog-do-db=ipaddressmgr
replicate-do-db=happy
replicate-do-db=ipaddressmgr

replicate-ignore-db=mysql,information_schema,performance_schema
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=2

 

 

log-bin
server-id= 1
binlog-do-db=happy
binlog-do-db=ipaddressmgr
replicate-do-db=happy
replicate-do-db=ipaddressmgr

replicate-ignore-db=mysql,information_schema,performance_schema
log-slave-updates
slave-skip-errors=all
sync_binlog=1
auto_increment_increment=2
auto_increment_offset=1

 

http://ylw6006.blog.51cto.com/470441/888523

mysql 双向同步

标签:

原文地址:http://www.cnblogs.com/hzm112567/p/4239192.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!