暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

mysql 8.0.31 使用clone特性做主从 (6)

原创 jieguo 2022-12-17
713

参考文档:Ⅲ、远程克隆https://www.cnblogs.com/—wunian/p/12806418.html
http://t.zoukankan.com/—wunian-p-12806418.html

长话短说,这个东西可以快速克隆MySQL实例,相关人士测试,效率远胜xtrabackup,另外已经由公司开始用该功能做数据库备份

数据库版本

(root@localhost) [(none)]> select version();
+-----------+
| version() |
+-----------+
| 8.0.19    |
+-----------+
1 row in set (0.00 sec)
测试实例都是新初始化的干净实例
Ⅰ、clone插件安装
在线安装插件

(root@localhost) [(none)]> install plugin clone soname 'mysql_clone.so';
Query OK, 0 rows affected (0.00 sec)
查看插件状态

(root@localhost) [(none)]> 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)
Ⅱ、本地克隆
创建克隆账号

该账号需要backup_admin权限

(root@localhost) [(none)]> create user clone_user identified by '123456';
Query OK, 0 rows affected (0.01 sec)

(root@localhost) [(none)]> grant backup_admin on *.* to clone_user;
Query OK, 0 rows affected (0.01 sec)
创建clone目录

clone目录属主属组设置为启动mysql服务的用户

[root@master data]# ll
total 4
drwxr-xr-x 6 mysql mysql 4096 Apr 20 16:17 mysql
[root@master data]# pwd
/data
[root@master data]# mkdir clone_dir
[root@master data]# chown -R mysql:mysql clone_dir
创建测试数据

(root@localhost) [(none)]> create database t;
Query OK, 1 row affected (0.01 sec)

(root@localhost) [(none)]> create table t.t(id int);
Query OK, 0 rows affected (0.03 sec)

(root@localhost) [(none)]> insert into t.t values(1),(2),(3);
Query OK, 3 rows affected (0.01 sec)
Records: 3  Duplicates: 0  Warnings: 0

(root@localhost) [(none)]> select * from t.t;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.00 sec)
用clone账号登陆做本地克隆

(clone_user@localhost) [(none)]> clone local data directory = '/data/clone_dir/mysql';
Query OK, 0 rows affected (0.24 sec)
启动并检查clone数据目录

[root@master data]# /etc/init.d/mysql.server stop
Shutting down MySQL..                                      [  OK  ]
[root@master data]# mv mysql mysql_bak
[root@master data]# mv clone_dir/mysql .
[root@master data]# ll mysql
total 155672
drwxr-x--- 2 mysql mysql     4096 Apr 20 17:00 #clone
-rw-r----- 1 mysql mysql     5360 Apr 20 17:00 ib_buffer_pool
-rw-r----- 1 mysql mysql 12582912 Apr 20 17:00 ibdata1
-rw-r----- 1 mysql mysql 50331648 Apr 20 17:00 ib_logfile0
-rw-r----- 1 mysql mysql 50331648 Apr 20 17:00 ib_logfile1
drwxr-x--- 2 mysql mysql     4096 Apr 20 17:00 mysql
-rw-r----- 1 mysql mysql 25165824 Apr 20 17:00 mysql.ibd
drwxr-x--- 2 mysql mysql     4096 Apr 20 17:00 sys
drwxr-x--- 2 mysql mysql     4096 Apr 20 17:00 t
-rw-r----- 1 mysql mysql 10485760 Apr 20 17:00 undo_001
-rw-r----- 1 mysql mysql 10485760 Apr 20 17:00 undo_002
[root@master data]# /etc/init.d/mysql.server start
Starting MySQL.Logging to '/data/mysql/error.log'.
.                                                          [  OK  ]
[root@master data]# mysql
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 8
Server version: 8.0.19 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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 'help;' or 'h' for help. Type 'c' to clear the current input statement.

(root@localhost) [(none)]> select * from t.t;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.00 sec)
Ⅲ、远程克隆
远程克隆中,源叫做捐赠者,目标叫做接收者

