亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

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

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

MySQL主從復制之延遲型數據復制

發布時間:2020-08-12 21:47:20 來源:ITPUB博客 閱讀:146 作者:StevenBeijing 欄目:MySQL數據庫
   讓MySQL拓撲中的從節點延遲適當的時間,可以幫助避免在主節點上發生的災難性的錯誤。
   MASTER_DELAY這個屬性指定SQL_THREAD會在從節點上暫定多長時間,時間以秒為單位。默認值為0,上限為68年。
mysql> stop slave;
Query OK, 0 rows affected (0.06 sec)
mysql> change master to master_delay=20;
Query OK, 0 rows affected (0.01 sec)
mysql> start slave;

點擊(此處)折疊或打開

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

  3. mysql> change master to master_delay=20 ;
  4. Query OK, 0 rows affected (0.02 sec)

  5. mysql> start slave;
  6. Query OK, 0 rows affected (0.02 sec)

  7. mysql> show slave status \G
  8. *************************** 1. row ***************************
  9.                Slave_IO_State: Waiting for master to send event
  10.                   Master_Host: 192.168.8.57
  11.                   Master_User: repl
  12.                   Master_Port: 3306
  13.                 Connect_Retry: 10
  14.               Master_Log_File: mysql-bin.000021
  15.           Read_Master_Log_Pos: 154
  16.                Relay_Log_File: relay-log.000002
  17.                 Relay_Log_Pos: 320
  18.         Relay_Master_Log_File: mysql-bin.000021
  19.              Slave_IO_Running: Yes
  20.             Slave_SQL_Running: Yes
  21.               Replicate_Do_DB:
  22.           Replicate_Ignore_DB:
  23.            Replicate_Do_Table:
  24.        Replicate_Ignore_Table:
  25.       Replicate_Wild_Do_Table:
  26.   Replicate_Wild_Ignore_Table:
  27.                    Last_Errno: 0
  28.                    Last_Error:
  29.                  Skip_Counter: 0
  30.           Exec_Master_Log_Pos: 154
  31.               Relay_Log_Space: 521
  32.               Until_Condition: None
  33.                Until_Log_File:
  34.                 Until_Log_Pos: 0
  35.            Master_SSL_Allowed: No
  36.            Master_SSL_CA_File: /usr/local/mysql/certs/ca-cert.pem
  37.            Master_SSL_CA_Path:
  38.               Master_SSL_Cert: /usr/local/mysql/certs/client-cert.pem
  39.             Master_SSL_Cipher:
  40.                Master_SSL_Key: /usr/local/mysql/certs/client-key.pem
  41.         Seconds_Behind_Master: 0
  42. Master_SSL_Verify_Server_Cert: No
  43.                 Last_IO_Errno: 0
  44.                 Last_IO_Error:
  45.                Last_SQL_Errno: 0
  46.                Last_SQL_Error:
  47.   Replicate_Ignore_Server_Ids:
  48.              Master_Server_Id: 1
  49.                   Master_UUID: 9ad24233-aeef-11e7-aa1b-080027768e58
  50.              Master_Info_File: mysql.slave_master_info
  51.                     SQL_Delay: 20
  52.           SQL_Remaining_Delay: NULL
  53.       Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
  54.            Master_Retry_Count: 86400
  55.                   Master_Bind:
  56.       Last_IO_Error_Timestamp:
  57.      Last_SQL_Error_Timestamp:
  58.                Master_SSL_Crl:
  59.            Master_SSL_Crlpath:
  60.            Retrieved_Gtid_Set:
  61.             Executed_Gtid_Set:
  62.                 Auto_Position: 0
  63.          Replicate_Rewrite_DB:
  64.                  Channel_Name:
  65.            Master_TLS_Version:
  66. 1 row in set (0.00 sec)
    可以看到SQL_Delay: 20
下邊做一個測試:
在主節點對測試表做truncate

點擊(此處)折疊或打開

  1. mysql> show tables;
  2. +----------------+
  3. | Tables_in_test |
  4. +----------------+
  5. | tb_admin |
  6. | tb_admin_bak |
  7. +----------------+
  8. 2 rows in set (0.00 sec)

  9. mysql> truncate table tb_admin_bak;
  10. Query OK, 0 rows affected (0.02 sec)
在從節點查看表信息

