背景: zabbix 数据库迁移,搭建主从,主是5.6.25,从是5.7.15,流式备份应用 redo.log 以后,change master 和reset slave 时报出以下错误mysql
mysql> CHANGE MASTER TO
-> MASTER_HOST='192.168.40.129',
-> MASTER_USER='repl',
-> MASTER_PASSWORD='repl_123',
-> MASTER_PORT=3306,
-> MASTER_LOG_FILE='mysql-bin.000005',
-> MASTER_LOG_POS=749,
-> MASTER_AUTO_POSITION=0;
ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.
缘由:从 5.6.25 版本使用 innobackupex 备份,在 5.7.15 版本中应用恢复,在 5.6.25 版本中,主从信息记录到了文件中,5.7.15 版本中的主从信息记录的是在表中,因此数据备份后须要对下面几张表进行重建。sql
--5.6.25 mysql> show variables like '%repository%'; +---------------------------+-------+ | Variable_name | Value | +---------------------------+-------+ | master_info_repository | FILE | | relay_log_info_repository | FILE | +---------------------------+-------+ 2 rows in set (0.00 sec)
--5.7.15 mysql> show variables like '%repository%'; +---------------------------+-------+ | Variable_name | Value | +---------------------------+-------+ | master_info_repository | TABLE | | relay_log_info_repository | TABLE | +---------------------------+-------+ 2 rows in set (0.00 sec)
解决步骤:数据库
一、drop 备份的 ibd表spa
use mysql
drop table slave_master_info;
drop table slave_relay_log_info;
drop table slave_worker_info;
drop table innodb_index_stats;
drop table innodb_table_stats;
二、重建rest
mysql> source /usr/local/mysql/share/mysql_system_tables.sql
Query OK, 0 rows affected, 1 warning (0.00 sec)
三、重启数据库server
[root@zero02 data]# /etc/init.d/mysqld restart
Shutting down MySQL.. [ OK ]
Starting MySQL.. [ OK ]
至此,问题解决,登录数据库,从新 change master to 便可!blog
做者:zero_gg 若是你真心以为文章写得不错,并且对你有所帮助,那就不妨小小打赏一下吧,若是囊中羞涩,不妨帮忙“推荐"一下,您的“推荐”和”打赏“将是我最大的写做动力!it 本文版权归做者全部,欢迎转载,但未经做者赞成必须保留此段声明,且在文章页面明显位置给出原文链接.io |