自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

一篇搞懂MySQL 8.0 Clone技術(shù)在線搭建主從復(fù)制全過程

數(shù)據(jù)庫 MySQL
MySQL從8.0.17開始新增了克隆Clone技術(shù),可以在線進(jìn)行MySQL的本地克隆或遠(yuǎn)程克隆,從此搭建從庫可以不再需要備份工具來實現(xiàn)了,本文分享Clone技術(shù)在線搭建主從復(fù)制全過程,希望對大家有幫助。

本文將通過Clone來實現(xiàn)一個遠(yuǎn)程從庫的搭建:環(huán)境如下

Mater: 192.168.3.133 port:3307 doner 捐贈者

Slave: 192.168.3.134 port:3307 recipient 接受者

第一步:兩臺機(jī)器MySQL分別進(jìn)行初始化安裝

進(jìn)入MySQL軟件目錄進(jìn)行初始化安裝并修改密碼:(MySQL8.0.19 下載解壓步驟省略) 

  1. [root@mgr2 bin]#cd /zcloud/db/abcMgr/abcMgr02/mysql/bin  
  2. [root@mgr2 bin]# ./mysqld --initialize --user=mysql  
  3. [root@mgr2 bin]# ./mysqld_safe --user=mysql &  
  4. [1] 19556  
  5. [root@mgr2 bin]# 2020-03-12T01:32:26.503048Z mysqld_safe Logging to ‘/rock/mysqldata/error.log’.  
  6. 2020-03-12T01:32:26.536292Z mysqld_safe Starting mysqld daemon with databases from /rock/mysqldata  
  7. [root@mgr2 bin]#  
  8. [root@mgr2 bin]# mysql -uroot -p -P3307  
  9. Enter password:  
  10. Welcome to the MySQL monitor. Commands end with ; or \g.  
  11. Your MySQL connection id is 8  
  12. Server version: 8.0.19  
  13. Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.  
  14. Oracle is a registered trademark of Oracle Corporation and/or its  
  15. affiliates. Other names may be trademarks of their respective  
  16. owners.  
  17. Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.  
  18. root@localhost:(none) 09:33:06 >alter user user() identified by ‘root1234’;  
  19. Query OK, 0 rows affected (0.00 sec) 
  20. root@localhost:(none) 09:33:26 >flush privileges;  
  21. Query OK, 0 rows affected (0.00 sec)  
  22. root@localhost:(none) 09:33:31 >exit  
  23. Bye 

第二步:doner節(jié)點192.168.3.133相關(guān)操作

–創(chuàng)建用戶 

  1. root@localhost:(none) 10:07:05 >create user ‘donor_user’@‘192.168.3.134’ identified by ‘password’;  
  2. Query OK, 0 rows affected (0.00 sec)  
  3. root@localhost:(none) 10:07:07 >grant backup_admin on . to ‘donor_user’@‘192.168.3.134’;  
  4. Query OK, 0 rows affected (0.01 sec) 

–安裝clone插件 

  1. root@localhost:(none) 10:23:16 >install plugin clone soname ‘mysql_clone.so’;  
  2. Query OK, 0 rows affected (0.01 sec) 

第三步:recipient節(jié)點192.168.3.134相關(guān)操作

–創(chuàng)建用戶(也可以不創(chuàng)建用戶,用root直接操作) 

  1. mysql> create user ‘recipient_user’@‘192.168.3.134’ identified by ‘password’; 

–安裝clone插件 

  1. mysql> grant clone_admin on . to ‘recipient_user’@‘192.168.3.134’; 

–設(shè)置參數(shù)clone_valid_donor_list 

  1. root@localhost:(none) 03:28:40 >set global clone_valid_donor_list=‘192.168.3.133:3307’;  
  2. Query OK, 0 rows affected (0.00 sec) 

–換成recipient_user’@‘192.168.3.134’ 用戶登陸,執(zhí)行clone語句(這里其實可以用本地root用戶直接進(jìn)行登錄操作) 

  1. [root@mgr3 bin]# mysql -urecipient_user -ppassword -P3307 -h192.168.3.134  
  2. recipient_user@192.168.3.134:(none) 03:39:46 >clone instance from ‘donor_user’@‘192.168.3.133’:3307 identified by ‘password’;  
  3. Query OK, 0 rows affected (2.34 sec)  
  4. recipient_user@192.168.3.134:(none) 03:39:57 >Restarting mysqld…  
  5. 2020-03-12T07:40:01.285267Z mysqld_safe Number of processes running now: 0  
  6. 2020-03-12T07:40:01.290169Z mysqld_safe mysqld restarted 

至此,遠(yuǎn)程數(shù)據(jù)的克隆已經(jīng)完成了。

