首页 > 数据库 >MySQL详细解析之Clone插件

MySQL详细解析之Clone插件

时间:2023-10-04 21:32:38浏览次数:35  
标签:10 插件 克隆 clone MySQL 2023 sec mysql Clone

文档课题:MySQL详细解析之Clone插件.
系统:rhel 7.3
数据库:MySQL 8.0.27
1、理论知识
从MySQL 8.0.17开始引入Clone插件,克隆插件允许从本地或远程MySQL Server克隆数据.克隆的数据存储在InnoDB中的schema(database)、table(表)、tablespaces(表空间)和data dictionary metadata(数据字典元数据)的物理快照.该物理快照实际上是一个功能完整的数据目录,MySQL克隆插件可以使用该数据目录恢复MySQL Server.
本地克隆:指将数据从启动克隆操作的MySQL Server克隆到该MySQL Server上另一个指定的目录下.
远程克隆:涉及到启动克隆操作的本地MySQL Server(称为"recipient",即数据接收方)和数据源所在的远程MySQL Server(称为"donor",即数据提供方).在接收方上启动远程克隆操作时,克隆的数据会通过网络从发送方传输到接收方.默认情况下远程克隆操作会删除接收方数据目录中的所有数据,并将其替换为克隆的新数据.如果不希望接收方中的现有数据被删除,可以在执行克隆操作时将克隆数据指定存放在接收方中其他目录中.
对于克隆的数据本身来说,本地克隆与远程克隆操作没太大区别,克隆插件支持在复制拓扑中使用.除克隆数据外,克隆操作还能够从发送方中提取和传输复制坐标(二进制日志的位置),并将其应用于接收方,也就是说可以使用克隆插件在组复制中添加新的组成员,也可以在主从复制拓扑中添加新从库.与通过二进制日志来复制大量事务相比,通过克隆插件要快得多,效率也更高.组复制成员还可以使用克隆插件作为另一种恢复方法(如果不使用克隆插件,则必须使用基于二进制日志的传输方式进行数据恢复),克隆插件支持克隆数据加密的和数据页压缩.

2、安装Clone插件
使用克隆技术须先进行安装和配置Clone插件mysql_clone.so,以下采用两种方法安装.
2.1、install安装
使用install plugin安装,并将插件注册到mysql.plugin系统表中.
(root@Slave01) [fruitsDB]> select version();
+-----------+
| version() |
+-----------+
| 8.0.27    |
+-----------+
1 row in set (0.00 sec)

(root@Slave01) [fruitsDB]> show variables like '%read_only%';
+-----------------------+-------+
| Variable_name         | Value |
+-----------------------+-------+
| innodb_read_only      | OFF   |
| read_only             | ON    |
| super_read_only       | ON    |
| transaction_read_only | OFF   |
+-----------------------+-------+
4 rows in set (0.00 sec)

(root@Slave01) [fruitsDB]> set global super_read_only=off;
Query OK, 0 rows affected (0.00 sec)

(root@Slave01) [fruitsDB]> show plugins;
+---------------------------------+----------+--------------------+----------------------+---------+
| Name                            | Status   | Type               | Library              | License |
+---------------------------------+----------+--------------------+----------------------+---------+
……
| group_replication               | ACTIVE   | GROUP REPLICATION  | group_replication.so | GPL     |
+---------------------------------+----------+--------------------+----------------------+---------+
46 rows in set (0.00 sec)

(root@Slave01) [fruitsDB]> install plugin clone soname 'mysql_clone.so';
Query OK, 0 rows affected (0.01 sec)

(root@Slave01) [fruitsDB]> set global super_read_only=on;
Query OK, 0 rows affected (0.00 sec)

(root@Slave01) [fruitsDB]> 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)

(root@Slave01) [fruitsDB]> show plugins;
+---------------------------------+----------+--------------------+----------------------+---------+
| Name                            | Status   | Type               | Library              | License |
+---------------------------------+----------+--------------------+----------------------+---------+
……
| group_replication               | ACTIVE   | GROUP REPLICATION  | group_replication.so | GPL     |
| clone                           | ACTIVE   | CLONE              | mysql_clone.so       | GPL     |
+---------------------------------+----------+--------------------+----------------------+---------+
47 rows in set (0.01 sec)
说明:如上所示,成功安装clone插件.