这里用上面的实例作为捐赠者,下面在接收者上操作

接收者建议保持为空,如果不为空会被清空

在线安装插件

(root@localhost) [(none)]> install plugin clone soname 'mysql_clone.so';
Query OK, 0 rows affected (0.02 sec)
创建克隆账号

这里的克隆账号需要clone_admin权限,这个权限比捐赠者上的克隆账号多了shutdown权限,克隆完后需要重启数据库,所以非mysqld_safe启动则会报错,但不影响克隆,手动重启数据库即可。

(root@localhost) [(none)]> create user clone_user identified by '123456';
Query OK, 0 rows affected (0.01 sec)

(root@localhost) [(none)]> grant clone_admin on *.* to clone_user;
Query OK, 0 rows affected (0.01 sec)
设置捐赠者列表清单

(root@localhost) [(none)]> set global clone_valid_donor_list = '192.168.0.65:3306';
Query OK, 0 rows affected (0.00 sec)
用clone账号登陆做远程克隆

(clone_user@localhost) [(none)]> clone instance from clone_user@'192.168.0.65':3306 identified by '123456';
Query OK, 0 rows affected (1.03 sec)
(clone_user@localhost) [(none)]> show databases;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    8
Current database: *** NONE ***
说明已经重启了
退出重连查看数据

我这里mysqld_safe自动重启了数据库,不需要手动启动数据库

(root@localhost) [(none)]> select * from t.t;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.01 sec)
Ⅳ、捐赠者和接收者创建复制关系
捐赠者上创建复制账号

(root@localhost) [(none)]> create user rpl identified with 'mysql_native_password' by '123';
Query OK, 0 rows affected (0.01 sec)

(root@localhost) [(none)]> grant replication slave on *.* to rpl;
Query OK, 0 rows affected (0.00 sec)
接收者设置主从关系

(root@localhost) [(none)]> change master to master_host = '192.168.0.65',
    -> master_user = 'rpl',
    -> master_password = '123',
    -> master_port = 3306,
    -> master_auto_position = 1;
Query OK, 0 rows affected, 2 warnings (0.05 sec)
启动并检查复制关系

(root@localhost) [(none)]> start slave;
Query OK, 0 rows affected (0.01 sec)

(root@localhost) [(none)]> show slave statusG
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.0.65
                  Master_User: rpl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: binlog.000002
          Read_Master_Log_Pos: 195
               Relay_Log_File: slave1-relay-bin.000002
                Relay_Log_Pos: 363
        Relay_Master_Log_File: binlog.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes
            ...
            
Ⅴ、其他相关小操作
查看克隆过程状态及错误

(root@localhost) [(none)]> 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)
查看克隆步骤

(root@localhost) [(none)]> 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   | 2020-04-21 18:22:44 | 2020-04-21 18:22:44 |  303.87 ms |              0MB |    100% |
| FILE COPY | In Progress | 2020-04-21 18:22:44 | NULL                | NULL       |          3,600MB |     96% |
| PAGE COPY | Not Started | NULL                | NULL                | NULL       |              0MB |      %0 |
| REDO COPY | Not Started | NULL                | NULL                | NULL       |              0MB |      %0 |
| FILE SYNC | Not Started | NULL                | NULL                | NULL       |              0MB |      %0 |
| RESTART   | Not Started | NULL                | NULL                | NULL       |              0MB |      %0 |
| RECOVERY  | Not Started | NULL                | NULL                | NULL       |              0MB |      %0 |
+-----------+-------------+---------------------+---------------------+------------+------------------+---------+
7 rows in set (0.01 sec)

+-----------+-----------+---------------------+---------------------+------------+------------------+---------+
| stage     | state     | START TIME          | FINISH TIME         | DURATION   | Estimate         | Done(%) |
+-----------+-----------+---------------------+---------------------+------------+------------------+---------+
| DROP DATA | Completed | 2020-04-21 18:22:44 | 2020-04-21 18:22:44 |  303.87 ms |              0MB |    100% |
| FILE COPY | Completed | 2020-04-21 18:22:44 | 2020-04-21 18:23:06 |    22.28 s |          3,600MB |    100% |
| PAGE COPY | Completed | 2020-04-21 18:23:06 | 2020-04-21 18:23:08 |     2.01 s |              0MB |    100% |
| REDO COPY | Completed | 2020-04-21 18:23:08 | 2020-04-21 18:23:09 |  300.20 ms |              0MB |    100% |
| FILE SYNC | Completed | 2020-04-21 18:23:09 | 2020-04-21 18:23:09 |  327.89 ms |              0MB |    100% |
| RESTART   | Completed | 2020-04-21 18:23:09 | 2020-04-21 18:23:13 |     3.90 s |              0MB |    100% |
| RECOVERY  | Completed | 2020-04-21 18:23:13 | 2020-04-21 18:23:13 |  482.81 ms |              0MB |    100% |
+-----------+-----------+---------------------+---------------------+------------+------------------+---------+
7 rows in set (0.01 sec)
查看克隆次数

只能看本地克隆次数,该命令记录clone命令执行次数
远程克隆,在接收者上执行,clone成功后服务重启,这个值会被置零

(root@localhost) [(none)]> show global status like 'Com_clone';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_clone     | 1     |
+---------------+-------+
1 row in set (0.00 sec)
停止克隆

直接kill克隆线程即可

主库配置:

*****[2022-12-16 13:43:05]*****
Last login: Fri Dec 16 10:40:19 2022 from 10.168.20.66
[root@mysql1 ~]# mysql -u root -pabcd1234
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.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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.

mysql> create user clone_user identified by '123456';
ERROR 1396 (HY000): Operation CREATE USER failed for 'clone_user'@'%'
mysql> grant clone_admin on *.* to clone_user;
Query OK, 0 rows affected (0.00 sec)

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.01 sec)

mysql> drop user clone_user;
Query OK, 0 rows affected (0.00 sec)

mysql> create user clone_user identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> grant clone_admin on *.* to clone_user;
Query OK, 0 rows affected (0.01 sec)

mysql> drop user clone_user;
Query OK, 0 rows affected (0.00 sec)

mysql> create user clone_user@'%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> grant clone_admin on *.* to clone_user;
Query OK, 0 rows affected (0.00 sec)

mysql> select * from user;
ERROR 1046 (3D000): No database selected
mysql> use mysql;
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> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | clone_user       |
| %         | mysql            |
| %         | root             |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
6 rows in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> drop user clone_user;
Query OK, 0 rows affected (0.00 sec)

mysql> create user clone_user@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> grant backup_admin on *.* to 'clone_user'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> create user rpl identified with 'mysql_native_password' by '123';
Query OK, 0 rows affected (0.00 sec)

mysql> grant replication slave on *.* to rpl;
Query OK, 0 rows affected (0.00 sec)

mysql> 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)

mysql> select binlog_file,binlog_position from performance_schema.clone_status;
+------------------+-----------------+
| binlog_file      | binlog_position |
+------------------+-----------------+
| mysql-bin.000004 |            1292 |
+------------------+-----------------+
1 row in set (0.00 sec)

mysql> select @@global.gtid_executed;
+------------------------+
| @@global.gtid_executed |
+------------------------+
|                        |
+------------------------+
1 row in set (0.00 sec)

mysql> set global   ENFORCE_GTID_CONSISTENCY   = WARN;
Query OK, 0 rows affected (0.00 sec)

mysql> set global ENFORCE_GTID_CONSISTENCY = ON;
Query OK, 0 rows affected (0.00 sec)

mysql> set global GTID_MODE = OFF_PERMISSIVE;
Query OK, 0 rows affected (0.02 sec)

mysql> set global GTID_MODE = ON_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW STATUS LIKE 'ONGOING_ANONYMOUS_TRANSACTION_COUNT';
+-------------------------------------+-------+
| Variable_name                       | Value |
+-------------------------------------+-------+
| Ongoing_anonymous_transaction_count | 0     |
+-------------------------------------+-------+
1 row in set (0.00 sec)

mysql> show slave status\G;
Empty set, 1 warning (0.00 sec)

ERROR: 
No query specified

mysql> set global GTID_MODE = ON;
Query OK, 0 rows affected (0.01 sec)

mysql> show slave status\G
Empty set, 1 warning (0.00 sec)

mysql> show master status\G
*************************** 1. row ***************************
             File: mysql-bin.000004
         Position: 157
     Binlog_Do_DB: 
 Binlog_Ignore_DB: 
Executed_Gtid_Set: 
1 row in set (0.00 sec)

mysql> select binlog_file,binlog_position from performance_schema.clone_status;
+------------------+-----------------+
| binlog_file      | binlog_position |
+------------------+-----------------+
| mysql-bin.000004 |            1292 |
+------------------+-----------------+
1 row in set (0.00 sec)

mysql> create database jyc;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jyc                |
| jycdb              |
| mysql              |
| performance_schema |
| sys                |
| t                  |
+--------------------+
7 rows in set (0.00 sec)

mysql> use jyc;
Database changed
mysql> create table t(id int);
Query OK, 0 rows affected (0.02 sec)

mysql> select * from jyc.t;
Empty set (0.00 sec)

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,
    -> 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 | 2022-12-16 10:53:20 | 2022-12-16 10:53:20 |     189 ms |              0MB |    100% |
| FILE COPY | Completed | 2022-12-16 10:53:20 | 2022-12-16 10:53:20 |  307.61 ms |             68MB |    100% |
| PAGE COPY | Completed | 2022-12-16 10:53:20 | 2022-12-16 10:53:20 |    1.95 ms |              0MB |    100% |
| REDO COPY | Completed | 2022-12-16 10:53:20 | 2022-12-16 10:53:20 |    1.05 ms |              0MB |    100% |
| FILE SYNC | Completed | 2022-12-16 10:53:20 | 2022-12-16 10:53:20 |   409.7 ms |              0MB |    100% |
| RESTART   | Completed | 2022-12-16 10:53:20 | 2022-12-16 10:58:01 |     4.68 m |              0MB |    100% |
| RECOVERY  | Completed | 2022-12-16 10:58:01 | 2022-12-16 10:58:02 |   977.1 ms |              0MB |    100% |
+-----------+-----------+---------------------+---------------------+------------+------------------+---------+
7 rows in set (0.00 sec)

mysql> show global status like 'Com_clone';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_clone     | 0     |
+---------------+-------+
1 row in set (0.01 sec)

mysql> show variables like '%server_uuid%';
+---------------+--------------------------------------+
| Variable_name | Value                                |
+---------------+--------------------------------------+
| server_uuid   | 740dc65b-7ced-11ed-9e87-82b000a4e5ee |
+---------------+--------------------------------------+
1 row in set (0.01 sec)

mysql> exit
Bye
[root@mysql1 ~]# vi /etc/my.cnf
[client]
port=3306
socket=/mysql/mysql.sock
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
port=3306
user=mysql
socket=/mysql/mysql.sock
basedir=/mysql
datadir=/mysql/data
lower-case-table-names=1
default_authentication_plugin=mysql_native_password
innodb_buffer_pool_size=2G
slow_query_log=ON
slow_query_log_file=/mysql/log/slow.log
long_query_time=2
log_queries_not_using_indexes=off
max_connections=1000
innodb_flush_log_at_trx_commit=2
character_set_server=utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
skip-character-set-client-handshake = true
log-bin=/mysql/data/mysql-bin
#general_log = 1
#general_log_file= /mysql/log/mysql.log
#skip-grant-tables
large-pages
gtid_mode = on
enforce_gtid_consistency = on
server-id=1
"/etc/my.cnf" 35L, 796C written
[root@mysql1 ~]# service mysql restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL... SUCCESS! 
[root@mysql1 ~]# mysql -u root -pabcd1234
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.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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.

