MySQL主从复制重新初始化单表或者单库的方法

2024-08-24 00:04

本文主要是介绍MySQL主从复制重新初始化单表或者单库的方法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

作者介绍:老苏,10余年DBA工作运维经验,擅长Oracle、MySQL、PG、Mongodb数据库运维(如安装迁移,性能优化、故障应急处理等)
公众号:老苏畅谈运维
欢迎关注本人公众号,更多精彩与您分享。

背景说明

在很多情况下,由于一张表或几张表的数据不一致导致主从复制中断,或者在搭建从库时,发现漏掉了某些库或者表。如果数据量较大,重新搭建一个从库耗时会较长。那么有没有办法只针对有问题的表或者漏掉的库重新初始化,从而恢复主从同步呢?

当然是有方法的,针对表的恢复操作有以下几种可行的方式:

  • 在主库锁定这张表做可传输表空间还原到从库
  • 在主库锁定这张表导出数据导入到从库
  • 使用备份恢复工具实现从库同步恢复

前面2种方法需要在导出数据过程中,需要进行锁表,考虑到对生产的影响尽可能减少,选择第三种方法来进行恢复。

环境说明

IP角色需初始的表
192.168.6.13主库sbtest库下的sbtest1、sbtest2
192.168.6.14从库sbtest库下的sbtest1、sbtest2

表的初始化恢复步骤

模拟从库出现表不一致

对主库进行加压测试数据

sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=192.168.6.13 --mysql-port=3306 --mysql-user=root --mysql-password='root@MySQL888' --mysql-db=sbtest --db-driver=mysql \
--tables=10 --table-size=1000 --report-interval=10 --threads=4 --time=600 --db-ps-mode=disable --max-requests=0 --percentile=95  run

加压过程中,删除从库的表sbtest1和sbtest2

(root@localhost)[sbtest]20:00>show tables;
+------------------+
| Tables_in_sbtest |
+------------------+
| sbtest1          |
| sbtest10         |
| sbtest2          |
| sbtest3          |
| sbtest4          |
| sbtest5          |
| sbtest6          |
| sbtest7          |
| sbtest8          |
| sbtest9          |
+------------------+
10 rows in set (0.00 sec)(root@localhost)[sbtest]20:01>drop table sbtest1;
Query OK, 0 rows affected (0.02 sec)(root@localhost)[sbtest]20:01>drop table sbtest2;
Query OK, 0 rows affected (0.00 sec)

从库同步报错

--同步状态(root@localhost)[sbtest]20:01>show slave status \G;
*************************** 1. row ***************************Slave_IO_State: Waiting for source to send eventMaster_Host: 192.168.6.13Master_User: svr_slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: binlog.000038Read_Master_Log_Pos: 103341043Relay_Log_File: relay.000087Relay_Log_Pos: 8172423Relay_Master_Log_File: binlog.000038Slave_IO_Running: YesSlave_SQL_Running: NoReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1146Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 3 failed executing transaction '86f14188-54fe-11ed-9f7a-0242c0a8060d:936591' at master log binlog.000038, end_log_pos 88970909. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.--日志显示找不到表sbtest.sbtest1
2024-08-23T20:01:31.543732+08:00 114 [ERROR] [MY-010584] [Repl] Slave SQL for channel '': Worker 2 failed executing transaction '86f14188-54fe-11ed-9f7a-0242c0a8060d:936590' at master log binlog.000038, end_log_pos 88968604; Error executing row event: 'Table 'sbtest.sbtest1' doesn't exist', Error_code: MY-001146
2024-08-23T20:01:31.544719+08:00 115 [ERROR] [MY-010584] [Repl] Slave SQL for channel '': Worker 3 failed executing transaction '86f14188-54fe-11ed-9f7a-0242c0a8060d:936591' at master log binlog.000038, end_log_pos 88970909; Error executing row event: 'Table 'sbtest.sbtest1' doesn't exist', Error_code: MY-001146
2024-08-23T20:01:31.545923+08:00 112 [Warning] [MY-010584] [Repl] Slave SQL for channel '': ... The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state. A restart should restore consistency automatically, although using non-transactional storage for data or info tables or DDL queries could lead to problems. In such cases you have to examine your data (see documentation for details). Error_code: MY-001756

