有时候我们想使用mtr来创建mgr,可以参看原生自带的测试套件的suite/group_replicaiton
有很多关于mgr创建的例子。这里我们来编写自己的一个文件。
创建自己的套件目录
~/mysql-test/suite/myownmgr
- 创建目录
cd ~/mysql-test/suite/myownmgr
mkdir t r include
- 当前目录编辑my.cnf
# Use default setting for mysqld processes
!include include/default_mysqld.cnf
!include include/default_client.cnf
[mysqld]
log-bin= server-binary-log
relay-log= server-relay-log
enforce-gtid-consistency
gtid-mode= on
report-host= 127.0.0.1
report-user= root
master-retry-count= 10
skip-replica-start
loose-group_replication_start_on_boot= OFF
loose-group_replication_single_primary_mode= FALSE
loose-group_replication_enforce_update_everywhere_checks= TRUE
loose-group_replication_recovery_get_public_key= TRUE
# Directory where slaves find the dumps generated by "load data"
# on the server. The path need to have constant length otherwise
# test results will vary, thus a relative path is used.
replica-load-tmpdir= ../../tmp
loose-innodb_write_io_threads= 1
loose-innodb_read_io_threads= 1
[mysqld.1]
# Run the master.sh script before starting this process
#!run-master-sh
report-port= @mysqld.1.port
[mysqld.2]
# Run the slave.sh script before starting this process
#!run-slave-sh
# Append <testname>-slave.opt file to the list of argument used when
# starting the mysqld
#!use-slave-opt
report-port= @mysqld.2.port
[mysqld.3]
report-port= @mysqld.3.port
[ENV]
MASTER_MYPORT= @mysqld.1.port
MASTER_MYSOCK= @mysqld.1.socket
SLAVE_MYPORT= @mysqld.2.port
SLAVE_MYSOCK= @mysqld.2.socket
SERVER_MYPORT_3= @mysqld.3.port
SERVER_MYSOCK_3= @mysqld.3.socket
# CLUSTER_MODE
# 1: 3 nodes
# 2: 5 nodes
CLUSTER_MODE=1
- 将套件myownmgr的t目录下的创建suite.opt
$GROUP_REPLICATION_OPT --plugin-load=$GROUP_REPLICATION
- 开始编写测例
先在套件myownmgr的include的目录下创建一个setup_cluster.inc
suite/myownmgr/include$ cat setup_cluster.inc
--source include/have_group_replication_plugin.inc
if ($CLUSTER_MODE == 1)
{
--let $rpl_server_count= 3
}
if ($CLUSTER_MODE == 2)
{
--let $rpl_server_count= 5
}
--source include/group_replication.inc
开始编写第一个简单的查看集群创建的3节点状态的测例1st.test
--source suite/myownmgr/include/setup_cluster.inc
SELECT * FROM performance_schema.replication_group_members;
--source include/group_replication_end.inc
1st.result
include/group_replication.inc [rpl_server_count=3]
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[connection server1]
SELECT * FROM performance_schema.replication_group_members;
CHANNEL_NAME MEMBER_ID MEMBER_HOST MEMBER_PORT MEMBER_STATE MEMBER_ROLE MEMBER_VERSION
group_replication_applier c43767ed-f1fd-11ec-8e9c-2cf05daaf63e 127.0.0.1 13000 ONLINE PRIMARY 8.0.26
group_replication_applier c43edcd7-f1fd-11ec-90a9-2cf05daaf63e 127.0.0.1 13002 ONLINE PRIMARY 8.0.26
group_replication_applier c446bb46-f1fd-11ec-8fe0-2cf05daaf63e 127.0.0.1 13004 ONLINE PRIMARY 8.0.26
include/group_replication_end.inc
想创建一个5节点的,但是配置文件就只给某个测试用例,不全部给所有用例
首先在myownmgr的t目录创建配置文件 testname.cnf
创建一个3st.cnf
!include ../my.cnf
[mysqld.4]
report-port= @mysqld.4.port
[mysqld.5]
report-port= @mysqld.5.port
[ENV]
SERVER_MYPORT_4= @mysqld.4.port
SERVER_MYSOCK_4= @mysqld.4.socket
SERVER_MYPORT_5= @mysqld.5.port
SERVER_MYSOCK_5= @mysqld.5.socket
CLUSTER_MODE=2
编写3st.test
--source suite/myownmgr/include/setup_cluster.inc
SELECT * FROM performance_schema.replication_group_members;
--source include/group_replication_end.inc
执行结果3st.result,为5个节点。
great@great-PC:~/mysql_mtr/mysql-8.0.26/mysql-test/suite/myownmgr/r$ cat 3st.result
include/group_replication.inc [rpl_server_count=5]
Warnings:
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure.
Note #### Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[connection server1]
SELECT * FROM performance_schema.replication_group_members;
CHANNEL_NAME MEMBER_ID MEMBER_HOST MEMBER_PORT MEMBER_STATE MEMBER_ROLE MEMBER_VERSION
group_replication_applier 22f05c71-f200-11ec-8a8c-2cf05daaf63e 127.0.0.1 13000 ONLINE PRIMARY 8.0.26
group_replication_applier 22f7fa47-f200-11ec-899a-2cf05daaf63e 127.0.0.1 13002 ONLINE PRIMARY 8.0.26
group_replication_applier 22ff4df3-f200-11ec-8a60-2cf05daaf63e 127.0.0.1 13004 ONLINE PRIMARY 8.0.26
group_replication_applier 23072911-f200-11ec-8aeb-2cf05daaf63e 127.0.0.1 13006 ONLINE PRIMARY 8.0.26
group_replication_applier 231090e9-f200-11ec-8b25-2cf05daaf63e 127.0.0.1 13008 ONLINE PRIMARY 8.0.26
include/group_replication_end.inc