首页 > 数据库 >【MySQL 8.0】通过Clone Plugin实现数据库的复制

【MySQL 8.0】通过Clone Plugin实现数据库的复制

时间:2023-08-25 17:37:20浏览次数:50  
标签:clone 8.0 rows 04 Plugin Clone sec 2023 08

(root@node01) > create user 'donor'@'%' identified by 'donor';
Query OK, 0 rows affected (0.10 sec)

(root@node01) > grant backup_admin on *.* to 'donor'@'%';
Query OK, 0 rows affected (0.23 sec)

(root@node01) > show grants for 'donor'@'%';
+------------------------------------------+
| Grants for donor@%                       |
+------------------------------------------+
| GRANT USAGE ON *.* TO `donor`@`%`        |
| GRANT BACKUP_ADMIN ON *.* TO `donor`@`%` |
+------------------------------------------+
2 rows in set (0.11 sec)

(root@node01) > install plugin clone soname 'mysql_clone.so';
Query OK, 0 rows affected (1.66 sec)

(root@node01) > show global variables like 'clone%';
+-------------------------------------------+---------+
| Variable_name                             | Value   |
+-------------------------------------------+---------+
| clone_autotune_concurrency                | ON      |
| clone_block_ddl                           | OFF     |
| clone_buffer_size                         | 4194304 |
| clone_ddl_timeout                         | 300     |
| clone_delay_after_data_drop               | 0       |
| clone_donor_timeout_after_network_failure | 5       |
| clone_enable_compression                  | OFF     |
| clone_max_concurrency                     | 16      |
| clone_max_data_bandwidth                  | 0       |
| clone_max_network_bandwidth               | 0       |
| clone_ssl_ca                              |         |
| clone_ssl_cert                            |         |
| clone_ssl_key                             |         |
| clone_valid_donor_list                    |         |
+-------------------------------------------+---------+
14 rows in set (0.11 sec)
(root@node02) >  create user 'replica'@'%' identified by 'replica';
Query OK, 0 rows affected (0.03 sec)

(root@node02) > grant clone_admin,system_variables_admin on *.* to 'replica'@'%';
Query OK, 0 rows affected (0.01 sec)

(root@node02) > show grants for 'replica'@'%';
+------------------------------------------------------------------+
| Grants for replica@%                                             |
+------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `replica`@`%`                              |
| GRANT CLONE_ADMIN,SYSTEM_VARIABLES_ADMIN ON *.* TO `replica`@`%` |
+------------------------------------------------------------------+
2 rows in set (0.00 sec)

(root@node02) > install plugin clone soname 'mysql_clone.so';
Query OK, 0 rows affected (0.08 sec)

[mysql@node02 ~]$ mysql -ureplica -preplica -hnode02
(replica@node02) > set global clone_valid_donor_list='192.168.1.101:3306';
Query OK, 0 rows affected (0.00 sec)

(replica@node02) > clone instance from 'donor'@'192.168.1.101':3306 identified by 'donor';
Query OK, 0 rows affected (1 min 35.41 sec)

(root@node02) > select * from performance_schema.clone_progress;
+------+-----------+-----------+----------------------------+----------------------------+---------+------------+------------+------------+------------+---------------+
| ID   | STAGE     | STATE     | BEGIN_TIME                 | END_TIME                   | THREADS | ESTIMATE   | DATA       | NETWORK    | DATA_SPEED | NETWORK_SPEED |
+------+-----------+-----------+----------------------------+----------------------------+---------+------------+------------+------------+------------+---------------+
|    1 | DROP DATA | Completed | 2023-08-04 10:58:20.067783 | 2023-08-04 10:58:20.560624 |       1 |          0 |          0 |          0 |          0 |             0 |
|    1 | FILE COPY | Completed | 2023-08-04 10:58:20.561700 | 2023-08-04 10:59:52.534608 |       2 | 2088062436 | 2088062436 | 2088183441 |          0 |             0 |
|    1 | PAGE COPY | Completed | 2023-08-04 10:59:52.535234 | 2023-08-04 10:59:52.668787 |       2 |          0 |          0 |        197 |          0 |             0 |
|    1 | REDO COPY | Completed | 2023-08-04 10:59:52.669329 | 2023-08-04 10:59:52.802320 |       2 |       2560 |       2560 |       2999 |          0 |             0 |
|    1 | FILE SYNC | Completed | 2023-08-04 10:59:52.802949 | 2023-08-04 10:59:54.415432 |       2 |          0 |          0 |          0 |          0 |             0 |
|    1 | RESTART   | Completed | 2023-08-04 10:59:54.415432 | 2023-08-04 10:59:59.931717 |       0 |          0 |          0 |          0 |          0 |             0 |
|    1 | RECOVERY  | Completed | 2023-08-04 10:59:59.931717 | 2023-08-04 11:00:08.709242 |       0 |          0 |          0 |          0 |          0 |             0 |
+------+-----------+-----------+----------------------------+----------------------------+---------+------------+------------+------------+------------+---------------+
7 rows in set (0.00 sec)