2.2、修改配置文件
MySQL数据库的插件默认放在系统变量plugin_dir对应的目录中,在MySQL服务器启动时使用--plugin-load-add选项加载该插件,但该方法需每次启动服务器都需要指定对应的选项,可以将其配置到my.cnf文件中.
$ vi /etc/my.cnf
在[mysqld]添加如下:
plugin-load-add=mysql_clone.so

--重启数据库
# systemctl restart mysqld
Clone[(none)]> show plugins;
+---------------------------------+----------+--------------------+----------------------+---------+
| Name                            | Status   | Type               | Library              | License |
+---------------------------------+----------+--------------------+----------------------+---------+
……
| mysqlx                          | ACTIVE   | DAEMON             | NULL                 | GPL     |
| clone                           | ACTIVE   | CLONE              | mysql_clone.so       | GPL     |
| group_replication               | ACTIVE   | GROUP REPLICATION  | group_replication.so | GPL     |
+---------------------------------+----------+--------------------+----------------------+---------+
47 rows in set (0.00 sec)

说明:如上所示,重启数据库后,查看plugins发现已成功安装插件mysql_clone.so.

3、Clone数据库
3.1、本地克隆数据
本地克隆数据是将MySQL数据目录克隆到另一个目录,语法如下:
clone local data directory= 'path';
说明:执行以上语句,对应的用户需有backup_admin权限,且用户创建的文件或表空间必须在数据目录中,克隆的目录需为绝对路径.此处在主机名为leo-827mgr-slave01的服务器进行测试.
3.1.1、创建用户
--主库创建clone用户.
(root@Master) [fruitsDB] > select version();
+-----------+
| version() |
+-----------+
| 8.0.27    |
+-----------+
1 row in set (0.00 sec)

(root@Master) [fruitsDB] 18:25:45> create user clone_admin identified by 'clone@12345';
Query OK, 0 rows affected (0.01 sec)

(root@Master) [fruitsDB] 18:25:51> grant backup_admin on *.* to clone_admin;
Query OK, 0 rows affected (0.00 sec)

(root@Master) [fruitsDB] 18:25:56> flush privileges;
Query OK, 0 rows affected (0.00 sec)


(root@Master) [fruitsDB] 20:33:48> select user,host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| clone_admin      | %         |
| repl             | %         |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
6 rows in set (0.00 sec)

3.1.2、克隆数据库
--创建目录
[mysql@leo-827mgr-slave01 ~]$ mkdir -p /mysql/clone/
(root@Slave01) [fruitsDB]> show databases;
+--------------------+
| Database           |
+--------------------+
| fruitsDB           |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)

[mysql@leo-827mgr-slave02 ~]$ mysql -uclone_admin -pclone@12345
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 8.0.27 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

(clone_admin@Slave01) [(none)]> clone local data directory='/mysql/clone/data';
Query OK, 0 rows affected (1.29 sec)

--查克隆状态
(root@Slave01) [fruitsDB]> select stage,state,end_time from performance_schema.clone_progress;
+-----------+-------------+----------------------------+
| stage     | state       | end_time                   |
+-----------+-------------+----------------------------+
| DROP DATA | Completed   | 2023-10-04 10:30:38.894261 |
| FILE COPY | Completed   | 2023-10-04 10:30:39.114664 |
| PAGE COPY | Completed   | 2023-10-04 10:30:39.130879 |
| REDO COPY | Completed   | 2023-10-04 10:30:39.135704 |
| FILE SYNC | Completed   | 2023-10-04 10:30:40.074355 |
| RESTART   | Not Started | NULL                       |
| RECOVERY  | Not Started | NULL                       |
+-----------+-------------+----------------------------+
7 rows in set (0.00 sec)

