Slave is not configured or failed to initialize properly. You must at least set --server-id
一、如果版本不一樣請執行以下操作:
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.
1
2
3
4
5
6
7
8
9
原因:從 5.6.25 版本使用 innobackupex 備份,在 5.7.15 版本中應用恢復,ibd系統表需要重建
解決步驟:
1、drop 備份的 ibd表
#登入資料庫
mysql -uroot -p
#使用mysql資料庫
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;
#重建
source /app/mysql-5.7.25/share/mysql_system_tables.sql
#退出mysql
quit
#重啟mysql
/etc/init.d/mysqld restart
或者service mysqld restart
注:這裡根據自己的mysql路徑進行修改即可
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
至此,問題解決,登陸資料庫,重新 change master to 即可!
二、如果版本一樣,請執行以下操作
2.1. 編輯/etc/my.cnf
vi /etc/my.cnf
1
2.2. 新增如下2行程式碼
log-bin=mysql-bin
server-id=2
1
2
2.3. 重啟mysql
#重啟mysql
/etc/init.d/mysqld restart
或者service mysqld restart
注:這裡根據自己的mysql路徑進行修改即可
1
2
3
4
gblfy
關注
————————————————
版權宣告:本文為CSDN博主「gblfy」的原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上原文出處連結及本宣告。
原文連結:https://blog.csdn.net/weixin_40816738/article/details/100053304