从库停止复制进程

(root@localhost)[sbtest]20:03>stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)(root@localhost)[sbtest]20:03>show slave status \G
*************************** 1. row ***************************Slave_IO_State: Master_Host: 192.168.6.13Master_User: svr_slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: binlog.000038Read_Master_Log_Pos: 198568806Relay_Log_File: relay.000087Relay_Log_Pos: 8172423Relay_Master_Log_File: binlog.000038Slave_IO_Running: NoSlave_SQL_Running: No

主库单独备份有问题的表(一致性备份)

一致性备份

mysqldump -uroot -proot@MySQL888 -h 192.168.6.13 --single-transaction --master-data=2 --flush-logs sbtest sbtest1 sbtest2 > t.sql

查看备份文件记录的pos、gtid信息

cat t.sql SET @@GLOBAL.GTID_PURGED=/*!80000 '+'*/ '86f14188-54fe-11ed-9f7a-0242c0a8060d:1-994227';--
-- Position to start replication or point-in-time recovery from
---- CHANGE MASTER TO MASTER_LOG_FILE='binlog.000039', MASTER_LOG_POS=196;

从库导入数据

(root@localhost)[sbtest]20:04>show tables;
+------------------+
| Tables_in_sbtest |
+------------------+
| sbtest10         |
| sbtest3          |
| sbtest4          |
| sbtest5          |
| sbtest6          |
| sbtest7          |
| sbtest8          |
| sbtest9          |
+------------------+
8 rows in set (0.00 sec)(root@localhost)[sbtest]20:05>source t.sql
(root@localhost)[sbtest]20:05>show tables;
+------------------+
| Tables_in_sbtest |
+------------------+
| sbtest1          |
| sbtest10         |
| sbtest2          |
| sbtest3          |
| sbtest4          |
| sbtest5          |
| sbtest6          |
| sbtest7          |
| sbtest8          |
| sbtest9          |
+------------------+
10 rows in set (0.00 sec)

从库开启复制过滤

设置复制过滤,并指定UNTIL SQL_BEFORE_GTIDS

CHANGE REPLICATION FILTER REPLICATE_WILD_IGNORE_TABLE=('sbtest.sbtest1','sbtest.sbtest2');## UNTIL SQL_BEFORE_GTIDS指定的GTID值为备份文件中的GTID值+1
## 86f14188-54fe-11ed-9f7a-0242c0a8060d:994227 +1
## 注意指定结束点即可,无需指定开始点(不需要1-994228这种形式,只要994228)
start slave UNTIL SQL_BEFORE_GTIDS='86f14188-54fe-11ed-9f7a-0242c0a8060d:994228';--start slave  SQL_THREAD  UNTIL   SQL_BEFORE_GTIDS='86f14188-54fe-11ed-9f7a-0242c0a8060d:994228'或通过指定pos信息
start slave until MASTER_LOG_FILE='binlog.000039',MASTER_LOG_POS=196;(root@localhost)[(none)]20:09>CHANGE REPLICATION FILTER REPLICATE_WILD_IGNORE_TABLE=('sbtest.sbtest1','sbtest.sbtest2');
Query OK, 0 rows affected (0.00 sec)(root@localhost)[(none)]20:09>show slave status \G;
*************************** 1. row ***************************Slave_IO_State: Master_Host: 192.168.6.13Master_User: svr_slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: binlog.000038Read_Master_Log_Pos: 198568806Relay_Log_File: relay.000087Relay_Log_Pos: 8172423Relay_Master_Log_File: binlog.000038Slave_IO_Running: NoSlave_SQL_Running: NoReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: sbtest.sbtest1,sbtest.sbtest2(root@localhost)[(none)]20:09>start slave UNTIL SQL_BEFORE_GTIDS='86f14188-54fe-11ed-9f7a-0242c0a8060d:994228';
Query OK, 0 rows affected, 1 warning (0.01 sec)(root@localhost)[(none)]20:10>show slave status \G;
*************************** 1. row ***************************Slave_IO_State: Waiting for source to send eventMaster_Host: 192.168.6.13Master_User: svr_slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: binlog.000039Read_Master_Log_Pos: 122237428Relay_Log_File: relay.000090Relay_Log_Pos: 405Relay_Master_Log_File: binlog.000039Slave_IO_Running: YesSlave_SQL_Running: NoReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: sbtest.sbtest1,sbtest.sbtest2Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 196Relay_Log_Space: 122237920Until_Condition: SQL_BEFORE_GTIDSUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_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: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 330613Master_UUID: 86f14188-54fe-11ed-9f7a-0242c0a8060dMaster_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Master_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 86f14188-54fe-11ed-9f7a-0242c0a8060d:634558-1047246Executed_Gtid_Set: 86f14188-54fe-11ed-9f7a-0242c0a8060d:1-994227,
871fa289-54fe-11ed-9b0e-0242c0a8060e:1-20Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: Master_public_key_path: Get_master_public_key: 0Network_Namespace: 
1 row in set, 1 warning (0.01 sec)###可以看到同步这个gtid:86f14188-54fe-11ed-9f7a-0242c0a8060d:1-994227 就自动停止。

取消过滤,重新开启复制

待数据同步到GTID:994227点后会自动停止,重新配置过滤规则取消后复制恢复正常

stop slave;
CHANGE REPLICATION FILTER REPLICATE_WILD_IGNORE_TABLE=();
start slave;(root@localhost)[(none)]20:11>stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)(root@localhost)[(none)]20:11>CHANGE REPLICATION FILTER REPLICATE_WILD_IGNORE_TABLE=();
Query OK, 0 rows affected (0.00 sec)(root@localhost)[(none)]20:11>start slave;
Query OK, 0 rows affected, 1 warning (0.01 sec)(root@localhost)[(none)]20:12>show slave status \G;
*************************** 1. row ***************************Slave_IO_State: Waiting for source to send eventMaster_Host: 192.168.6.13Master_User: svr_slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: binlog.000039Read_Master_Log_Pos: 122238144Relay_Log_File: relay.000091Relay_Log_Pos: 807Relay_Master_Log_File: binlog.000039Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 122238144Relay_Log_Space: 122238845Until_Condition: NoneUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 330613Master_UUID: 86f14188-54fe-11ed-9f7a-0242c0a8060dMaster_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Replica has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 86f14188-54fe-11ed-9f7a-0242c0a8060d:634558-1047248Executed_Gtid_Set: 86f14188-54fe-11ed-9f7a-0242c0a8060d:1-1047248,
871fa289-54fe-11ed-9b0e-0242c0a8060e:1-20Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: Master_public_key_path: Get_master_public_key: 0Network_Namespace: 
1 row in set, 1 warning (0.01 sec)

库的初始化恢复步骤

针对某个库的初始化和表的初始化,步骤大体相似(不同地方就是在导出的时候针对库导出,后面用 CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB=(sbtest) 来进行过滤库)。

模拟从库出现库不一致

对主库进行加压测试数据

sysbench /usr/share/sysbench/oltp_read_write.lua --mysql-host=192.168.6.13 --mysql-port=3306 --mysql-user=root --mysql-password='root@MySQL888' --mysql-db=sbtest --db-driver=mysql \
--tables=10 --table-size=1000 --report-interval=10 --threads=4 --time=600 --db-ps-mode=disable --max-requests=0 --percentile=95  run

加压过程中,删除从库的sbtest库

(root@localhost)[(none)]21:15>show databases;
+-----------------------+
| Database              |
+-----------------------+
| 192_168_6_13_3306_aaa |
| aaa                   |
| inception             |
| information_schema    |
| mydb                  |
| mysql                 |
| ora_backup            |
| performance_schema    |
| sbtest                |
| sys                   |
+-----------------------+
10 rows in set (0.00 sec)(root@localhost)[(none)]21:16>drop database sbtest;
Query OK, 10 rows affected (0.08 sec)(root@localhost)[(none)]21:16>show databases;
+-----------------------+
| Database              |
+-----------------------+
| 192_168_6_13_3306_aaa |
| aaa                   |
| inception             |
| information_schema    |
| mydb                  |
| mysql                 |
| ora_backup            |
| performance_schema    |
| sys                   |
+-----------------------+
9 rows in set (0.01 sec)

从库同步报错

(root@localhost)[(none)]21:17>show slave status \G
*************************** 1. row ***************************Slave_IO_State: Waiting for source to send eventMaster_Host: 192.168.6.13Master_User: svr_slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: binlog.000040Read_Master_Log_Pos: 67009395Relay_Log_File: relay.000091Relay_Log_Pos: 11750613Relay_Master_Log_File: binlog.000039Slave_IO_Running: YesSlave_SQL_Running: NoReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1049Last_Error: Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker 1 failed executing transaction '86f14188-54fe-11ed-9f7a-0242c0a8060d:1052495' at master log binlog.000039, end_log_pos 134212310. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any.2024-08-23T21:16:11.664410+08:00 129 [ERROR] [MY-010584] [Repl] Slave SQL for channel '': Worker 3 failed executing transaction '86f14188-54fe-11ed-9f7a-0242c0a8060d:1052497' at master log binlog.000039, end_log_pos 134216920; Error executing row event: 'Unknown database 'sbtest'', Error_code: MY-001049
2024-08-23T21:16:11.664722+08:00 128 [ERROR] [MY-010584] [Repl] Slave SQL for channel '': Worker 2 failed executing transaction '86f14188-54fe-11ed-9f7a-0242c0a8060d:1052496' at master log binlog.000039, end_log_pos 134214615; Error executing row event: 'Unknown database 'sbtest'', Error_code: MY-001049
2024-08-23T21:16:11.672727+08:00 127 [ERROR] [MY-010584] [Repl] Slave SQL for channel '': Worker 1 failed executing transaction '86f14188-54fe-11ed-9f7a-0242c0a8060d:1052495' at master log binlog.000039, end_log_pos 134212310; Error executing row event: 'Unknown database 'sbtest'', Error_code: MY-001049
2024-08-23T21:16:11.675160+08:00 126 [ERROR] [MY-010586] [Repl] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log 'binlog.000039' position 133987950

从库停止复制进程

(root@localhost)[(none)]21:19>stop slave;
Query OK, 0 rows affected, 1 warning (0.01 sec)

主库备份有问题的库(一致性备份)

mysqldump -uroot -proot@MySQL888 -h 192.168.6.13 --single-transaction --master-data=2 --flush-logs sbtest  > db.sql

查看备份文件记录的pos、gtid信息

SET @@GLOBAL.GTID_PURGED=/*!80000 '+'*/ '86f14188-54fe-11ed-9f7a-0242c0a8060d:1-1064457';--
-- Position to start replication or point-in-time recovery from
---- CHANGE MASTER TO MASTER_LOG_FILE='binlog.000040', MASTER_LOG_POS=196;

从库导入数据

(root@localhost)[(none)]21:22>create database sbtest;
Query OK, 1 row affected (0.02 sec)(root@localhost)[(none)]21:22>use sbtest;
Database changed
(root@localhost)[sbtest]21:22>source db.sql;
(root@localhost)[sbtest]21:23>show tables;
+------------------+
| Tables_in_sbtest |
+------------------+
| sbtest1          |
| sbtest10         |
| sbtest2          |
| sbtest3          |
| sbtest4          |
| sbtest5          |
| sbtest6          |
| sbtest7          |
| sbtest8          |
| sbtest9          |
+------------------+
10 rows in set (0.00 sec)

从库开启复制过滤