--查执行克隆命令后的文件
[mysql@leo-827mgr-slave01 data]$ pwd
/mysql/clone/data
[mysql@leo-827mgr-slave01 data]$ ll
total 167944
drwxr-x---. 2 mysql mysql       89 Oct  4 10:30 #clone
drwxr-x---. 2 mysql mysql       24 Oct  4 10:30 fruitsDB
-rw-r-----. 1 mysql mysql     4648 Oct  4 10:30 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Oct  4 10:30 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Oct  4 10:30 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Oct  4 10:30 ib_logfile1
drwxr-x---. 2 mysql mysql        6 Oct  4 10:30 mysql
-rw-r-----. 1 mysql mysql 25165824 Oct  4 10:30 mysql.ibd
drwxr-x---. 2 mysql mysql       28 Oct  4 10:30 sys
-rw-r-----. 1 mysql mysql 16777216 Oct  4 10:30 undo_001
-rw-r-----. 1 mysql mysql 16777216 Oct  4 10:30 undo_002   

说明:
a、业务库fruitsDB以及系统库sys、mysql会被克隆.注意:空库、information_schema、performance_schema不会被克隆;
b、克隆命令中/mysql/clone/data目录的data为自动生成.

3.1.3、使用克隆数据恢复
--现使用克隆的目录启动数据库,先关闭mysql数据库.
[mysql@leo-827mgr-slave01 data]$ ps -ef | grep mysql
mysql     14052      1  0 Oct02 pts/0    00:00:00 /bin/sh /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin/mysqld_safe --defaults-file=/home/mysql/etc/my.cnf
mysql     14377  14052  3 Oct02 pts/0    01:33:40 /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin/mysqld --defaults-file=/home/mysql/etc/my.cnf --basedir=/opt/mysql --datadir=/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/opt/logs/mysql_error.log --pid-file=/mysql/data/mysql.pid --socket=/mysql/data/mysql.sock --port=3306
root      14845  10988  0 Oct02 pts/0    00:00:00 su - mysql
mysql     14846  14845  0 Oct02 pts/0    00:00:00 -bash
mysql     14888  14846  0 Oct02 pts/0    00:00:00 mysql -uroot -p
root      40064  40026  0 10:20 pts/1    00:00:00 su - mysql
mysql     40065  40064  0 10:20 pts/1    00:00:00 -bash
mysql     41950  40065  0 13:24 pts/1    00:00:00 ps -ef
mysql     41951  40065  0 13:24 pts/1    00:00:00 grep --color=auto mysql
[mysql@leo-827mgr-slave01 data]$ kill -9 14052 14377

--将clone数据恢复到原目录
[mysql@leo-827mgr-slave01 data]$ cd ..
[mysql@leo-827mgr-slave01 mysql]$ mv /mysql/data /mysql/databak
[mysql@leo-827mgr-slave01 mysql]$ mv clone/data .
[mysql@leo-827mgr-slave01 mysql]$ ll data
total 167944
drwxr-x---. 2 mysql mysql       89 Oct  4 10:30 #clone
drwxr-x---. 2 mysql mysql       24 Oct  4 10:30 fruitsDB
-rw-r-----. 1 mysql mysql     4648 Oct  4 10:30 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Oct  4 10:30 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Oct  4 10:30 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Oct  4 10:30 ib_logfile1
drwxr-x---. 2 mysql mysql        6 Oct  4 10:30 mysql
-rw-r-----. 1 mysql mysql 25165824 Oct  4 10:30 mysql.ibd
drwxr-x---. 2 mysql mysql       28 Oct  4 10:30 sys
-rw-r-----. 1 mysql mysql 16777216 Oct  4 10:30 undo_001
-rw-r-----. 1 mysql mysql 16777216 Oct  4 10:30 undo_002

--启动数据库
[mysql@leo-827mgr-slave01 mysql]$ mysqld_safe --defaults-file=/home/mysql/etc/my.cnf &
[1] 42128
[mysql@leo-827mgr-slave01 mysql]$ 2023-10-04T05:41:49.222267Z mysqld_safe Logging to '/opt/logs/mysql_error.log'.
2023-10-04T05:41:49.252184Z mysqld_safe Starting mysqld daemon with databases from /mysql/data

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| fruitsDB           |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)

mysql> use fruitsDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+--------------------+
| Tables_in_fruitsDB |
+--------------------+
| fruits             |
+--------------------+
1 row in set (0.00 sec)

