我尝试在具有 2 个 VM 的 MI LAN 中进行主到主复制,配置:
#bind-address = 127.0.0.1
server-id = 2
auto_increment_increment = 2
auto_increment_offset = 2
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = blog
和:
#bind-address = 127.0.0.1
server-id = 1
auto_increment_increment = 1
auto_increment_offset = 2
log_bin = /var/log/mysql/mysql-bin.log
binlog_do_db = blog
并执行:
GRANT REPLICATION SLAVE ON *.* TO 'myuser'@'192.168.1.2' IDENTIFIED BY 'x';
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.2';
FLUSH PRIVILEGES;
USE mydb;
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
UNLOCK TABLES;
在其他服务器上也执行此操作,更改密码和 IP。之后,我配置从属服务器:
stop slave;
CHANGE MASTER TO MASTER_HOST='192.168.1.3', MASTER_USER='myuser', MASTER_PASSWORD='y’, MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=512;
start slave;
等等。数据库是空的。我使用 show slave status 并显示“连接 master 时出错”,使用 netstat 我查看只有一个连接,如下所示:
tcp 0 0 ns2174.ip-192-1:mysql ns2167.ip-192-1:36453 TIME_WAIT
我已尝试重新启动、停止一个从属服务器等;我可以使用 mysql -h 192.168.1.3 -p 等进行连接,但复制无法连接。