點擊(此處)折疊或打開

  1. mysql> select count(*) from tb_admin_bak;
  2. +----------+
  3. | count(*) |
  4. +----------+
  5. | 1 |
  6. +----------+
  7. 1 row in set (0.02 sec)

  8. mysql> select count(*) from tb_admin_bak;
  9. +----------+
  10. | count(*) |
  11. +----------+
  12. | 1 |
  13. +----------+
  14. 1 row in set (0.00 sec)

  15. mysql> show full processlist \G
  16. *************************** 1. row ***************************
  17.      Id: 3
  18.    User: root
  19.    Host: localhost
  20.      db: test
  21. Command: Query
  22.    Time: 0
  23.   State: starting
  24.    Info: show full processlist
  25. *************************** 2. row ***************************
  26.      Id: 8
  27.    User: system user
  28.    Host:
  29.      db: NULL
  30. Command: Connect
  31.    Time: 334
  32.   State: Waiting for master to send event
  33.    Info: NULL
  34. *************************** 3. row ***************************
  35.      Id: 9
  36.    User: system user
  37.    Host:
  38.      db: NULL
  39. Command: Connect
  40.    Time: 100
  41.   State: Waiting until MASTER_DELAY seconds after master executed event
  42.    Info: NULL
  43. 3 rows in set (0.00 sec)
  44. mysql> select count(*) from tb_admin_bak;
  45. +----------+
  46. | count(*) |
  47. +----------+
  48. | 0 |
  49. +----------+
  50. 1 row in set (0.00 sec)
發現從節點此表數據剛開始并沒有被清理,20S之后數據才被清理掉。

在主庫刪除測試表

點擊(此處)折疊或打開

  1. mysql> drop table tb_admin_bak;
  2. Query OK, 0 rows affected (0.06 sec)

  3. mysql> show tables;
  4. +----------------+
  5. | Tables_in_test |
  6. +----------------+
  7. | tb_admin |
  8. +----------------+
  9. 1 row in set (0.00 sec)
在從庫查看表是否存在

點擊(此處)折疊或打開

  1. mysql> show tables;
  2. +----------------+
  3. | Tables_in_test |
  4. +----------------+
  5. | tb_admin |
  6. | tb_admin_bak |
  7. +----------------+
  8. 2 rows in set (0.00 sec)

  9. mysql> show tables;
  10. +----------------+
  11. | Tables_in_test |
  12. +----------------+
  13. | tb_admin |
  14. | tb_admin_bak |
  15. +----------------+
  16. 2 rows in set (0.00 sec)

  17. mysql> show tables;
  18. +----------------+
  19. | Tables_in_test |
  20. +----------------+
  21. | tb_admin |
  22. | tb_admin_bak |
  23. +----------------+
  24. 2 rows in set (0.00 sec)

  25. mysql> show tables;
  26. +----------------+
  27. | Tables_in_test |
  28. +----------------+
  29. | tb_admin |
  30. | tb_admin_bak |
  31. +----------------+
  32. 2 rows in set (0.00 sec)

  33. mysql> show tables;
  34. +----------------+
  35. | Tables_in_test |
  36. +----------------+
  37. | tb_admin |
  38. | tb_admin_bak |
  39. +----------------+
  40. 2 rows in set (0.00 sec)

  41. mysql> show tables;
  42. +----------------+
  43. | Tables_in_test |
  44. +----------------+
  45. | tb_admin |
  46. | tb_admin_bak |
  47. +----------------+
  48. 2 rows in set (0.00 sec)

  49. mysql> show tables;
  50. +----------------+
  51. | Tables_in_test |
  52. +----------------+
  53. | tb_admin |
  54. | tb_admin_bak |
  55. +----------------+
  56. 2 rows in set (0.00 sec)

  57. mysql> show tables;
  58. +----------------+
  59. | Tables_in_test |
  60. +----------------+
  61. | tb_admin |
  62. +----------------+
  63. 1 row in set (0.00 sec)

  64. mysql> show tables;
  65. +----------------+
  66. | Tables_in_test |
  67. +----------------+
  68. | tb_admin |
  69. +----------------+
  70. 1 row in set (0.00 sec)
一段時間之后,測試表才被刪除。




向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

莎车县| 湄潭县| 禄劝| 七台河市| 开封市| 玉田县| 磐安县| 延安市| 囊谦县| 昌都县| 定边县| 广昌县| 太谷县| 德阳市| 光泽县| 拜城县| 阳山县| 柳林县| 黔西县| 石台县| 若尔盖县| 赤峰市| 南部县| 阿克陶县| 灵璧县| 桐柏县| 思南县| 凯里市| 治多县| 崇文区| 西盟| 申扎县| 洱源县| 祁东县| 衡东县| 霍山县| 收藏| 马山县| 柏乡县| 商南县| 东阳市|