我们将两个MySQL数据库设置为主 - 主设置。我们在将数据从host1复制到host2时遇到了问题。我是数据库管理初学者。
错误日志在下面给出
host1:/$ cat /var/log/mysql/error.log
131115 13:51:06 [ERROR] Slave I/O: error reconnecting to master 'host1@host.company.com:3306' - retry-time: 60 retries: 86400, Error_code: 2003
错误不断重复。我已阅读本教程http://dev.mysql.com/doc/refman/5.5/en/replication-howto.html和此http://dev.mysql.com/doc/refman/5.0/en/can-not-connect-to-server.html以获取有关2003错误代码的帮助。
我从日志中验证了mysqld一直在运行,并且mysql服务器没有停机时间。
我对主机2的授权成功地将数据从host2复制到host1,如下所示
mysql> show grants;
-------------------------------+
| Grants for admin@localhost |
+--------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY PASSWORD '*53CB11958EE3FBA4B6C0CECA582369151A97FFA9' |
+-------------------------------------------------------------------------------------------
我在host1上的授权没有成功地从host1复制到host2,如下所示。
mysql> show grants;
+-------------------------------------------------------------------------------------------
| Grants for admin@localhost |
+-------------------------------------------------------------------------------------------
| GRANT USAGE ON *.* TO 'admin'@'localhost' IDENTIFIED BY PASSWORD '*53CB11958EE3FBA4B6C0CECA582369151A97FFA9' |
| GRANT ALL PRIVILEGES ON `MyDatabase`.* TO 'admin'@'localhost' |
+-------------------------------------------------------------------------------------------
主人身份: host2(正确复制到主机1)
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000235 | 12804977 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
host1(未正确复制到主机2)
mysql> show master status;
ERROR 1227 (42000): Access denied; you need (at least one of) the SUPER,REPLICATION CLIENT privilege(s) for this operation
我不太确定我做错了什么。我看了host2的my.cnf,它确实成功复制到主机有以下delta。 host1和host2都配置了不同的 server-id 参数。两个值均大于0.
server-id = 1
replicate-do-db = MyDatabase
innodb_buffer_pool_size = 2G
innodb_flush_method = O_DIRECT
read_buffer_size = 64M
sort_buffer_size = 64M
我的host1 my.cnf delta
server-id = 3
我不知道导致复制失败的原因。在发布这里之前我查看了这个SO链接的答案,但我不太清楚我需要做什么。
Mysql Master Master Replication, MySQL replication - Error connecting to master和 一直无法弄清楚我做错了什么。数据库上的两个主机都具有相同的用户名和密码。