以下案例演示重新初始化slave上的個(gè)別表,如test01和test02.
1、停止slave復(fù)制
-
MySQL> stop slave;
-
Query OK, 0 rows affected (0.02 sec)
2、在master導(dǎo)出這張表,并記錄下同步的binlog和POS點(diǎn)
mysqldump -uroot -pmysql -q --single --master-data=2 test test01 test02 > test_01_test_02.sql
3、查看test_01_test_02.sql文件,找到記錄的binlog和POS點(diǎn)
MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=3407;
4、把test_01_test_02.sql復(fù)制到slave上,并做change master指向
-
mysql> start slave until master_log_file='mysql-bin.000003', MASTER_LOG_POS=3407;
-
Query OK, 0 rows affected, 1 warning (0.01 sec)
直到sql_thread線程為NO,這期間的同步報(bào)錯(cuò)一律跳過(guò)即可,可用如下命令跳過(guò):
stop slave;
set global sql_slave_skip_counter=1;
start slave;
5、在slave上導(dǎo)入
-
mysql> source /mysql/dump/test_01_test_02.sql
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.04 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.04 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 6 rows affected (0.01 sec)
-
Records: 6 Duplicates: 0 Warnings: 0
-
-
Query OK, 0 rows affected (0.01 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.06 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.07 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 6 rows affected (0.01 sec)
-
Records: 6 Duplicates: 0 Warnings: 0
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
-
-
Query OK, 0 rows affected (0.00 sec)
6、導(dǎo)入完畢之后,開(kāi)啟同步即可。
-
mysql> start slave;
-
Query OK, 0 rows affected (0.01 sec)
分享標(biāo)題:恢復(fù)slave從機(jī)上的部分表
文章出自:
http://weahome.cn/article/iejjsp.html