stop slave; ..."/>
溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

恢復(fù)slave從機上的部分表

發(fā)布時間:2020-08-14 17:40:14 來源:ITPUB博客 閱讀:125 作者:StevenBeijing 欄目:MySQL數(shù)據(jù)庫
以下案例演示重新初始化slave上的個別表,如test01和test02.
1、停止slave復(fù)制

點擊(此處)折疊或打開

  1. mysql> stop slave;
  2. Query OK, 0 rows affected (0.02 sec)
2、在master導(dǎo)出這張表,并記錄下同步的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復(fù)制到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上導(dǎo)入

點擊(此處)折疊或打開

  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、導(dǎo)入完畢之后,開啟同步即可。

點擊(此處)折疊或打開

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



向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI