處理一則MySQL Slave環境出現ERROR 1201 (HY000): Could not initialize master info structure的案例

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   ar   for   sp   

 

mysql> start slave;ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository

 

處理一則MySQL Slave環境出現ERROR 1201 (HY000): Could not initialize master info structure的案例。 冷備份方式複製一份新的slave,初始化參數中已經修改了相關檔案路徑及server_id等關聯參數。但在啟動slave時發現error_log中出現下列錯誤資訊:
120326 11:10:23 [ERROR] /usr/local/mysql//libexec/mysqld: File ‘/data/mysqldata/3306/binlog/mysql-relay-bin.000002‘ not found (Errcode: 2)120326 11:10:23 [ERROR] Failed to open log (file ‘/data/mysqldata/3306/binlog/mysql-relay-bin.000002‘, errno 2)120326 11:10:23 [ERROR] Failed to open the relay log ‘/data/mysqldata/3306/binlog/mysql-relay-bin.000002‘ (relay_log_pos 126074557)120326 11:10:23 [ERROR] Could not open log file120326 11:10:23 [ERROR] Failed to initialize the master info structure

 

 由於新的slave改變了服務連接埠和檔案路徑,分析應該是由於mysql-relay-bin.index中仍然儲存著舊relay記錄檔的路徑,而這些路徑下又找不到合適的檔案,因此報錯。 對於這類問題解決起來是比較簡單的,重設slave的參照即可,執行命令如下:
mysql> reset slave;Query OK, 0 rows affected (0.01 sec) mysql> change master to     -> master_host=‘10.0.0.101‘,    -> master_port=3306,    -> master_user=‘repl‘,    -> master_password=‘repl‘,    -> master_log_file=‘mysql-bin.000011‘,    -> master_log_pos=1;

 

ERROR 29 (HY000): File ‘/data/mysqldata/3306/binlog/mysql-relay-bin.000001‘ not found (Errcode: 2)看來應該還是mysql-relay-bin.index的問題,刪除該檔案及關聯的relay-bin檔案。再次配置master:
mysql> change master to     -> master_host=‘10.0.0.101‘,    -> master_port=3306,    -> master_user=‘repl‘,    -> master_password=‘repl‘,    -> master_log_file=‘mysql-bin.000011‘,    -> master_log_pos=1;ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log

 

 出現了新的錯誤,按照提示查看error_log也沒發現更多錯誤資訊,error_log中只是顯示一條:
120326 11:14:27 [ERROR] Error reading master configuration在作業系統端查看master/slave的設定檔,發現是兩個0位元組檔案:-rw-rw---- 1 mysql mysql     0 Mar 26 11:13 master.info-rw-rw---- 1 mysql mysql     0 Mar 26 11:13 relay-log.info

 

會不會是這個原因呢,直接刪除這兩個檔案,然後嘗試重新執行change master: 
mysql> change master to     -> master_host=‘10.0.0.101‘,    -> master_port=3306,    -> master_user=‘repl‘,    -> master_password=‘repl‘,    -> master_log_file=‘mysql-bin.000011‘,    -> master_log_pos=1;Query OK, 0 rows affected (0.00 sec)

 

 成功,啟動slave並查看狀態:
mysql> start slave;Query OK, 0 rows affected (0.00 sec) mysql> show slave status\G*************************** 1. row ***************************               Slave_IO_State: Waiting for master to send event                  Master_Host: 10.0.0.101                  Master_User: repl                  Master_Port: 3306                Connect_Retry: 60              Master_Log_File: mysql-bin.000011          Read_Master_Log_Pos: 101

 

........... 故障解決。 轉自: http://blog.itpub.net/7607759/viewspace-719707/

處理一則MySQL Slave環境出現ERROR 1201 (HY000): Could not initialize master info structure的案例

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.