Tuesday, 10 November 2020

MySQL : Troubleshooting Replication

If you have followed the instructions to make a replica (If not have a visit at this quick post), and your replication setup is not working, than the first thing to do is check MySQL error log. (if you dont know where it is? Just check my.cnf for the location of that file). Most of time, you will get the actual error from the log if not than you can try below things.

 

  • Check master server and verify that binlog is enable or not and position is rotating or not by using “show master status” command.
  • Master and slave server both must have unique server_id.
  • Run “show slave status” command on slave server and check below values first.Slave_IO_Running:Slave_SQL_Running: Last_errno: 0 Last_error:
  • If “Slave_IO_Running” is “YES” than slave is able to connect master and getting log entries from master but if it’s “NO” that means slave is not able to connect to master so check the values of Master_Host, Master_User, Master_Pass that it is right or not. Also check the connectivity between master and slave for mysql as well as network side.
  • If “Slave_SQL_Running” is “YES” than no issue with sql thread butit its “NO” than you should get error on “Last_error”.
  • Most of time, you will get the query related error in “Last_error” section.
  • If the slave was running previously but stopped suddenly than the reason usually is that some statement that succeeded on the master failed on the slave.
  • If a statement that succeeded on the master but refuses to run on the slave, try to do the below things. Because it‘s not feasible to do a full database resynchronization from the masterby copying a new snapshot/backup from the master.
  • Sometimes, its happening when table changes are done in master server but somehow its not replicated on slave so slave will refuse to run the statement and give error. In this situation, we have synchronize the changes and start replication with simple “Start Slave” command.
  • Sometimes, we are getting some error which can be solve by running that statement manually. At that time we can just stop slave completely, skip the statement with “ set global sql_slave_skip_counter=1” command, start the slave.



No comments:

Post a Comment