对一个M-M 架构的mysql 重新搭建双master ,出现了两个报错:
ERROR 29 (HY000): File '/home/mysql/data3306/slave-relay.066538' not found (Errcode: 2)
ERROR 1201 (HY000): Could not initialize master info structure;
(none)@3306 14:34:29>CHANGE MASTER TO
-> MASTER_HOST='10.1.147.164',
-> MASTER_USER='replicator',
-> MASTER_PASSWORD='yangql',
-> MASTER_LOG_FILE='mysql-bin.000002',
-> MASTER_LOG_POS=106;
ERROR 29 (HY000): File '/home/mysql/data3306/slave-relay.066538' not found (Errcode: 2)
查看 slave-relay-log.index 文件
[root@linux11-02 data3306]#cat slave-relay-log.index
/home/mysql/data3306/slave-relay.066537
/home/mysql/data3306/slave-relay.066538
/home/mysql/data3306/slave-relay.066539
/home/mysql/data3306/slave-relay.066540
/home/mysql/data3306/slave-relay.066541
/home/mysql/data3306/slave-relay.066542
/home/mysql/data3306/slave-relay.066543
/home/mysql/data3306/slave-relay.066544
/home/mysql/data3306/slave-relay.066545
data_dir 目录并不存在这些relay.log file 因为要重新创建,所以清除slave-relay-log.index 之后 重新指定 master
(none)@3306 14:37:36>CHANGE MASTER TO
-> MASTER_HOST='10.1.147.164',
-> MASTER_USER='replicator',
-> MASTER_PASSWORD='yangql',
-> MASTER_LOG_FILE='mysql-bin.000002',
-> MASTER_LOG_POS=106;
ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log
(none)@3306 14:37:42>
出现上述报错的原因是因为已经存在一个86KB的文件master.info(之前已经存在的文件),该文件导致mysqld提示复制无法初始化主数据库服务器的信息,直接删除该文件:
[root@linux11-02 data3306]# rm master.info
rm: remove regular file `master.info'? y
[root@linux11-02 data3306]# rm slave-relay-log.info
rm: remove regular empty file `slave-relay-log.info'? y
[root@linux11-02 data3306]#
再执行CHANAGE MASTER TO 命令,复制搭建成功,
(none)@3306 14:50:50>CHANGE MASTER TO
-> MASTER_HOST='10.1.147.164',
-> MASTER_USER='replicator',
-> MASTER_PASSWORD='yangql',
-> MASTER_LOG_FILE='mysql-bin.000002',
-> MASTER_LOG_POS=106;
Query OK, 0 rows affected (0.26 sec)
且生成了记录主数据库服务器信息的master.info和 slave-relay-log.info文件。