mysql> use jyc;
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> insert into t values(1);
Query OK, 1 row affected (0.00 sec)

从库配置:

*****[2022-12-16 13:43:14]*****
Last login: Thu Dec 15 15:00:33 2022 from 10.168.20.66
[root@mysql2 ~]# mysql -h 192.168.207.132 -P 3306 -u root -pabcd1234
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 11
Server version: 8.0.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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.

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

mysql> install plugin clone soname 'mysql_clone.so';
Query OK, 0 rows affected (0.02 sec)

mysql> create user clone_user identified by '123456';
Query OK, 0 rows affected (0.02 sec)

mysql> grant clone_admin on *.* to clone_user;
Query OK, 0 rows affected (0.01 sec)

mysql> set global clone_valid_donor_list = '192.168.207.131:3306';
Query OK, 0 rows affected (0.00 sec)

mysql> clone instance from clone_user@'192.168.207.131':3306 identified by '123456';
ERROR 1227 (42000): Access denied; you need (at least one of) the CLONE_ADMIN privilege(s) for this operation
mysql> clone instance from clone_user@'192.168.207.131:3306' identified by '123456';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by '123456'' at line 1
mysql> 
mysql> clone instance from clone_user@'192.168.207.131':3306 identified by '123456';
ERROR 1227 (42000): Access denied; you need (at least one of) the CLONE_ADMIN privilege(s) for this operation
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.01 sec)

mysql> clone instance from clone_user@'192.168.207.131':3306 identified by '123456';
ERROR 1227 (42000): Access denied; you need (at least one of) the CLONE_ADMIN privilege(s) for this operation
mysql> clone instance from clone_user@'192.168.207.131':3306 identified by '123456';
ERROR 1227 (42000): Access denied; you need (at least one of) the CLONE_ADMIN privilege(s) for this operation
mysql> clone instance from clone_user@'192.168.207.131':3306 identified by '123456';
ERROR 1227 (42000): Access denied; you need (at least one of) the CLONE_ADMIN privilege(s) for this operation
mysql> select host,user from user;
ERROR 1046 (3D000): No database selected
mysql> use mysql
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> select host,user from user;
+-----------+------------------+
| host      | user             |
+-----------+------------------+
| %         | clone_user       |
| %         | mysql            |
| %         | root             |
| localhost | mysql.infoschema |
| localhost | mysql.session    |
| localhost | mysql.sys        |
+-----------+------------------+
6 rows in set (0.00 sec)

mysql> clone instance from clone_user@'192.168.207.131':3306 identified by '123456';
ERROR 1227 (42000): Access denied; you need (at least one of) the CLONE_ADMIN privilege(s) for this operation
mysql> drop user clone_user;
Query OK, 0 rows affected (0.01 sec)

mysql> create user 'clone_user'@'%' indetified by '123456';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'indetified by '123456'' at line 1
mysql> create user 'clone_user'@'%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> grant clone_admin on *.* to 'clone_user'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> set global clone_valid_donor_list = '192.168.207.131:3306';
Query OK, 0 rows affected (0.00 sec)

mysql> clone instance from clone_user@'192.168.207.131':3306 identified by '123456';
ERROR 1227 (42000): Access denied; you need (at least one of) the CLONE_ADMIN privilege(s) for this operation
mysql> \q
Bye
[root@mysql2 ~]# mysql -h 192.168.207.132 -P 3306 -u clone_user -p123456
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 12
Server version: 8.0.31

Copyright (c) 2000, 2022, 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.

mysql> set global clone_valid_donor_list = '192.168.207.131:3306';
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id:    13
Current database: *** NONE ***

ERROR 1184 (08S01): Aborted connection 13 to db: 'unconnected' user: 'clone_user' host: '192.168.207.132' (init_connect command failed)
mysql> \q
Bye
[root@mysql2 ~]# mysql -P 3306 -u clone_user -p123456
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 14
Server version: 8.0.31

