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

mysql 主主复制(双主复制)binlog-do-db

时间:2016-07-12 12:00:06      阅读:316      评论:0      收藏:0      [点我收藏+]

标签:

[root@DB ~]# grep "binlog-do-db" /etc/my.cnf 
binlog-do-db = test
[root@DB-S ~]# grep "binlog-do-db" /etc/my.cnf
binlog-do-db=test
binlog-do-db=test2

 

DB:
mysql> use test2;
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> 
DB-S:
mysql> show tables;
Empty set (0.04 sec)

mysql> CREATE TABLE `users` (
    ->   `id` int(11) NOT NULL AUTO_INCREMENT,
    ->   `name` varchar(20) NOT NULL,
    ->   `password` varchar(100) NOT NULL,
    ->   `address` varchar(200) DEFAULT NULL,
    ->   PRIMARY KEY (`id`),
    ->   UNIQUE KEY `name` (`name`)
    -> ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.06 sec)

mysql> show tables;
+-----------------+
| Tables_in_test2
+-----------------+
| users           |
+-----------------+
1 row in set (0.00 sec)
DB:
mysql> SHOW TABLES;
+-----------------+
| Tables_in_test2 |
+-----------------+
| users           |
+-----------------+
1 row in set (0.00 sec)
mysql> drop table users;
Query OK, 0 rows affected (0.00 sec)

DB-S:
mysql> show tables;
+-----------------+
| Tables_in_test2 |
+-----------------+
| users           |#因DB没指定test2,所以发生变化从库DB-S也不会变化
+-----------------+
1 row in set (0.00 sec)

  注意:my.cnf中binlog-do-db=库名,当这个库发生变化时,从库也会发生相应的变化,也就是说互为主从的两个库都要用这个参数指名相应的相做主从同步的库;并要主注如果要多个库时,同时也要有多个binlog-do-db参数

[root@DB-S ~]# grep "binlog-do-db" /etc/my.cnf
binlog-do-db=test
binlog-do-db=test2
[root@DB ~]# grep "binlog-do-db" /etc/my.cnf 
binlog-do-db = test
binlog-do-db = test2

 

mysql 主主复制(双主复制)binlog-do-db

标签:

原文地址:http://www.cnblogs.com/bass6/p/5662702.html

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