MySQL 跨版本主從復制時報錯:ERROR 1794 (HY000): Slave is not configured or failed to initialize properly.


 

背景: zabbix 數據庫遷移,搭建主從,主是5.6.25,從是5.7.15,流式備份應用 redo.log 之后,change master 和reset slave 時報出如下錯誤

 

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 版本中的主從信息記錄的是在表中,所以數據備份后需要對下面幾張表進行重建。

--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)

 

解決步驟:

1、drop 備份的 ibd表

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;

2、重建

mysql> source /usr/local/mysql/share/mysql_system_tables.sql
Query OK, 0 rows affected, 1 warning (0.00 sec) 

3、重啟數據庫

[root@zero02 data]# /etc/init.d/mysqld restart
Shutting down MySQL..                                      [  OK  ]
Starting MySQL..                                           [  OK  ]

  至此,問題解決,登陸數據庫,重新 change master to 即可!

 

作者:zero_gg
出處:http://www.cnblogs.com/zero-gg/

如果你真心覺得文章寫得不錯,而且對你有所幫助,那就不妨小小打賞一下吧,如果囊中羞澀,不妨幫忙“推薦"一下,您的“推薦”和”打賞“將是我最大的寫作動力!

本文版權歸作者所有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM