恢复slave从机上的部分表

以下案例演示重新初始化slave上的个别表,如test01和test02.
1、停止slave复制

点击(此处)折叠或打开

在顺平等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、成都网站建设 网站设计制作定制网站制作,公司网站建设,企业网站建设,品牌网站建设,成都营销网站建设,外贸网站制作,顺平网站建设费用合理。

  1. MySQL> stop slave;
  2. Query OK, 0 rows affected (0.02 sec)
2、在master导出这张表,并记录下同步的binlog和POS点
mysqldump -uroot -pmysql -q --single --master-data=2 test test01 test02 > test_01_test_02.sql
3、查看test_01_test_02.sql文件,找到记录的binlog和POS点
MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=3407;
4、把test_01_test_02.sql复制到slave上,并做change master指向

点击(此处)折叠或打开

  1. mysql> start slave until master_log_file='mysql-bin.000003', MASTER_LOG_POS=3407;
  2. Query OK, 0 rows affected, 1 warning (0.01 sec)
直到sql_thread线程为NO,这期间的同步报错一律跳过即可,可用如下命令跳过:
stop slave;
set global sql_slave_skip_counter=1;
start slave;
5、在slave上导入

点击(此处)折叠或打开

  1. mysql> source /mysql/dump/test_01_test_02.sql
  2. Query OK, 0 rows affected (0.00 sec)

  3. Query OK, 0 rows affected (0.00 sec)

  4. Query OK, 0 rows affected (0.00 sec)

  5. Query OK, 0 rows affected (0.00 sec)

  6. Query OK, 0 rows affected (0.00 sec)

  7. Query OK, 0 rows affected (0.00 sec)

  8. Query OK, 0 rows affected (0.00 sec)

  9. Query OK, 0 rows affected (0.00 sec)

  10. Query OK, 0 rows affected (0.00 sec)

  11. Query OK, 0 rows affected (0.00 sec)

  12. Query OK, 0 rows affected (0.04 sec)

  13. Query OK, 0 rows affected (0.00 sec)

  14. Query OK, 0 rows affected (0.00 sec)

  15. Query OK, 0 rows affected (0.04 sec)

  16. Query OK, 0 rows affected (0.00 sec)

  17. Query OK, 0 rows affected (0.00 sec)

  18. Query OK, 0 rows affected (0.00 sec)

  19. Query OK, 6 rows affected (0.01 sec)
  20. Records: 6 Duplicates: 0 Warnings: 0

  21. Query OK, 0 rows affected (0.01 sec)

  22. Query OK, 0 rows affected (0.00 sec)

  23. Query OK, 0 rows affected (0.06 sec)

  24. Query OK, 0 rows affected (0.00 sec)

  25. Query OK, 0 rows affected (0.00 sec)

  26. Query OK, 0 rows affected (0.07 sec)

  27. Query OK, 0 rows affected (0.00 sec)

  28. Query OK, 0 rows affected (0.00 sec)

  29. Query OK, 0 rows affected (0.00 sec)

  30. Query OK, 6 rows affected (0.01 sec)
  31. Records: 6 Duplicates: 0 Warnings: 0

  32. Query OK, 0 rows affected (0.00 sec)

  33. Query OK, 0 rows affected (0.00 sec)

  34. Query OK, 0 rows affected (0.00 sec)

  35. Query OK, 0 rows affected (0.00 sec)

  36. Query OK, 0 rows affected (0.00 sec)

  37. Query OK, 0 rows affected (0.00 sec)

  38. Query OK, 0 rows affected (0.00 sec)

  39. Query OK, 0 rows affected (0.00 sec)

  40. Query OK, 0 rows affected (0.00 sec)

  41. Query OK, 0 rows affected (0.00 sec)
6、导入完毕之后,开启同步即可。

点击(此处)折叠或打开

  1. mysql> start slave;
  2. Query OK, 0 rows affected (0.01 sec)




网站名称:恢复slave从机上的部分表
网站网址:http://scyanting.com/article/iejjsp.html