MySQL的简单复制问题:“显示主状态”产生“空集”?

我一直在按照这些说明忠实地设置MySQL主复制(在Debian 6.0.1上): http : //www.neocodesoftware.com/replication/

我还有:

mysql > show master status; 

但不幸的是产生了以下结果,而不是任何有用的结果:

 Empty set (0.00 sec) 

/var/log/mysql.err的错误日志只是一个空文件,所以没有给我任何线索。

有任何想法吗?

这是我在/etc/mysql/my.cnf在一台服务器(适当地修改了其他服务器):

 server-id = 1 replicate-same-server-id = 0 auto-increment-increment = 2 auto-increment-offset = 1 master-host = 10.0.0.3 master-user = <myusername> master-password = <mypass> master-connect-retry = 60 replicate-do-db = fruit log-bin = /var/log/mysql-replication.log binlog-do-db = fruit 

我已经build立了用户,可以使用上面的用户名/密码/ ipaddress从服务器A上的MySQL连接到服务器B上的数据库

有趣的是,我有我的电脑与二进制日志未启用MySQL运行。 我做了以下几点:

 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 19 Server version: 5.5.12 MySQL Community Server (GPL) Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show master status; Empty set (0.00 sec) mysql> show binary logs; ERROR 1381 (HY000): You are not using binary logging mysql> 

如图所示,由于MySQL为SHOW MASTER STATUS显示“Empty Set” 因为二进制日志logging没有启用。 鉴于我的configuration,这是显而易见的。

你应该做的第一件事是确保错误日志有一个特定的文件夹

 [mysqld] log-error=/var/log/mysql/mysql.err log-bin = /var/log/mysql/mysql-replication.log 

然后运行以下内容:

 service mysql stop mkdir /var/log/mysql chown -R mysql:mysql /var/log/mysql service mysql start 

然后在mysql客户端运行这些SQL命令

 SHOW MASTER STATUS; SHOW BINARY LOGS; 

如果你得到了和以前一样的输出,那么MySQL不能把二进制日志写到指定的文件夹。 你的困境变成了为什么MySQL不能写入/ var / log。

这不是一个完整的答案,但我希望这有助于。

如果Mysql版本大于5.0,则my.cnf中的复制设置master-host,master-user,master-password和其他一些将被忽略。 使用CHANGE MASTER TO进行初始复制设置。

比较http://dev.mysql.com/doc/refman/5.1/en/replication-howto-slaveinit.html

您的log-bin设置不正确,所以MySQL无法写入二进制日志。 这不是一个文件名,它是一个部分文件名模式, MySQL将在其中预先加一个目录并附加一个序号和扩展名。 通常的设置是类似的

 log-bin=log-bin 

检查手册。