ERROR 1201 (HY000): Could not initialize master info structure


mysql主従非同期、手動同期時に発生したエラー:

  
  
  
  
  1. mysql>stop slave;  
  2. mysql>change master to master_host='192.168.1.80',  
  3.  >master_user='admin',  
  4.  >master_password='123456',  
  5.  >master_log_file='mysql-bin.000519',  
  6.  >master_log_pos=107;  
  7. ERROR 1201 (HY000): Could not initialize master info structure; more error messages can be found in the MySQL error log 

ネット上の先輩たちの解決策には、サーバーからの中継ログの削除とreset slaveの2つがある.
1:エラー・ログの表示

  
  
  
  
  1. [root@test mysql]# tail test.com.err  
  2. 121229 11:34:01 [ERROR] Could not find target log during relay log initialization  
  3. 121229 11:38:05 [ERROR] Failed to open the relay log './81-relay-bin.000047' (relay_log_pos 12247)  
  4. 121229 11:38:05 [ERROR] Could not find target log during relay log initialization 121229 11:42:51 [ERROR] Failed to open the relay log './81-relay-bin.000047'   
  5.  
  6. (relay_log_pos 12247)  
  7. 121229 11:42:51 [ERROR] Could not find target log during relay log initialization  
  8. 121229 11:42:54 [ERROR] Failed to open the relay log './81-relay-bin.000047' (relay_log_pos 12247)  
  9. 121229 11:42:54 [ERROR] Could not find target log during relay log initialization  
  10. 121229 11:44:41 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='192.168.1.80'master_port='3306'master_log_file='',   
  11.  
  12. master_log_pos='4'. New state master_host='192.168.1.80'master_port='3306'master_log_file='mysql-bin.000583'master_log_pos='6682'.  
  13. 121229 11:44:52 [Note] Slave SQL thread initialized, starting replication in log'mysql-bin.000583' at position 6682, relay log './test-relay-bin.000001' position: 4  
  14.  

2:バイナリ・ログ情報の表示

  
  
  
  
  1. [root@test mysql]# cat relay-log.info  
  2. ./test-relay-bin.000002  
  3. 253  
  4. mysql-bin.000583  
  5. 6682 

3:master情報の表示

  
  
  
  
  1. [root@test mysql]# cat master.info  
  2. 18  
  3. mysql-bin.000583  
  4. 6682  
  5. 192.168.1.80  
  6. rep  
  7. 11111  
  8. 3306  
  9. 60  

1つ目の解決方法:

  
  
  
  
  1. [root@test mysql]#service mysqld stop   
  2. [root@test mysql]#rm -rf master.info  
  3. [root@test mysql]#rm -rf relay-log.info  
  4. [root@test mysql]#service mysqld start  
  5. mysql>change master to master_host='192.168.1.80',  
  6.  >master_user='admin',  
  7.  >master_password='123456',  
  8.  >master_log_file='mysql-bin.000519',  
  9.  >master_log_pos=107;  
  10. mysql>start slave;  

2つ目の解決策:

  
  
  
  
  1. mysql> reset slave;  
  2. mysql>change master to master_host='192.168.1.80',  
  3.  >master_user='admin',  
  4.  >master_password='123456',  
  5.  >master_log_file='mysql-bin.000519',  
  6.  >master_log_pos=107;  
  7. mysql>start slave;