首页 > 数据库 >mysql_clone

mysql_clone

时间:2023-05-05 13:45:50浏览次数:40  
标签:17 clone mysql sec TIME NULL

  1. How to Install 安装
    Using the INSTALL PLUGIN statement:
    Unix/Linux:
mysql> INSTALL PLUGIN clone SONAME 'mysql_clone.so';

Windows:

mysql> INSTALL PLUGIN clone SONAME 'mysql_clone.dll';

Using the plugin-load option in the MySQL configuration file:
Unix/Linux:

[mysqld]
plugin-load = mysql_clone.so

Windows:

[mysqld]
plugin-load = mysql_clone.dll

Using the plugin-load-add option in the MySQL configuration file:
Unix/Linux:

[mysqld]
plugin-load-add = mysql_clone.so

Windows:

[mysqld]
plugin-load-add = mysql_clone.dll
  1. How to Verify 安装校验
mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS FROM information_schema.PLUGINS WHERE PLUGIN_NAME = 'clone';
+-------------+---------------+
| PLUGIN_NAME | PLUGIN_STATUS |
+-------------+---------------+
| clone | ACTIVE |
+-------------+---------------+
1 row in set (0.00 sec)
  1. How to Create a Local Backup of the Data Directory 新增逻辑备份的目录
mysql> CLONE LOCAL DATA DIRECTORY '/mysql/backup/clone';
Query OK, 0 rows affected (1 min 4.49 sec)
  1. How to Create a Replica 建立复制关系
    4.1 install PLUGIN 安装插件
    4.2 On the recipient, set the clone_valid_donor_list option to include the donor for the cloning operation
mysql> SET GLOBAL clone_valid_donor_list = "10.57.19.100:3306";
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE USER clone_user IDENTIFIED BY "clone_password";
mysql> GRANT CLONE_ADMIN ON *.* to clone_user;

4.3 On the donor, ensure there is a user that is allowed to connect from the recipient host with the BACKUP_ADMIN privilege

mysql> CREATE USER clone_user@'%' IDENTIFIED BY '<password>';
Query OK, 0 rows affected (0.02 sec)

mysql> GRANT BACKUP_ADMIN on *.* TO clone_user@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT SELECT ON performance_schema.* TO clone_user;
mysql> GRANT EXECUTE ON *.* to clone_user;

4.4 Start the clone operation: 开始复制

mysql> CLONE INSTANCE FROM [email protected]:3306 IDENTIFIED BY "clone_password";
Query OK, 0 rows affected (1 min 7.34 sec)

4.5 BASE on GTID 基于GTID

mysql> CHANGE REPLICATION SOURCE TO SOURCE_HOST='<source host of replication>', SOURCE_PORT=<port on source of replication>, SOURCE_SSL=1, SOURCE_AUTO_POSITION=1;
Query OK, 0 rows affected (0.04 sec)

mysql> START REPLICA USER='<replication user>' PASSWORD='<replication password>';
Query OK, 0 rows affected (0.03 sec)

4.6 BASE on Position 基于binlog 位置

mysql> SELECT BINLOG_FILE, BINLOG_POSITION FROM performance_schema.clone_status;
+---------------+-----------------+
| BINLOG_FILE | BINLOG_POSITION |
+---------------+-----------------+
| binlog.000004 | 761 |
+---------------+-----------------+
1 row in set (0.00 sec)

mysql> CHANGE REPLICATION SOURCE TO SOURCE_HOST='<source host of the clone>', SOURCE_PORT=3306, SOURCE_SSL=1, SOURCE_LOG_FILE='binlog.000004', SOURCE_LOG_POS=761;
Query OK, 0 rows affected (0.04 sec)

mysql> START REPLICA USER='<replication user>' PASSWORD='<replication password>';
Query OK, 0 rows affected (0.03 sec)

4.7 BASE on MGR 基于MGR

