MySQL主从维护笔记

2023年 12月 27日 30.1k 0

1032,1062错误维护

1、主从复制状态检查:

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.20.52
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: slave3306_bin.002359
Read_Master_Log_Pos: 826041295
Relay_Log_File: relay3306.002778
Relay_Log_Pos: 1018409992
Relay_Master_Log_File: slave3306_bin.002358
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1032
Last_Error: Could not execute Update_rows event on table preinvoicenew.t_kp_record; Can’t find record in ‘t_kp_record’, Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event’s master log slave3306_bin.002358, end_log_pos 1018415279
Skip_Counter: 0
Exec_Master_Log_Pos: 1018409814
Relay_Log_Space: 1899784990
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1032
Last_SQL_Error: Could not execute Update_rows event on table preinvoicenew.t_kp_record; Can’t find record in ‘t_kp_record’, Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event’s master log slave3306_bin.002358, end_log_pos 1018415279
Replicate_Ignore_Server_Ids:
Master_Server_Id: 2
Master_UUID: 792ca926-fca6-11eb-9d03-acb3b57bf07d
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 231225 09:35:13
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 792ca926-fca6-11eb-9d03-acb3b57bf07d:149989186-547442278
Executed_Gtid_Set: 792ca926-fca6-11eb-9d03-acb3b57bf07d:16730-546963697,
9d1987be-9151-11ed-abc9-005056b7ea40:1-964199
Auto_Position: 0
1 row in set (0.00 sec)

ERROR:
No query specified
1062的错误新增主要内容如下:
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1062
Last_Error: Could not execute Write_rows event on table preinvoicenew.t_kp_record; Duplicate entry ‘000016154_6583a57ed6fcfd0001c13d42’ for key ‘serialNoUniue’, Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event’s master log slave3306_bin.002359, end_log_pos 123417974
……
Last_SQL_Errno: 1062
Last_SQL_Error: Could not execute Write_rows event on table preinvoicenew.t_kp_record; Duplicate entry ‘000016154_6583a57ed6fcfd0001c13d42’ for key ‘serialNoUniue’, Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event’s master log slave3306_bin.002359, end_log_pos 123417974

2、修改参数配置

编辑配置文件 vim /home/mysql3306/mysql-5.6.33/my.cnf
修改参数slave_skip_errors
原来是:slave_skip_errors = ddl_exist_errors
改后是:slave_skip_errors = ddl_exist_errors,1032,1062

3、重启数据库

先关闭:
/home/mysql3306/mysql-5.6.33/bin/mysqladmin shutdown -uroot -p密码 -S"/home/mysql3306/mysql-5.6.33/mysql.sock"
再启动:
nohup /home/mysql3306/mysql-5.6.33/bin/mysqld_safe --defaults-file=/home/mysql3306/mysql-5.6.33/my.cnf --user=mysql3306 >/dev/null 2>&1 &

4、再检查主从复制状态:

mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Queueing master event to the relay log
Master_Host: 192.168.20.52
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: slave3306_bin.002360
Read_Master_Log_Pos: 956544384
Relay_Log_File: relay3306.002803
Relay_Log_Pos: 9133512
Relay_Master_Log_File: slave3306_bin.002358
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 1027543008
Relay_Log_Space: 2085622154
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 233058
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 2
Master_UUID: 792ca926-fca6-11eb-9d03-acb3b57bf07d
Master_Info_File: mysql.slave_master_info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: System lock
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 792ca926-fca6-11eb-9d03-acb3b57bf07d:546963698-548117686
Executed_Gtid_Set: 792ca926-fca6-11eb-9d03-acb3b57bf07d:16730-546967970,
9d1987be-9151-11ed-abc9-005056b7ea40:1-964199
Auto_Position: 0
1 row in set (0.00 sec)

ERROR:
No query specified

如上状态说明主从复制修复成功。

5、确认数据同步完成

当Seconds_Behind_Master: 233058 再执行变化,直到变成 Seconds_Behind_Master: 0,表示数据同步完成,主从数据追平!

相关文章

pt-kill工具的使用
pt-ioprofile工具包的使用
数据库管理-第216期 Oracle的高可用-01(20240703)
DBMS_REPAIR EXAMPLE SCRIPT WITH PARTITION
数据库事务的四大特性: ACID 
使用BBED修复损坏的SYSTEM文件头

发布评论