mysql> select * from fruits;
+------+------+------------+---------+
| f_id | s_id | f_name     | f_price |
+------+------+------------+---------+
| a1   |  101 | apple      |    5.20 |
| a2   |  103 | apricot    |    2.20 |
| b1   |  101 | blackberry |   10.20 |
| b2   |  104 | berry      |    7.60 |
| b5   |  107 | xxxx       |    3.60 |
| bs1  |  102 | orange     |   11.20 |
| bs2  |  105 | melon      |    8.20 |
| c0   |  101 | cherry     |    3.20 |
| l2   |  104 | lemon      |    6.40 |
| m1   |  106 | mango      |   15.70 |
| m2   |  105 | xbabay     |    2.60 |
| m3   |  105 | xxtt       |   11.60 |
| o2   |  103 | coconut    |    9.20 |
| t1   |  102 | banana     |   10.30 |
| t2   |  102 | grape      |    5.30 |
| t4   |  107 | xbababa    |    3.60 |
+------+------+------------+---------+
16 rows in set (0.00 sec)

说明:如上所示,成功开启数据库.

3.2、远程克隆
说明:远程克隆中源端称为捐赠者,目标端称为接收者.此处用上面主机名为leo-827mgr-slave01,IP 为192.168.133.127作为捐赠者,主机名为leo-827mgr-slave02,IP 为192.168.133.128作为接收者.
注意:如下操作在leo-827mgr-slave02上执行.

3.2.1、安装插件
(root@Slave02) [(none)]> install plugin clone soname 'mysql_clone.so';
Query OK, 0 rows affected (0.01 sec)

3.2.2、创建克隆账号
说明:此处克隆账号需要clone_admin权限,此权限比捐赠者上的克隆账号多了shutdown权限,克隆完后需要重启数据库,所以非mysqld_safe启动数据库的方式会报错,但不影响克隆,手动启动数据库即可.
(root@Slave02) [(none)]> select user,host from mysql.user;
+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+
4 rows in set (0.01 sec)