mysql> START GROUP_REPLICATION;
Query OK, 0 rows affected (5.65 sec)
  1. How to Monitor 如何监控
    5.1 Clone Tables 表级别的克隆
mysql> SELECT * FROM clone_status\G
*************************** 1. row ***************************
ID: 1
PID: 24
STATE: In Progress
BEGIN_TIME: 2019-07-11 13:05:20.364
END_TIME: NULL
SOURCE: LOCAL INSTANCE
DESTINATION: /mysql/backup/clone/
ERROR_NO: 0
ERROR_MESSAGE:
BINLOG_FILE:
BINLOG_POSITION: 0
GTID_EXECUTED:
1 row in set (0.00 sec)
mysql> SELECT * FROM clone_progress;
+------+-----------+-------------+----------------------------+----------------------------+---------+------------+------------+---------+------------+---------------+
| ID | STAGE | STATE | BEGIN_TIME | END_TIME | THREADS | ESTIMATE | DATA | NETWORK | DATA_SPEED | NETWORK_SPEED |
+------+-----------+-------------+----------------------------+----------------------------+---------+------------+------------+---------+------------+---------------+
| 1 | DROP DATA | Completed | 2019-07-11 13:05:20.364075 | 2019-07-11 13:05:20.364859 | 1 | 0 | 0 | 0 | 0 | 0 |
| 1 | FILE COPY | In Progress | 2019-07-11 13:05:20.364962 | NULL | 1 | 2759120174 | 1696830766 | 0 | 414269680 | 0 |
| 1 | PAGE COPY | Not Started | NULL | NULL | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | REDO COPY | Not Started | NULL | NULL | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | FILE SYNC | Not Started | NULL | NULL | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | RESTART | Not Started | NULL | NULL | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | RECOVERY | Not Started | NULL | NULL | 0 | 0 | 0 | 0 | 0 | 0 |
+------+-----------+-------------+----------------------------+----------------------------+---------+------------+------------+---------+------------+---------------+
7 rows in set (0.00 sec)


mysql> select STAGE, STATE, CAST(BEGIN_TIME AS TIME) as "START TIME",
CASE WHEN END_TIME IS NULL THEN
LPAD(sys.format_time(POWER(10,12) * (UNIX_TIMESTAMP(now()) - UNIX_TIMESTAMP(BEGIN_TIME))), 10, ' ')
ELSE
LPAD(sys.format_time(POWER(10,12) * (UNIX_TIMESTAMP(END_TIME) - UNIX_TIMESTAMP(BEGIN_TIME))), 10, ' ')
END as DURATION,
LPAD(CONCAT(FORMAT(ROUND(ESTIMATE/1024/1024,0), 0), " MB"), 16, ' ') as "Estimate",
CASE WHEN BEGIN_TIME IS NULL THEN LPAD('0%', 7, ' ')
WHEN ESTIMATE > 0 THEN
LPAD(CONCAT(CAST(ROUND(DATA*100/ESTIMATE, 0) AS BINARY), "%"), 7, ' ')
WHEN END_TIME IS NULL THEN LPAD('0%', 7, ' ')
ELSE LPAD('100%', 7, ' ') END as "Done(%)"
from performance_schema.clone_progress;

+-----------+-------------+------------+------------+-----------+---------+
| STAGE | STATE | START TIME | DURATION | Estimate | Done(%) |
+-----------+-------------+------------+------------+-----------+---------+
| DROP DATA | Completed | 17:23:26 | 790.86 ms | 0 MB | 100% |
| FILE COPY | In Progress | 17:23:27 | 4.85 m | 94,729 MB | 47% |
| PAGE COPY | Not Started | NULL | NULL | 0 MB | 0% |
| REDO COPY | Not Started | NULL | NULL | 0 MB | 0% |
| FILE SYNC | Not Started | NULL | NULL | 0 MB | 0% |
| RESTART | Not Started | NULL | NULL | 0 MB | 0% |
| RECOVERY | Not Started | NULL | NULL | 0 MB | 0% |
+-----------+-------------+------------+------------+-----------+---------+