通過查詢兩張表來監(jiān)控一下克隆的進(jìn)度和結(jié)果狀態(tài):

–查看clone進(jìn)度和狀態(tài) 

  1. root@localhost:(none) 03:34:49 >SELECT * FROM performance_schema.clone_progress;  
  2. ±-----±----------±----------±---------------------------±---------------------------±--------±----------±----------±----------±-----------±--------------+ 
  3. | ID | STAGE | STATE | BEGIN_TIME | END_TIME | THREADS | ESTIMATE | DATA | NETWORK | DATA_SPEED | NETWORK_SPEED |  
  4. ±-----±----------±----------±---------------------------±---------------------------±--------±----------±----------±----------±-----------±--------------+ 
  5. | 1 | DROP DATA | Completed | 2020-03-12 15:29:15.385694 | 2020-03-12 15:29:15.634609 | 1 | 0 | 0 | 0 | 0 | 0 |  
  6. | 1 | FILE COPY | Completed | 2020-03-12 15:29:15.634765 | 2020-03-12 15:29:17.452961 | 1 | 465800520 | 465800520 | 465833356 | 0 | 0 |  
  7. | 1 | PAGE COPY | Completed | 2020-03-12 15:29:17.453144 | 2020-03-12 15:29:17.554224 | 1 | 0 | 0 | 99 | 0 | 0 |  
  8. | 1 | REDO COPY | Completed | 2020-03-12 15:29:17.554413 | 2020-03-12 15:29:17.654430 | 1 | 2560 | 2560 | 3031 | 0 | 0 |  
  9. | 1 | FILE SYNC | Completed | 2020-03-12 15:29:17.654596 | 2020-03-12 15:29:17.730172 | 1 | 0 | 0 | 0 | 0 | 0 |  
  10. | 1 | RESTART | Completed | 2020-03-12 15:29:17.730172 | 2020-03-12 15:29:22.160372 | 0 | 0 | 0 | 0 | 0 | 0 |  
  11. | 1 | RECOVERY | Completed | 2020-03-12 15:29:22.160372 | 2020-03-12 15:29:22.478889 | 0 | 0 | 0 | 0 | 0 | 0 |  
  12. ±-----±----------±----------±---------------------------±---------------------------±--------±----------±----------±----------±-----------±--------------+  
  13. 7 rows in set (0.00 sec)  
  14. root@localhost:(none) 03:34:52 >SELECT * FROM performance_schema.clone_status\G  
  15. *************************** 1. row ***************************  
  16. ID: 1  
  17. PID: 0  
  18. STATE: Completed  
  19. BEGIN_TIME: 2020-03-12 15:29:15.385  
  20. END_TIME: 2020-03-12 15:29:22.479  
  21. SOURCE: 192.168.3.133:3307  
  22. DESTINATION: LOCAL INSTANCE  
  23. ERROR_NO: 0  
  24. ERROR_MESSAGE:  
  25. BINLOG_FILE: mysql-bin.000002  
  26. BINLOG_POSITION: 421  
  27. GTID_EXECUTED: 3e75bf2f-6401-11ea-8995-000c29db65a6:1  
  28. 1 row in set (0.00 sec) 

–在主庫133上建立復(fù)制賬號: 

  1. root@localhost:(none) 04:12:23 >create user repl@‘192.168.3.%’ identified by ‘repl’;  
  2. Query OK, 0 rows affected (0.00 sec)  
  3. root@localhost:(none) 04:13:03 >grant all on . to repl@‘192.168.3.%’; 
  4. Query OK, 0 rows affected (0.00 sec) 