Copyright (c) 2000, 2022, 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.

mysql> set global clone_valid_donor_list = '192.168.207.131:3306';
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id:    15
Current database: *** NONE ***

ERROR 1184 (08S01): Aborted connection 15 to db: 'unconnected' user: 'clone_user' host: 'localhost' (init_connect command failed)
mysql> \q
Bye
[root@mysql2 ~]# mysql -h 192.168.207.132 -P 3306 -u root -pabcd1234
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 16
Server version: 8.0.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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.

mysql> grant super on *.* to 'clone_user'@'%';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> exit
Bye
[root@mysql2 ~]# mysql -P 3306 -u clone_user -p123456
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 17
Server version: 8.0.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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.

mysql> set global clone_valid_donor_list = '192.168.207.131:3306';
Query OK, 0 rows affected (0.00 sec)

mysql> clone instance from clone_user@'192.168.207.131':3306 identified by '123456';
Query OK, 0 rows affected (2.14 sec)

mysql> show databases;
ERROR 2013 (HY000): Lost connection to MySQL server during query
No connection. Trying to reconnect...
Connection id:    8
Current database: *** NONE ***

ERROR 1184 (08S01): Aborted connection 8 to db: 'unconnected' user: 'clone_user' host: 'localhost' (init_connect command failed)
mysql> \q
Bye
[root@mysql2 ~]# mysql -h 192.168.207.132 -P 3306 -u root -pabcd1234
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.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jycdb              |
| mysql              |
| performance_schema |
| sys                |
| t                  |
+--------------------+
6 rows in set (0.01 sec)

mysql> select * from t.t;
+------+
| id   |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.01 sec)

mysql> 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)

mysql> select binlog_file,binlog_position from performance_schema.clone_status;
+------------------+-----------------+
| binlog_file      | binlog_position |
+------------------+-----------------+
| mysql-bin.000001 |            2600 |
+------------------+-----------------+
1 row in set (0.00 sec)

mysql> select @@global.gtid_executed;
+------------------------+
| @@global.gtid_executed |
+------------------------+
|                        |
+------------------------+
1 row in set (0.00 sec)

mysql> change master to master_host = '192.168.207.131',master_user = 'rpl',master_password = '123',master_port = 3306,master_auto_position = 1;
ERROR 1777 (HY000): CHANGE MASTER TO MASTER_AUTO_POSITION = 1 cannot be executed because @@GLOBAL.GTID_MODE = OFF.
mysql> set global   ENFORCE_GTID_CONSISTENCY   = WARN;
Query OK, 0 rows affected (0.00 sec)

mysql> set global ENFORCE_GTID_CONSISTENCY = ON;
Query OK, 0 rows affected (0.00 sec)

mysql> set global GTID_MODE = OFF_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)

mysql> set global GTID_MODE = ON_PERMISSIVE;
Query OK, 0 rows affected (0.01 sec)

mysql> SHOW STATUS LIKE 'ONGOING_ANONYMOUS_TRANSACTION_COUNT';
+-------------------------------------+-------+
| Variable_name                       | Value |
+-------------------------------------+-------+
| Ongoing_anonymous_transaction_count | 0     |
+-------------------------------------+-------+
1 row in set (0.00 sec)

mysql> show slave status\G;
Empty set, 1 warning (0.00 sec)

ERROR: 
No query specified

mysql> set global GTID_MODE = ON;
Query OK, 0 rows affected (0.01 sec)

mysql> change master to master_host = '192.168.207.131',master_user = 'rpl',master_password = '123',master_port = 3306,master_auto_position = 1;
Query OK, 0 rows affected, 7 warnings (0.04 sec)

mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: 192.168.207.131
                  Master_User: rpl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: 
          Read_Master_Log_Pos: 4
               Relay_Log_File: mysql2-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: 
             Slave_IO_Running: No
            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: 0
              Relay_Log_Space: 157
              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: 13117
                Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
                  Master_UUID: 
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 221216 14:21:03
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                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, 1 warning (0.00 sec)