设置复制过滤,并指定UNTIL SQL_BEFORE_GTIDS

CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB=(sbtest);## UNTIL SQL_BEFORE_GTIDS指定的GTID值为备份文件中的GTID值+1
## 86f14188-54fe-11ed-9f7a-0242c0a8060d:1-1064457 +1
## 注意指定结束点即可,无需指定开始点(不需要1-1064457这种形式,只要1064458)
start slave UNTIL SQL_BEFORE_GTIDS='86f14188-54fe-11ed-9f7a-0242c0a8060d:1064458';--start slave  SQL_THREAD  UNTIL   SQL_BEFORE_GTIDS='86f14188-54fe-11ed-9f7a-0242c0a8060d:1064458'或通过指定pos信息
start slave until MASTER_LOG_FILE='binlog.000040',MASTER_LOG_POS=196;(root@localhost)[sbtest]21:23>CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB=(sbtest);
Query OK, 0 rows affected (0.00 sec)(root@localhost)[(none)]21:42>start slave UNTIL SQL_BEFORE_GTIDS='86f14188-54fe-11ed-9f7a-0242c0a8060d:1064458';
Query OK, 0 rows affected, 1 warning (0.01 sec)
(root@localhost)[(none)]21:43>show slave status \G
*************************** 1. row ***************************Slave_IO_State: Queueing source event to the relay logMaster_Host: 192.168.6.13Master_User: svr_slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: binlog.000040Read_Master_Log_Pos: 514040758Relay_Log_File: relay.000097Relay_Log_Pos: 405Relay_Master_Log_File: binlog.000040Slave_IO_Running: YesSlave_SQL_Running: NoReplicate_Do_DB: Replicate_Ignore_DB: sbtestReplicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 196Relay_Log_Space: 514041475Until_Condition: SQL_BEFORE_GTIDSUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_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: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 330613Master_UUID: 86f14188-54fe-11ed-9f7a-0242c0a8060dMaster_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Master_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 86f14188-54fe-11ed-9f7a-0242c0a8060d:1052495-1287353Executed_Gtid_Set: 86f14188-54fe-11ed-9f7a-0242c0a8060d:1-1064457,
871fa289-54fe-11ed-9b0e-0242c0a8060e:1-22Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: Master_public_key_path: Get_master_public_key: 0Network_Namespace: 
1 row in set, 1 warning (0.00 sec)
###可以看到同步这个gtid:86f14188-54fe-11ed-9f7a-0242c0a8060d:1-1064457 就自动停止。

取消过滤,重新开启复制

待数据同步到GTID:1064457点后会自动停止,重新配置过滤规则取消后复制恢复正常

stop slave;
CHANGE REPLICATION FILTER REPLICATE_IGNORE_DB=();
start slave;

查看同步情况

(root@localhost)[(none)]21:50>show slave status \G
*************************** 1. row ***************************Slave_IO_State: Waiting for source to send eventMaster_Host: 192.168.6.13Master_User: svr_slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: binlog.000040Read_Master_Log_Pos: 569068103Relay_Log_File: relay.000098Relay_Log_Pos: 1881Relay_Master_Log_File: binlog.000040Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0Last_Error: Skip_Counter: 0Exec_Master_Log_Pos: 569068103Relay_Log_Space: 569068804Until_Condition: NoneUntil_Log_File: Until_Log_Pos: 0Master_SSL_Allowed: NoMaster_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error: Last_SQL_Errno: 0Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 330613Master_UUID: 86f14188-54fe-11ed-9f7a-0242c0a8060dMaster_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Replica has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 86f14188-54fe-11ed-9f7a-0242c0a8060d:1052495-1311285Executed_Gtid_Set: 86f14188-54fe-11ed-9f7a-0242c0a8060d:1-1311285,
871fa289-54fe-11ed-9b0e-0242c0a8060e:1-22Auto_Position: 1Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: Master_public_key_path: Get_master_public_key: 0Network_Namespace: 
1 row in set, 1 warning (0.00 sec)

