MySQL复制不更新slave

时间:2013-05-30 08:49:22

标签: mysql replication

尝试设置复制主 - 从。

掌握my.cnf

[mysqld]
bind-address = 0.0.0.0
port = 3306
server-id = 1
log-bin = /var/lib/mysql/mysql-bin
replicate-do-db = Test

Slave my.cnf

[mysqld]
log_output              = "FILE"
general_log_file        = /var/log/mysql/mysql.log
general_log             = 1
log_bin                 = /var/log/mysql/mysql-bin.log
server-id = 2
relay-log = /var/lib/mysql/mysql-relay-bin
relay-log-index = /var/lib/mysql/mysql-relay-bin.index
replicate-do-db = Test

SHOW SLAVE STATUS显示

Slave_IO_Running: Yes
Slave_SQL_Running: Yes

在中继日志中,我看到在master上执行的查询 Read_Master_Log_Pos也会更新。
但是在general_log_file中只出现

130530 14:50:25   523 Query     BEGIN
                  523 Query     COMMIT /* implicit, from Xid_log_event */

master上的更改未在slave上执行。我错过了什么?

1 个答案:

答案 0 :(得分:7)

这可能是由于以下选项:

replicate-do-db = Test

replicate-do-db选项可能非常棘手,有时可能behave in a manner that appears illogical

它只会复制默认((即USE选择的那个)数据库的语句。所以在你的例子中,这意味着要复制它:

use Test;

insert into myTable (column) values (value);

但这将被复制:

insert into Test.myTable (column) values (value);

请尝试使用replicate-wild-do-table选项:

replicate-wild-do-table=Test.%

希望你能获得一些快乐。