mysql> show master status\G
*************************** 1. row ***************************
             File: mysql-bin.000005
         Position: 157
     Binlog_Do_DB: 
 Binlog_Ignore_DB: 
Executed_Gtid_Set: 
1 row in set (0.01 sec)

mysql> select binlog_file,binlog_position from performance_schema.clone_status;
+------------------+-----------------+
| binlog_file      | binlog_position |
+------------------+-----------------+
| mysql-bin.000001 |            2600 |
+------------------+-----------------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jycdb              |
| mysql              |
| performance_schema |
| sys                |
| t                  |
+--------------------+
6 rows in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jycdb              |
| mysql              |
| performance_schema |
| sys                |
| t                  |
+--------------------+
6 rows in set (0.00 sec)

mysql> select * from jyc.t;
ERROR 1049 (42000): Unknown database 'jyc'
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,
    -> 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 | 2022-12-16 14:05:45 | 2022-12-16 14:05:45 |  235.28 ms |              0MB |    100% |
| FILE COPY | Completed | 2022-12-16 14:05:45 | 2022-12-16 14:05:46 |     1.37 s |             68MB |    100% |
| PAGE COPY | Completed | 2022-12-16 14:05:46 | 2022-12-16 14:05:46 |    5.49 ms |              0MB |    100% |
| REDO COPY | Completed | 2022-12-16 14:05:46 | 2022-12-16 14:05:46 |    3.63 ms |              0MB |    100% |
| FILE SYNC | Completed | 2022-12-16 14:05:46 | 2022-12-16 14:05:46 |  226.53 ms |              0MB |    100% |
| RESTART   | Completed | 2022-12-16 14:05:46 | 2022-12-16 14:05:51 |     4.09 s |              0MB |    100% |
| RECOVERY  | Completed | 2022-12-16 14:05:51 | 2022-12-16 14:05:52 |     1.19 s |              0MB |    100% |
+-----------+-----------+---------------------+---------------------+------------+------------------+---------+
7 rows in set (0.01 sec)