(root@node02) > select * from performance_schema.clone_status\G;
*************************** 1. row ***************************
             ID: 1
            PID: 0
          STATE: Completed
     BEGIN_TIME: 2023-08-04 10:58:19.007
       END_TIME: 2023-08-04 11:00:08.709
         SOURCE: 192.168.1.101:3306
    DESTINATION: LOCAL INSTANCE
       ERROR_NO: 0
  ERROR_MESSAGE: 
    BINLOG_FILE: mysql-bin.000006
BINLOG_POSITION: 2001
  GTID_EXECUTED: 
1 row in set (0.00 sec)

(root@node02) > change replication source to \
source_host='192.168.1.101', \
source_log_file='mysql-bin.000006', \
source_log_pos=2001,
get_source_public_key=1;
Query OK, 0 rows affected (0.05 sec)

(root@node02) > start replica user='repl' password='repl';
Query OK, 0 rows affected (0.04 sec)

(root@node02) > show replica status\G;

标签:clone,8.0,rows,04,Plugin,Clone,sec,2023,08
From: https://blog.51cto.com/dbprofessional/7233194

相关文章

  • 【MySQL 8.0】通过mysqlpump实现数据库对象的逻辑备份与恢复
    转储数据库mysqlpump-uroot-p--all-databases>full.sqlmysqlpump-uroot-p--all-databases--exclude-databases=soe>full.sqlmysqlpump-uroot-p--databasestpcc10>tpcc10.sqlmysqlpump-uroot-p--parallel-schemas=4:tpcc10>tpcc10.sql......
  • 【MySQL 8.0】通过mysqlbinlog实现binlog文件的远程同步
    mysqlbinlog会伪装成一个slave,连接master请求指定的binlogfile,master接收到这个请求之后创建一个binlogdump线程推送binlog给伪装的slave。[mysql@node01~]$mysql-uroot-pabcd.1234-hnode01(root@node01)>createuserrepl@'%'identifiedby'repl';QueryOK,0ro......
  • 【MySQL 8.0】部分备份与恢复验证
    [mysql@node01~]$xtrabackup--user=xtrabackup--password=xtrabackup--databases="tpcc10"--backup--target-dir=/home/mysql/backup/partial[mysql@node01~]$scp-rbackup/partial/*node02:/home/mysql/backup/partial[mysql@node01~]$mysqldump......
  • 【MySQL 8.0】物理备份与恢复验证
    [root@node01~]#wgethttps://repo.percona.com/yum/percona-release-latest.noarch.rpm[root@node01~]#rpm-ivhpercona-release-latest.noarch.rpm[root@node01~]#yuminstall-ypercona-xtrabackup-80用户与权限(root@node01)>createuserxtrabackup@'......
  • 【MySQL 8.0】增量备份与恢复验证
    [mysql@node01~]$xtrabackup--user=xtrabackup--password=xtrabackup--backup--target-dir=/home/mysql/backup/base[mysql@node01~]$./tpcc-mysql/tpcc_start-h192.168.1.101-P3306-dtpcc10-utpcc-ptpcc-w10-c10-l120[mysql@node01~]$xtrabac......
  • 主从升级(mysql5.7.39-mysql8.0.25)
    环境:OS:Centos7当前数据库版本:5.7.39(主从目前启用了审计server_audit.so,master_auto_position=1)计划升级的数据库版本:8.0.28升级顺序:先升级从库########################从库机器上的操作######################1.从库机器上安装好新版本的mysql注意端口和socket不能与......
  • 【MySQL 8.0】在 CentOS 7.5 安装 MySQL 8.0
    [root@node01~]#cat>>/etc/hosts<<EOF192.168.1.101node01EOF[root@node01~]#useraddmysql[root@node01~]#echomysql|passwd--stdinmysqlChangingpasswordforusermysql.passwd:allauthenticationtokensupdatedsuccessfully.......
  • eslint-config-prettier和eslint-plugin-prettier有什么关系
    `eslint-config-prettier`和`eslint-plugin-prettier`是用于与ESLint和Prettier集成的两个不同的包。1.`eslint-config-prettier`:这是一个ESLint配置规则的包,它将禁用与Prettier冲突的ESLint规则。使用`eslint-config-prettier`可以确保ESLint规则与Prettier......
  • destoon8.0自媒体类型综合资讯门户模板
     随着时代发展,自媒体资讯适合当前的互联网情形。呕心沥血开发的一套自媒体综合门户网站模板,本模板采用纯手写开发,带会员中心。首页,列表页,内容页,搜索页面精心编写,非常大气,并配移动端。注意:模板目前只用了资讯模块,会员模块,其他模块都禁用了。特色:1、非常适合做资讯门户站。2、首页,......
  • Spring源码搭建导依赖时报错:Failed to apply plugin 'kotlin'.
    原因是kotlin插件的版本与gradle中指定的版本不一致,我的是1.8.0,spring5.3.x版本gradle配置文件指定的kotlin版本是1.5.32,修改成1.8.0......