mysql> select STAGE, STATE, CAST(BEGIN_TIME AS DATETIME) as "START TIME",
CAST(END_TIME AS DATETIME) as "FINISH TIME",
LPAD(sys.format_time(POWER(10,12) * (UNIX_TIMESTAMP(END_TIME) - UNIX_TIMESTAMP(BEGIN_TIME))), 10, ' ')
as DURATION
from performance_schema.clone_progress;
select STAGE, STATE, CAST(BEGIN_TIME AS TIME) as "START TIME",
CAST(END_TIME AS TIME) as "FINISH TIME",
LPAD(sys.format_time(POWER(10,12) * (UNIX_TIMESTAMP(END_TIME) - UNIX_TIMESTAMP(BEGIN_TIME))), 10, ' ')
as DURATION
from performance_schema.clone_progress;

+-----------+-----------+------------+-------------+------------+
| STAGE | STATE | START TIME | FINISH TIME | DURATION |
+-----------+-----------+------------+-------------+------------+
| DROP DATA | Completed | 17:23:26 | 17:23:27 | 790.86 ms |
| FILE COPY | Completed | 17:23:27 | 17:33:47 | 10.33 m |
| PAGE COPY | Completed | 17:33:47 | 17:34:03 | 15.91 s |
| REDO COPY | Completed | 17:34:03 | 17:34:04 | 1.07 s |
| FILE SYNC | Completed | 17:34:04 | 17:35:32 | 1.46 m |
| RESTART | Completed | 17:35:32 | 17:35:40 | 7.77 s |
| RECOVERY | Completed | 17:35:40 | 17:40:27 | 4.79 m |
+-----------+-----------+------------+-------------+------------+

5.2 Memory Usage 内存使用

mysql> SELECT * FROM memory_summary_global_by_event_name WHERE EVENT_NAME IN ('memory/innodb/clone', 'memory/clone/data')\G
*************************** 1. row ***************************
EVENT_NAME: memory/clone/data
COUNT_ALLOC: 8
COUNT_FREE: 8
SUM_NUMBER_OF_BYTES_ALLOC: 33587200
SUM_NUMBER_OF_BYTES_FREE: 33587200
LOW_COUNT_USED: 0
CURRENT_COUNT_USED: 0
HIGH_COUNT_USED: 1
LOW_NUMBER_OF_BYTES_USED: 0
CURRENT_NUMBER_OF_BYTES_USED: 0
HIGH_NUMBER_OF_BYTES_USED: 4198400
*************************** 2. row ***************************
EVENT_NAME: memory/innodb/clone
COUNT_ALLOC: 93
COUNT_FREE: 88
SUM_NUMBER_OF_BYTES_ALLOC: 470920
SUM_NUMBER_OF_BYTES_FREE: 450208
LOW_COUNT_USED: 0
CURRENT_COUNT_USED: 5
HIGH_COUNT_USED: 5
LOW_NUMBER_OF_BYTES_USED: 0
CURRENT_NUMBER_OF_BYTES_USED: 20712
HIGH_NUMBER_OF_BYTES_USED: 20712
2 rows in set (0.01 sec)

mysql> SELECT * FROM sys.memory_global_by_current_bytes WHERE event_name IN ('memory/innodb/clone', 'memory/clone/data');
+---------------------+---------------+---------------+-------------------+------------+------------+----------------+
| event_name | current_count | current_alloc | current_avg_alloc | high_count | high_alloc | high_avg_alloc |
+---------------------+---------------+---------------+-------------------+------------+------------+----------------+
| memory/innodb/clone | 5 | 20.23 KiB | 4.05 KiB | 5 | 20.23 KiB | 4.05 KiB |
+---------------------+---------------+---------------+-------------------+------------+------------+----------------+
1 row in set (0.00 sec)

标签:17,clone,mysql,sec,TIME,NULL
From: https://www.cnblogs.com/Miac/p/17373867.html