mysql> show global status like 'Com_clone';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_clone     | 0     |
+---------------+-------+
1 row in set (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: 192.168.207.131
                  Master_User: rpl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: 
          Read_Master_Log_Pos: 4
               Relay_Log_File: mysql2-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: 
             Slave_IO_Running: No
            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: 0
              Relay_Log_Space: 157
              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: 13117
                Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 1
                  Master_UUID: 
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 221216 14:21:03
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                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, 1 warning (0.00 sec)

mysql> show variables like '%server_uuid%';
+---------------+--------------------------------------+
| Variable_name | Value                                |
+---------------+--------------------------------------+
| server_uuid   | d0271cef-7782-11ed-828a-d67f35a9de29 |
+---------------+--------------------------------------+
1 row in set (0.01 sec)

mysql> show variables like '%server%';
+---------------------------------+--------------------------------------+
| Variable_name                   | Value                                |
+---------------------------------+--------------------------------------+
| character_set_server            | utf8mb4                              |
| collation_server                | utf8mb4_unicode_ci                   |
| immediate_server_version        | 999999                               |
| innodb_dedicated_server         | OFF                                  |
| innodb_ft_server_stopword_table |                                      |
| original_server_version         | 999999                               |
| server_id                       | 1                                    |
| server_id_bits                  | 32                                   |
| server_uuid                     | d0271cef-7782-11ed-828a-d67f35a9de29 |
+---------------------------------+--------------------------------------+
9 rows in set (0.00 sec)

mysql> exit
Bye
[root@mysql2 ~]# vi /etc/my.cnf
[client]
port=3306
socket=/mysql/mysql.sock
default-character-set = utf8mb4

[mysql]
default-character-set = utf8mb4

[mysqld]
port=3306
user=mysql
socket=/mysql/mysql.sock
basedir=/mysql
datadir=/mysql/data
lower-case-table-names=1
default_authentication_plugin=mysql_native_password
innodb_buffer_pool_size=2G #注意这个大小建议为50%-70%的物理内存即可,总之建议给操作系统留出30%以上的剩余
slow_query_log=ON
slow_query_log_file=/mysql/log/slow.log
long_query_time=2
log_queries_not_using_indexes=off
max_connections=1000
innodb_flush_log_at_trx_commit=2
character_set_server=utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=‘SET NAMES utf8mb4’
skip-character-set-client-handshake = true
log-bin=/mysql/data/mysql-bin
#general_log = 1
#general_log_file= /mysql/log/mysql.log
#skip-grant-tables
#skip-log-bin
skip-name-resolve
gtid_mode = on
enforce_gtid_consistency = on
server-id=2
"/etc/my.cnf" 36L, 929C written
[root@mysql2 ~]# service mysql restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL.. SUCCESS! 
[root@mysql2 ~]# mysql -h 192.168.207.132 -P 3306 -u root -pabcd1234
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 14
Server version: 8.0.31 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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.

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, 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 NULLmysql> from performance_schema.clone_progress;


mysql> show master status\G
*************************** 1. row ***************************
             File: mysql-bin.000006
         Position: 538
     Binlog_Do_DB: 
 Binlog_Ignore_DB: 
Executed_Gtid_Set: 740dc65b-7ced-11ed-9e87-82b000a4e5ee:1-2
1 row in set (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for source to send event
                  Master_Host: 192.168.207.131
                  Master_User: rpl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000005
          Read_Master_Log_Pos: 197
               Relay_Log_File: mysql2-relay-bin.000004
                Relay_Log_Pos: 413
        Relay_Master_Log_File: mysql-bin.000005
             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: 197
              Relay_Log_Space: 1598
              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: 1
                  Master_UUID: 740dc65b-7ced-11ed-9e87-82b000a4e5ee
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Replica 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: 740dc65b-7ced-11ed-9e87-82b000a4e5ee:1-2
            Executed_Gtid_Set: 740dc65b-7ced-11ed-9e87-82b000a4e5ee:1-2
                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, 1 warning (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| jyc                |
| jycdb              |
| mysql              |
| performance_schema |
| sys                |
| t                  |
+--------------------+
7 rows in set (0.01 sec)

mysql> select * from jyc.t;
Empty set (0.00 sec)

mysql> select * from jyc.t;
+------+
| id   |
+------+
|    1 |
+------+
1 row in set (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for source to send event
                  Master_Host: 192.168.207.131
                  Master_User: rpl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000005
          Read_Master_Log_Pos: 467
               Relay_Log_File: mysql2-relay-bin.000004
                Relay_Log_Pos: 683
        Relay_Master_Log_File: mysql-bin.000005
             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: 467
              Relay_Log_Space: 1868
              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: 1
                  Master_UUID: 740dc65b-7ced-11ed-9e87-82b000a4e5ee
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Replica 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: 740dc65b-7ced-11ed-9e87-82b000a4e5ee:1-3
            Executed_Gtid_Set: 740dc65b-7ced-11ed-9e87-82b000a4e5ee:1-3
                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, 1 warning (0.00 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for source to send event
                  Master_Host: 192.168.207.131
                  Master_User: rpl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000005
          Read_Master_Log_Pos: 467
               Relay_Log_File: mysql2-relay-bin.000004
                Relay_Log_Pos: 683
        Relay_Master_Log_File: mysql-bin.000005
             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: 467
              Relay_Log_Space: 1868
              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: 1
                  Master_UUID: 740dc65b-7ced-11ed-9e87-82b000a4e5ee
             Master_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Replica 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: 740dc65b-7ced-11ed-9e87-82b000a4e5ee:1-3
            Executed_Gtid_Set: 740dc65b-7ced-11ed-9e87-82b000a4e5ee:1-3
                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, 1 warning (0.00 sec)


最后修改时间:2022-12-23 11:23:36
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论