久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

MySQL 8.0中如何通過Clone來實現一個遠程從庫的搭建

147次閱讀
沒有評論

共計 7501 個字符,預計需要花費 19 分鐘才能閱讀完成。

這篇文章給大家分享的是有關 MySQL 8.0 中如何通過 Clone 來實現一個遠程從庫的搭建的內容。丸趣 TV 小編覺得挺實用的,因此分享給大家做個參考,一起跟隨丸趣 TV 小編過來看看吧。

環境如下

Mater: 192.168.3.133 port:3307 doner 捐贈者

Slave: 192.168.3.134 port:3307 recipient 接受者

第一步:兩臺機器 MySQL 分別進行初始化安裝

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

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

第二步:doner 節點 192.168.3.133 相關操作

ndash; 創建用戶

root@localhost:(none) 10:07:05  create user  lsquo;donor_user rsquo;@ lsquo;192.168.3.134 rsquo; identified by  lsquo;password rsquo;; Query OK, 0 rows affected (0.00 sec) root@localhost:(none) 10:07:07  grant backup_admin on . to  lsquo;donor_user rsquo;@ lsquo;192.168.3.134 rsquo;; Query OK, 0 rows affected (0.01 sec)

ndash; 安裝 clone 插件

root@localhost:(none) 10:23:16  install plugin clone soname  lsquo;mysql_clone.so rsquo;; Query OK, 0 rows affected (0.01 sec)

第三步:recipient 節點 192.168.3.134 相關操作

ndash; 創建用戶(也可以不創建用戶,用 root 直接操作)

mysql  create user  lsquo;recipient_user rsquo;@ lsquo;192.168.3.134 rsquo; identified by  lsquo;password rsquo;;

ndash; 安裝 clone 插件

mysql  grant clone_admin on . to  lsquo;recipient_user rsquo;@ lsquo;192.168.3.134 rsquo;;

ndash; 設置參數 clone_valid_donor_list

root@localhost:(none) 03:28:40  set global clone_valid_donor_list= lsquo;192.168.3.133:3307 rsquo;; Query OK, 0 rows affected (0.00 sec)

ndash; 換成 recipient_user rsquo;@ lsquo;192.168.3.134 rsquo; 用戶登陸,執行 clone 語句 (這里其實可以用本地 root 用戶直接進行登錄操作)

[root@mgr3 bin]# mysql -urecipient_user -ppassword -P3307 -h292.168.3.134 recipient_user@192.168.3.134:(none) 03:39:46  clone instance from  lsquo;donor_user rsquo;@ lsquo;192.168.3.133 rsquo;:3307 identified by  lsquo;password rsquo;; Query OK, 0 rows affected (2.34 sec) recipient_user@192.168.3.134:(none) 03:39:57  Restarting mysqld hellip; 2020-03-12T07:40:01.285267Z mysqld_safe Number of processes running now: 0 2020-03-12T07:40:01.290169Z mysqld_safe mysqld restarted

至此,遠程數據的克隆已經完成了。

通過查詢兩張表來監控一下克隆的進度和結果狀態:

ndash; 查看 clone 進度和狀態

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

ndash; 在主庫 133 上建立復制賬號:

root@localhost:(none) 04:12:23  create user repl@ lsquo;192.168.3.% rsquo; identified by  lsquo;repl rsquo;; Query OK, 0 rows affected (0.00 sec) root@localhost:(none) 04:13:03  grant all on . to repl@ lsquo;192.168.3.% rsquo;; Query OK, 0 rows affected (0.00 sec)

ndash; 在從庫 134 上進行復制步驟的完成:

root@localhost:(none) 04:16:09  change master to master_host= lsquo;192.168.3.133 rsquo;,master_port=3307,master_user= lsquo;repl rsquo;,master_password= lsquo;repl rsquo;,master_auto_position=1; Query OK, 0 rows affected, 2 warnings (0.00 sec) root@localhost:(none) 04:17:32  start slave; Query OK, 0 rows affected (0.00 sec) root@localhost:(none) 04:17:35  show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.3.133 Master_User: repl Master_Port: 3307 Connect_Retry: 60 Master_Log_File: mysql-bin.000002 Read_Master_Log_Pos: 1193 Relay_Log_File: mgr3-relay-bin.000002 Relay_Log_Pos: 904 Relay_Master_Log_File: mysql-bin.000002 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 1193 Relay_Log_Space: 1103 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 207 Master_UUID: 3e75bf2f-6401-11ea-8995-000c29db65a6 Master_Info_File: mysql.slave_master_info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 3e75bf2f-6401-11ea-8995-000c29db65a6:3-4 Executed_Gtid_Set: 3e75bf2f-6401-11ea-8995-000c29db65a6:1-4 Auto_Position: 1 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: Master_public_key_path: Get_master_public_key: 0 Network_Namespace: 1 row in set (0.00 sec)

至此遠程從庫通過 clone 插件的方式搭建成功了,非常簡單也非常快速,不需要 mysqldump 也不需要 xtrabackup,在線搭建成功,非常快,以后用 8.0 可以考慮這種便捷的方式了。

感謝各位的閱讀!關于“MySQL 8.0 中如何通過 Clone 來實現一個遠程從庫的搭建”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-19發表,共計7501字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 金寨县| 西和县| 尚志市| 旌德县| 沅陵县| 朝阳市| 龙泉市| 定州市| 阿克苏市| 阿坝县| 巴塘县| 余江县| 泽普县| 永登县| 桦川县| 加查县| 黎川县| 息烽县| 当涂县| 新郑市| 渝北区| 大丰市| 乐至县| 墨脱县| 玛沁县| 鄂托克前旗| 嘉兴市| 金寨县| 五大连池市| 洪雅县| 双牌县| 济南市| 察哈| 福泉市| 确山县| 灵石县| 拉萨市| 滨海县| 德钦县| 敖汉旗| 喜德县|