(root@Slave02) [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

(root@Slave02) [(none)]> create user clone_admin identified by 'clone@12345';
Query OK, 0 rows affected (0.02 sec)

(root@Slave02) [(none)]> grant clone_admin on *.* to clone_admin;
Query OK, 0 rows affected (0.01 sec)

3.2.3、捐赠者清单
--设置捐赠者列表清单
(root@Slave02) [(none)]> set global clone_valid_donor_list='192.168.133.127:3306';
Query OK, 0 rows affected (0.00 sec)

3.2.4、远程克隆
--用clone账号远程克隆
[mysql@leo-827mgr-slave02 ~]$ mysql -uclone_admin -pclone@12345           
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.27 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

(clone_admin@Slave02) [(none)]> clone instance from clone_admin@'192.168.133.127':3306 identified by 'clone@12345';
Query OK, 0 rows affected (1.40 sec)

(clone_admin@Slave02) [(none)]> Restarting mysqld...
2023-10-04T09:46:03.926053Z mysqld_safe Number of processes running now: 0
2023-10-04T09:46:03.931154Z mysqld_safe mysqld restarted

3.2.5、相关查询
--查克隆详细过程
(clone_admin@Slave02) [fruitsDB]> 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,
    ->      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(round(data*100/estimate, 0), "%"), 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          | FINISH TIME         | DURATION   | Estimate         | Done(%) |
+-----------+-----------+---------------------+---------------------+------------+------------------+---------+
| DROP DATA | Completed | 2023-10-04 17:45:58 | 2023-10-04 17:45:58 |  178.15 ms |              0MB |    100% |
| FILE COPY | Completed | 2023-10-04 17:45:58 | 2023-10-04 17:45:59 |  369.94 ms |             68MB |    100% |
| PAGE COPY | Completed | 2023-10-04 17:45:59 | 2023-10-04 17:45:59 |   30.94 ms |              0MB |    100% |
| REDO COPY | Completed | 2023-10-04 17:45:59 | 2023-10-04 17:45:59 |   30.11 ms |              0MB |    100% |
| FILE SYNC | Completed | 2023-10-04 17:45:59 | 2023-10-04 17:45:59 |  639.26 ms |              0MB |    100% |
| RESTART   | Completed | 2023-10-04 17:45:59 | 2023-10-04 17:46:04 |     4.76 s |              0MB |    100% |
| RECOVERY  | Completed | 2023-10-04 17:46:04 | 2023-10-04 17:46:05 |  857.84 ms |              0MB |    100% |
+-----------+-----------+---------------------+---------------------+------------+------------------+---------+
7 rows in set (0.00 sec)

--查克隆次数
只能看本地克隆次数,该命令记录clone命令执行次数.远程克隆时在接收者上执行,clone成功后服务重启,该值会被置零.
(root@Slave02) [fruitsDB]> show global status like 'Com_clone';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_clone     | 0     |
+---------------+-------+
1 row in set (0.00 sec)

--查看克隆过程状态及错误
(root@Slave02) [fruitsDB]> select state,error_no,error_message from performance_schema.clone_status;
+-----------+----------+---------------+
| state     | error_no | error_message |
+-----------+----------+---------------+
| Completed |        0 |               |
+-----------+----------+---------------+
1 row in set (0.00 sec)

后台日志:
2023-10-04T09:45:58.186492Z 9 [Warning] [MY-013460] [InnoDB] Clone removing all user data for provisioning: Started
2023-10-04T09:45:58.353305Z 9 [Warning] [MY-013460] [InnoDB] Clone removing all user data for provisioning: Finished
2023-10-04T09:46:01.446024Z 0 [Warning] [MY-010909] [Server] /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin/mysqld: Forcing close of thread 9  user: 'clone_admin'.
2023-10-04T09:46:03.203307Z 0 [System] [MY-010910] [Server] /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin/mysqld: Shutdown complete (mysqld 8.0.27)  MySQL Community Server - GPL.
2023-10-04T09:46:03.926053Z mysqld_safe Number of processes running now: 0
2023-10-04T09:46:03.931154Z mysqld_safe mysqld restarted
2023-10-04T09:46:03.946889Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8161)
2023-10-04T09:46:03.946899Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 431 (requested 4000)
2023-10-04T09:46:04.180216Z 0 [System] [MY-010116] [Server] /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin/mysqld (mysqld 8.0.27) starting as process 6203
2023-10-04T09:46:04.180289Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file '/opt/mysql/share/errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2023-10-04T09:46:04.193890Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-10-04T09:46:05.059547Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2023-10-04T09:46:05.351777Z 0 [ERROR] [MY-011685] [Repl] Plugin group_replication reported: 'The group_replication_group_name option is mandatory'
2023-10-04T09:46:05.351828Z 0 [ERROR] [MY-011660] [Repl] Plugin group_replication reported: 'Unable to start Group Replication on boot'
2023-10-04T09:46:05.503386Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2023-10-04T09:46:05.503429Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2023-10-04T09:46:05.504920Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2023-10-04T09:46:05.505004Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2023-10-04T09:46:05.532142Z 0 [Warning] [MY-010604] [Repl] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use '--relay-log=leo-827mgr-slave02-relay-bin' to avoid this problem.
2023-10-04T09:46:05.583868Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
2023-10-04T09:46:05.583933Z 0 [System] [MY-010931] [Server] /opt/mysql-8.0.27-linux-glibc2.17-x86_64-minimal/bin/mysqld: ready for connections. Version: '8.0.27'  socket: '/mysql/data/mysql.sock'  port: 3306  MySQL Community Server - GPL.

3.2.6、远程克隆后查询
--退出重连查看数据
(root@Slave02) [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| fruitsDB           |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)

(root@Slave02) [(none)]> use fruitsDB;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
(root@Slave02) [fruitsDB]> show tables;
+--------------------+
| Tables_in_fruitsDB |
+--------------------+
| fruits             |
+--------------------+
1 row in set (0.00 sec)

(root@Slave02) [fruitsDB]> select * from fruits;
+------+------+------------+---------+
| f_id | s_id | f_name     | f_price |
+------+------+------------+---------+
| a1   |  101 | apple      |    5.20 |
| a2   |  103 | apricot    |    2.20 |
| b1   |  101 | blackberry |   10.20 |
| b2   |  104 | berry      |    7.60 |
| b5   |  107 | xxxx       |    3.60 |
| bs1  |  102 | orange     |   11.20 |
| bs2  |  105 | melon      |    8.20 |
| c0   |  101 | cherry     |    3.20 |
| l2   |  104 | lemon      |    6.40 |
| m1   |  106 | mango      |   15.70 |
| m2   |  105 | xbabay     |    2.60 |
| m3   |  105 | xxtt       |   11.60 |
| o2   |  103 | coconut    |    9.20 |
| t1   |  102 | banana     |   10.30 |
| t2   |  102 | grape      |    5.30 |
| t4   |  107 | xbababa    |    3.60 |
+------+------+------------+---------+
16 rows in set (0.00 sec)
说明:如上所示,执行远程克隆后,数据库fruitsDB成功在远程主机上恢复.