–在從庫134上進(jìn)行復(fù)制步驟的完成: 

  1. root@localhost:(none) 04:16:09 >change master to master_host=‘192.168.3.133’,master_port=3307,master_user=‘repl’,master_password=‘repl’,master_auto_position=1
  2. Query OK, 0 rows affected, 2 warnings (0.00 sec)  
  3. root@localhost:(none) 04:17:32 >start slave;  
  4. Query OK, 0 rows affected (0.00 sec)  
  5. root@localhost:(none) 04:17:35 >show slave status\G  
  6. *************************** 1. row ***************************  
  7. Slave_IO_State: Waiting for master to send event  
  8. Master_Host: 192.168.3.133  
  9. Master_User: repl  
  10. Master_Port: 3307  
  11. Connect_Retry: 60  
  12. Master_Log_File: mysql-bin.000002  
  13. Read_Master_Log_Pos: 1193  
  14. Relay_Log_File: mgr3-relay-bin.000002  
  15. Relay_Log_Pos: 904  
  16. Relay_Master_Log_File: mysql-bin.000002  
  17. Slave_IO_Running: Yes  
  18. Slave_SQL_Running: Yes  
  19. Replicate_Do_DB:  
  20. Replicate_Ignore_DB:  
  21. Replicate_Do_Table:  
  22. Replicate_Ignore_Table:  
  23. Replicate_Wild_Do_Table:  
  24. Replicate_Wild_Ignore_Table:  
  25. Last_Errno: 0  
  26. Last_Error:  
  27. Skip_Counter: 0  
  28. Exec_Master_Log_Pos: 1193  
  29. Relay_Log_Space: 1103  
  30. Until_Condition: None  
  31. Until_Log_File:  
  32. Until_Log_Pos: 0  
  33. Master_SSL_Allowed: No  
  34. Master_SSL_CA_File:  
  35. Master_SSL_CA_Path:  
  36. Master_SSL_Cert:  
  37. Master_SSL_Cipher:  
  38. Master_SSL_Key:  
  39. Seconds_Behind_Master: 0  
  40. Master_SSL_Verify_Server_Cert: No  
  41. Last_IO_Errno: 0  
  42. Last_IO_Error:  
  43. Last_SQL_Errno: 0  
  44. Last_SQL_Error:  
  45. Replicate_Ignore_Server_Ids:  
  46. Master_Server_Id: 207  
  47. Master_UUID: 3e75bf2f-6401-11ea-8995-000c29db65a6  
  48. Master_Info_File: mysql.slave_master_info  
  49. SQL_Delay: 0  
  50. SQL_Remaining_Delay: NULL  
  51. Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates  
  52. Master_Retry_Count: 86400  
  53. Master_Bind:  
  54. Last_IO_Error_Timestamp:  
  55. Last_SQL_Error_Timestamp:  
  56. Master_SSL_Crl:  
  57. Master_SSL_Crlpath:  
  58. Retrieved_Gtid_Set: 3e75bf2f-6401-11ea-8995-000c29db65a6:3-4  
  59. Executed_Gtid_Set: 3e75bf2f-6401-11ea-8995-000c29db65a6:1-4  
  60. Auto_Position: 1  
  61. Replicate_Rewrite_DB:  
  62. Channel_Name:  
  63. Master_TLS_Version:  
  64. Master_public_key_path:  
  65. Get_master_public_key: 0  
  66. Network_Namespace:  
  67. 1 row in set (0.00 sec) 

至此遠(yuǎn)程從庫通過clone插件的方式搭建成功了,非常簡單也非??焖伲恍枰猰ysqldump也不需要xtrabackup,在線搭建成功,非???,以后用8.0可以考慮這種便捷的方式了。

最后將clone技術(shù)的 限制條件 列出:

  1.  版本大于等于8.0.17且不支持跨版本
  2.  兩臺機(jī)器具有相同的操作系統(tǒng)OS
  3.  兩臺MySQL實例具體相同的 innodb_page_size 和 innodb_data_file_path(ibdata文件名)
  4.  同一時刻僅僅允許有一個克隆任務(wù)存在
  5.  recipient 需要設(shè)置變量clone_valid_donor_list
  6.  max_allowed_packet 大于2M
  7.  doner的undo表空間文件名稱不能重復(fù)
  8.  不會克隆my.cnf文件
  9.  不會克隆binlog
  10.  僅僅支持innodb引擎 

 

責(zé)任編輯:龐桂玉 來源: 數(shù)據(jù)庫開發(fā)
相關(guān)推薦

2011-08-30 13:08:55

Mysql ProxyLua分離

2011-08-30 18:01:20

2011-02-22 10:46:02

Samba配置

2017-04-20 21:00:06

MySQLbinlog主從復(fù)制

2024-07-04 08:00:24

2025-02-10 10:55:16

2024-03-01 18:33:59

MySQL節(jié)點數(shù)據(jù)

2021-06-08 07:48:27

MySQL主從配置

2021-06-09 19:23:52

MySQLROLE管理

2015-07-08 09:57:59

Git服務(wù)器分步詳解

2022-02-08 16:17:41

MySQL主從復(fù)制數(shù)據(jù)庫

2023-02-27 07:33:14

MySQL數(shù)據(jù)庫服務(wù)器

2009-12-08 17:56:16

WCF配置

2011-04-18 15:56:10

軟件測試

2011-09-06 15:38:20

QT安裝

2011-01-21 17:51:52

2009-04-13 12:37:18

2023-03-19 11:53:27

2023-03-19 22:38:12

邏輯復(fù)制PostgreSQL

2009-08-05 14:16:38

無線局域網(wǎng)設(shè)置無線路由無線網(wǎng)卡
點贊
收藏

51CTO技術(shù)棧公眾號