温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

恢复slave从机上的部分表

发布时间:2020-08-14 17:40:14 来源:ITPUB博客 阅读:128 作者:StevenBeijing 栏目:MySQL数据库
以下案例演示重新初始化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)



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI