MySQL Replication ERROR 1201: Could not initialize master info structure…
I have noticed strange behavior with MySQL version 5 and replication. I manage several MySQL database servers. The setup is simple, one master and two replication slaves acting as backups. The master server version is 5.0.22-log and the two slaves are 5.0.51a and 5.0.45.
When the replication gets interrupted (either via a clean server shutdown or a forced one), replication refuses to restart citing the following error:
ERROR 1201: Could not initialize master info structure, more error messages can be found in the MySQL error log
The master.info file is present in the data directory and has all the required information in it but MySQL refuses to use it. Searching on the net did not yield anything definitive.
The simplest way to restart replication from this point is to re-enter the master.info data manually. Do the following:
- STOP SLAVE
- RESET SLAVE
- CHANGE MASTER TO MASTER_HOST=’your_master’, MASTER_USER=’your_login’, MASTER_PASSWORD=’your_password’, MASTER_LOG_FILE=’log_file’, MASTER_LOG_POS=log_position
- START SLAVE
At this point you want to execute ‘SHOW SLAVE STATUS’ and check to see if everything is running. Most times MySQL will stop since it tried to replay a duplicate record from the logs. We need to tell MySQL to skip that record and continue:
- SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1
- START SLAVE
That should get replication up and running again.
What is interesting to note is that, under the same circumstances, my MySQL 4 servers had no problems continuing replication. In any case, don’t forget to run regular backups of your database.
thanks… this error drive me crazy the whole day.
Thats very good to know… thanks
I really enjoyed your blog, Thanks.
Thanks a lot. Bouncing our MySQL servers has just become a lot easier instead of doing a full dump and reload of the data from the master!
Regards
Lewis
Thanks for being the sole useful source of info on the matter!
There were always people who can write beautifully and you are among them
This helped a lot. I was able to get away with:
stop slave; reset slave;
CHANGE MASTER TO MASTER_LOG_POS=98 , MASTER_LOG_FILE = ‘mysqld-bin.000401′;
start slave;
the values came from running
SHOW SLAVE STATUS\G
before resetting
@Akom
Sounds like replication died right at the beginning of the log file in your case. I wonder if the master.info had the same data as listed by SHOW SLAVE.
Зачетный пост, спасибо!
спасибо за статью… добавил в ридер
Thanks a lot. You saved my day.
То ли в википедии, то ли еще где я уже читал эту подборку данных, но все равно спасибо
I really enjoyed you post, but still I am facing problem with my slave. it is not updating data from master. Output is below –
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.209
Master_User: rplusr
Master_Port: 3306
Connect_Retry: 10
Master_Log_File: mysql-bin.000009
Read_Master_Log_Pos: 130188
Relay_Log_File: mysqld-relay-bin.000003
Relay_Log_Pos: 235
Relay_Master_Log_File: mysql-bin.000009
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Here Relay_Log_Pos: 235 always same.
what should i do for this problem
@Chetan, have you checked my post on the Silent Timeout Failure?
Also, I have found that running replication over an SSH tunnel makes it more robust.