MySQL: Skip master-slave replication error

mysql master-slave replication, often encounter the error which led to slave-end replication is interrupted, this time generally will require manual intervention, skip the error to continue.

Skip wrong in two ways:


1. Skips a specified number of transactions

MySQL> Slave STOP;
MySQL> = the SET. 1 # skip the GLOBAL SQL_SLAVE_SKIP_COUNTER a transaction
mysql> slave start

2. Modify the mysql configuration file

  • To jump all error or a specific type of error parameters by slave_skip_errors 

we /etc/my.cnf


Note: In the [mysqld] Add the following under


# slave-skip-errors = 1062,1053,1146 # skip error no specified type of error
slave-skip-errors = all # skip all errors

Then, you can restart the server

# Restart mysql

service mysqld restart

# After the restart, view the status mysql

service mysqld status

# View from the state two main yes that is mainly from success

show slave status\G

 

Examples

  • Error leads to a master-slave replication blackout

  • Modify the mysql configuration file

  • Restart Service

# View from the state two main yes that is mainly from success

show slave status\G

 

mysql backup from the main common errors and solutions

    It successfully configured the first time in the main mysql database from a backup, that since everything can be worry-free. But not too long, by querying the instruction from the synchronization status of the server, the error was found in the online search for solutions to solve later. Found soon, other types of errors will occur. In short, I feel very troublesome, but also that master from a backup is not reliable, people often need to view the synchronization status, once the error occurs, people need timely treatment. This situation usually occurs in the first few days to do database synchronization, there is the master server, or a long time from the server downtime situation. Common errors and solutions:

[ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position', Error_code: 1236

              解决方案:出现1236,出现这种错误一般是主从服务器失去连接,出现了宕机的情况。常用解决办法,重新查询主服务器的状态,获取新的position位置,重新设置从服务器的同步信息。设置命令为:change master to master_log_file='',master_log_pos=123;

                

 Last_Errno: 1032, Last_Error: Could not execute Update_rows event on table xuanzhi.test; Can't find record in 'test', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysql

               解决方案:出现1032,表示从数据库上面缺少某一条数据记录,主数据库对这条记录又做了修改,从数据库在修改时报错。解决方案是直接用数据库管理工具,数据传输模式处理具体异常的数据表,保证主数据与从数据库对应的报错数据表结构信息一样。

 Last_Errno: 1062,Last_Error: Could not execute Write_rows event on table xuanzhi.test; Duplicate entry '5' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log 

               解决方案:出现1062,表示主键冲突,及从数据库上面出现了主数据库上面没有的主键信息记录。解决方案是直接删除提示的从数据库中的异常数据,或者利用数据传输模式处理具体异常的数据表。

Last_Errno: 1594,Last_Errno: 1593

             解决方案:中继日志错误,一般是服务器宕机引起,解决方案和出现错误1236一样。在msql 5.5以上版本,可在slave的配置文件my.cnf里要增加一个参数relay_log_recovery=1。

 

参考链接:https://www.cnblogs.com/wlandwl/p/mysql.html

Guess you like

Origin blog.csdn.net/fly910905/article/details/93721561