参考网址:https://www.cnblogs.com/---wunian/p/12806418.html

标签:10,插件,克隆,clone,MySQL,2023,sec,mysql,Clone
From: https://blog.51cto.com/u_12991611/7706777

相关文章

  • MySQL思维导图:MySQL的架构介绍
    MySQL的架构介绍(思维导图形式)MySQL简介概述MySQL是一种关系型数据库管理系统,关系数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。高级MySQLMySQL内核sql优化攻城狮MySQL服务器的优化各种参数常量设定查询语句优化主......
  • Mysql
    目录命令行DQL执行顺序函数字符串函数数值函数日期函数流程函数命令行selectdatabase();--查看当前的使用的数据库usestudent;--选择一个数据库showtables;--查询当前数据库有哪些表mysql>desc`order`;--查看表结构+--------------+--------------+------+......
  • MySQL数据库多表关联查询
    本文列举数据库的多表关联查询及实际使用,以员工表和部门表作为举例:部门表:dept点击查看创建部门表sqlcreate table `dept`  (  `deptno` int(2) not null,  `dname` varchar(14),  `loc` varchar(13),  primary key (`deptno`));员工表:emp点击查看创建......
  • MySQL学习(3)B+树索引是如何快速查询的
    前言我们已经知道在磁盘中,有很多索引页,这些页并非在物理结构上相连接,而是通过双向链表关联。如果要查找一条数据,需要通过页目录中的槽,通过二分法定位到分组再进行遍历查找。比如下面这样:SELECT[查询列表]FROM表名WHERE条件; 假设表中只有一个页,在查找记录时,可以根据搜......
  • 什么是Mysql的日志
    Mysql日志体系1错误日志​ -默认开启​ 错误日志是MySQL中最重要的日志之一,它记录了当mysqld启动和停止时,以及服务器在运行过程中发生任何严重错误时的相关信息。当数据库出现任何故障导致无法正常使用时,建议首先查看此日志。可通过下面命令查看错误日志的存储位置:s......
  • 简单介绍一下 Mysql 存储引擎
    1入门本文去浅浅的探讨一下mysql数据库的存储引擎。数据库存储引擎是数据库底层软件组件,数据库管理系统使用数据引擎进行创建、查询、更新和删除数据操作。不同的存储引擎提供不同的存储机制、索引技巧、锁定水平等功能,使用不同的存储引擎还可以获得特定的功能。现在许多数......
  • Docker搭建Mysql主从机制
    Mysql主从复制1基础准备由于家境贫寒没有那么多的云资源供我操作,只能使用docker进行模拟了。拉取镜像简单得很就先不谈了。直接开整。以下操作基于mysql:5.7进行一主二从配置。2主库配置运行容器dockerrun-p3306:3306--namemysql-slaver-2-eMYSQL_ROOT_PASSWOR......
  • Mysql - 函数
    目录字符串函数数值函数日期函数字符串函数案例:企业员工的工号,统一为5位数,目前不足5位数的全部在前面补0,比如:1号员工的工号应该为00001updateempsetworkno=LPAD(workno,5,'0');效果:需要注意的是workno需要是varchar类型数值函数案例:通过数据库的函数,生成一个6位......
  • IntelliJ IDEA 解决连接MYSQL失败问题
    省流版:mysql-connector-java-8.0.13.jar应该出现在下面三个地方:①web-WEB-INF-lib②Database连接时(一般会自动下载)③apache-tomcat-8.0.32-lib 在自己的项目里找到web-WEB-INF-lib,检查一下有没有驱动包  如果没有mysql-connector-java-8.0.13.jar需要下载一个然后在F......
  • 2.MySQL的基本命令
    netstartmysql数据库重启netstopmysql强行停止数据库服务mysql-uroot-p进入数据库exit退出-u代表用户名,这之间可以用空格,空格也代表一个字符,但是仅对密码有效-p代表密码p后面如果跟空格也会算作一个字符......