mysql報錯:You must at least set –server-id to enable either a master or a slave

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.