標籤:is slave not
【情境】MySQL版本:Percona-Server 5.6.23,相關主要參數:
server_id = 3306sync_binlog=1gtid_mod = onenforce-gtid-consistency = 1log-slave-updates = 1relay-log-purge = 1relay_log_recovery = 1master_info_repository = "TABLE"relay_log_info_repository = "TABLE"
打算部署一個新的slave執行個體用於測試,圖方便從master上直接把mysql這個系統庫整個目錄拷貝到slave上,進行初始化後,執行 CHANGE MASTER 配置主從複製,但卻提示錯誤資訊:
mysql> change master to master_host=’10.x.x.x’,master_port=3306,master_user=’repl’,master_password=’xx’,master_auto_position=1;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.
看到這個錯誤資訊,最直覺的反應是 server_id 設定錯誤了,比如和 master 的ID重複了。經過檢查,確認不是這個原因,嘗試檢查了其他參數,也提示同樣的錯誤。另外奇怪的是,上面的錯誤資訊,未被記錄到錯誤記錄檔中。
【分析】應該注意到一點,上面提到初始化slave執行個體時,是從master上直接拷貝mysql系統庫整個目錄的,但並沒有同時也拷貝 ibdata1、ib_logfile* 等InnoDB相關檔案。其實問題就在這裡,因為mysql系統庫中,下面這幾個表是採用InnoDB引擎的,所以初始化後,無法正常讀寫:
innodb_index_statsinnodb_table_statsslave_master_infoslave_relay_log_infoslave_worker_info
經驗證,通過用戶端訪問mysql庫時,就會提示下面的錯誤資訊了:
2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/innodb_index_stats from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/innodb_table_stats from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/slave_master_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.2015-05-04 17:21:25 14407 [Warning] InnoDB: Cannot open table mysql/slave_worker_info from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
【解決】本次案例中造成上述問題的原因是沒有按照標準流程進行初始化,或者沒有把master上的全部相關檔案都拷貝到slave上去,導致mysql庫下的幾個InnoDB表無法使用。
解決的方法有兩個:
1、刪解除mysql系統庫目錄下上述幾個表對應的ibd檔案,執行 mysql_install_db 重新初始化;
2、從master將整個資料庫全部檔案都拷貝到slave上,並確認InnoDB的共用資料表空間檔案及REDO LOG大小配置和master上是一致的;
本文出自 “11726068” 部落格,謝絕轉載!
mysql報錯:You must at least set –server-id to enable either a master or a slave