在这里插入图片描述

关注我,学习更多的数据库知识!
请添加图片描述

这篇关于MySQL主从复制重新初始化单表或者单库的方法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1100873

相关文章

canal实现mysql数据同步的详细过程

《canal实现mysql数据同步的详细过程》:本文主要介绍canal实现mysql数据同步的详细过程,本文通过实例图文相结合给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的... 目录1、canal下载2、mysql同步用户创建和授权3、canal admin安装和启动4、canal

Maven 配置中的 <mirror>绕过 HTTP 阻断机制的方法

《Maven配置中的<mirror>绕过HTTP阻断机制的方法》:本文主要介绍Maven配置中的<mirror>绕过HTTP阻断机制的方法,本文给大家分享问题原因及解决方案,感兴趣的朋友一... 目录一、问题场景:升级 Maven 后构建失败二、解决方案:通过 <mirror> 配置覆盖默认行为1. 配置示

SpringBoot排查和解决JSON解析错误(400 Bad Request)的方法

《SpringBoot排查和解决JSON解析错误(400BadRequest)的方法》在开发SpringBootRESTfulAPI时,客户端与服务端的数据交互通常使用JSON格式,然而,JSON... 目录问题背景1. 问题描述2. 错误分析解决方案1. 手动重新输入jsON2. 使用工具清理JSON3.

使用jenv工具管理多个JDK版本的方法步骤

《使用jenv工具管理多个JDK版本的方法步骤》jenv是一个开源的Java环境管理工具,旨在帮助开发者在同一台机器上轻松管理和切换多个Java版本,:本文主要介绍使用jenv工具管理多个JD... 目录一、jenv到底是干啥的?二、jenv的核心功能(一)管理多个Java版本(二)支持插件扩展(三)环境隔

SQL中JOIN操作的条件使用总结与实践

《SQL中JOIN操作的条件使用总结与实践》在SQL查询中,JOIN操作是多表关联的核心工具,本文将从原理,场景和最佳实践三个方面总结JOIN条件的使用规则,希望可以帮助开发者精准控制查询逻辑... 目录一、ON与WHERE的本质区别二、场景化条件使用规则三、最佳实践建议1.优先使用ON条件2.WHERE用

MySQL存储过程之循环遍历查询的结果集详解

《MySQL存储过程之循环遍历查询的结果集详解》:本文主要介绍MySQL存储过程之循环遍历查询的结果集,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录前言1. 表结构2. 存储过程3. 关于存储过程的SQL补充总结前言近来碰到这样一个问题:在生产上导入的数据发现

Java中Map.Entry()含义及方法使用代码

《Java中Map.Entry()含义及方法使用代码》:本文主要介绍Java中Map.Entry()含义及方法使用的相关资料,Map.Entry是Java中Map的静态内部接口,用于表示键值对,其... 目录前言 Map.Entry作用核心方法常见使用场景1. 遍历 Map 的所有键值对2. 直接修改 Ma

MySQL 衍生表(Derived Tables)的使用

《MySQL衍生表(DerivedTables)的使用》本文主要介绍了MySQL衍生表(DerivedTables)的使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学... 目录一、衍生表简介1.1 衍生表基本用法1.2 自定义列名1.3 衍生表的局限在SQL的查询语句select

MySQL 横向衍生表(Lateral Derived Tables)的实现

《MySQL横向衍生表(LateralDerivedTables)的实现》横向衍生表适用于在需要通过子查询获取中间结果集的场景,相对于普通衍生表,横向衍生表可以引用在其之前出现过的表名,本文就来... 目录一、横向衍生表用法示例1.1 用法示例1.2 使用建议前面我们介绍过mysql中的衍生表(From子句

Mybatis Plus Join使用方法示例详解

《MybatisPlusJoin使用方法示例详解》:本文主要介绍MybatisPlusJoin使用方法示例详解,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,... 目录1、pom文件2、yaml配置文件3、分页插件4、示例代码:5、测试代码6、和PageHelper结合6