相关文章

  • MySQL 元数据
    MySQL元数据你可能想知道MySQL以下三种信息:查询结果信息: SELECT,UPDATE或DELETE语句影响的记录数。数据库和数据表的信息: 包含了数据库及数据表的结构信息。MySQL服务器信息: 包含了数据库服务器的当前状态,版本号等。在MySQL的命令提示符中,我们可以很容易的获取以上......
  • MySQL数据库基础
    MYSQL数据库基础Mysql的基础操作mysql概述启动和停止:在运行窗口中输入"services.msc"进入本地服务窗口,找到MySQL80右键关闭或启动.在命令行中输入(以管理员身份运行)netstartmysql80 启动netstopmysql80停止客户端的连接MySQL提供的客户端命令......
  • MySQL 删除数据库
    MySQL删除数据库使用普通用户登陆MySQL服务器,你可能需要特定的权限来创建或者删除MySQL数据库,所以我们这边使用root用户登录,root用户拥有最高权限。在删除数据库过程中,务必要十分谨慎,因为在执行删除命令后,所有数据将会消失。drop命令删除数据库drop命令格式:dropd......
  • 23、MySQL压力测试及mysql如何在生产中配置主配置文件
    MySQL压力测试及mysql如何在生产中配置主配置文件测试工具mysqlslap跟上选项#mysql自带mysqlslap-a-uroot-p123456#单线程测试mysqlslap-a-c100-uroot-p123456#多线程并发测试(模拟100个客户端并发连接)mysqlslap-a--concurrency=50,100--number-o......
  • mysql event事件
    检查事件调度程序SHOWVARIABLESLIKE'event_scheduler';#如果返回值为ON,则表示事件调度程序已启用。如果返回值为OFF,则需要使用以下命令启用SETGLOBALevent_scheduler=ON;查询事件SHOWEVENTS;查看事件定义SHOWCREATEEVENTevent_name;创建事件CRE......
  • mysql TRIGGER 触发器
    确定触发器的触发事件,可以是INSERT、UPDATE或DELETE操作。确定触发器的执行时间,可以是BEFORE(前)或AFTER(后)。确定触发器要绑定的表名和触发事件(即INSERT、UPDATE或DELETE)。编写触发器的触发操作,可以是任何合法的SQL语句。使用CREATETRIGGER语句创建触发器,指定触......
  • ubuntu18.04 安装docker、mysql、nacos
    一、安装docker1.更新软件源列表sudoapt-getupdate2.安装软件包依赖sudoaptinstallapt-transport-httpsca-certificatescurlsoftware-properties-common3.在系统中添加Docker的官方密钥curl-fsSLhttps://download.docker.com/linux/ubuntu/gpg|sudoapt-ke......
  • MySQL存储引擎
    介绍MySQL提供了多个不同的存储引擎,包括处理事务安全表的引擎和处理非事务安全表的引擎。可以使用''SHOWENGINES;''命令查看当前版本的MySQL所支持的引擎类型,如MySQL8支持的存储引擎有InnoDB、MyISAM、Memory、Merge、Archive、CSV、BLACKHOLE等。存储引擎描述AR......
  • 14、MySQL复制延迟原因及解决办法
    复制延迟原因:写入速度超过了复制速度解决办法:1、升级到mysql5.7以上版本,开启GTID功能,主库可以并发事务,支持并发传输及并行多个SQL线程2、减少大事务,将大事务拆分成小事务减少锁(和开发相关)3、sync_binlog=1加快binlog更新时间,从而加快日志复制只要事务一提交,立即写日志(默认......
  • 【MySQL–07】内置函数
    【MySQL--07】内置函数1.函数1.1日期函数函数名称描述current_data()当前日期current_time()当前时间current_timestamp()当前时间戳date(datetime)返回datetume参数的日期部分date_add(date,intervald_value_type)在date中添加日期时间interval后......