一键构建GreatSQL5.7.36-single-master模式MGR集群
Posted 运维之美
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一键构建GreatSQL5.7.36-single-master模式MGR集群相关的知识,希望对你有一定的参考价值。
开场白:整点心灵毒鸡汤
三十岁一切オ刚刚开始
下班路上想了很久,一眨眼自己已经不是20几岁了,我的青春结束了,我们都低估了时间的善变,轻易让原本浓烈的东西不见了。
生活的琐碎,吐出来矫情,吞下去呛。
百般滋味涌上心头,话到嘴边却不值一提,词穷不是沉默更多的是一言难尽。
非常喜欢一段话:现在的我,用执着烧死了所有的幼稚和任性,那片荒野慢慢长处了理智冷漠和清醒。共勉!
闲话短说,让咱们进入本期博文正题
一、准备环境
服务器环境:
centos7.9 x86_64位 阿里ECS最小化安装
ECS服务器本地hosts文件
tidb04 mgr01
tidb05 mgr02
tidb06 mgr03
阿里云安全组或者iptables防火墙要提前放行33061端口 (MGR内部通信端口)
演示实现结果:
一键脚本初始化和安装完成greatsql版mysql5.7.36-39 单主模式三个节点的MGR集群,(最多支持9个节点的MGR集群)
演示ansible脚本来源:
参考 GreatSQL官方版 mysql8.0.25 ansible 一键完成单主模式MGR集群
greatsql官方ansible地址如下
https://gitee.com/GreatSQL/GreatSQL-Doc/blob/master/docs/install-greatsql-with-ansible.md
二、开始部署
2.1、mgr01到mgr01,mgr02,mgr03 实现ssh免密钥登陆
mgr01服务器作为ansible脚本执行端:
需要在 MGR01服务器上安装ansible软件和 ssh免密钥到 MGR01 MGR02 MGR03
安装命令: yum install -y ansible
验证ansible: ansible --version
配置ansible:
修改 /etc/ansible/hosts 文件,把要安装GreatSQL的服务器IP加进去
[root@tidb04 greatsql]# cat /etc/ansible/hosts
[greatsql_dbs:children]
greatsql_mgr_primary
greatsql_mgr_secondary
greatsql_mgr_arbitrator
[greatsql_mgr_primary]
192.168.0.59
[greatsql_mgr_secondary]
192.168.0.246
[greatsql_mgr_arbitrator]
192.168.0.247
提示:
请填内网IP地址,因为MGR初始化时,默认使用用内网IP地址。所以,如果同时还要安装到本机,也请填写内网IP地址
上面这个主机列表,分为三个组,一个是选择作为MGR PRIMARY节点的组 greatsql_mgr_primary,只有一个主机。另一组选择作为SECONDARY节点 greatsql_mgr_secondary,有1个主机。greatsql_mgr_arbitrator 代表仲裁节点,有一个主机。
当然 这三个组也可以再次合并到一起。成为一个新的组 greatsql_dbs。
当然也可以去掉冲裁组greatsql_mgr_arbitrator,按照下面的方式配置ansible hosts文件也是OK的
[root@tidb04 greatsql]# cat /etc/ansible/hosts
[greatsql_dbs:children]
greatsql_mgr_primary
greatsql_mgr_secondary
[greatsql_mgr_primary]
192.168.0.59
192.168.0.246
配置SSH免密钥,具体过程大家百度自查,此处不在演示
测试ansible:
随意执行一个指令,测试ansibile可连接远程主机
[root@tidb04 greatsql]# ansible greatsql_dbs -a "uptime"
192.168.0.59 | CHANGED | rc=0 >>
12:28:44 up 162 days, 22:41, 5 users, load average: 0.24, 0.11, 0.12
192.168.0.246 | CHANGED | rc=0 >>
12:28:44 up 24 days, 17 min, 2 users, load average: 0.02, 0.03, 0.05
192.168.0.247 | CHANGED | rc=0 >>
12:28:44 up 35 days, 21:58, 2 users, load average: 0.08, 0.07, 0.12
这就表示可以正常运行了。
2.2、使用ansible自动安装GreatSQL
A、第一步,修改 /etc/hosts 设置正确的主机名
修改三台个服务器上的 /etc/hosts 文件,加入正确的主机名配置:
[root@tidb04 greatsql]# grep mgr /etc/hosts
192.168.0.59 mgr01
192.168.0.246 mgr02
192.168.0.247 mgr03
B、第二步, git clone greatsql-8.0.27的ansible脚本
https://gitee.com/GreatSQL/GreatSQL-Ansible.git
修改脚本内容包括:安装包版本,安装路径,MGR初始化参数,greatsql-5.7.36的初始化脚本和启动脚本等。修改完成后cp 到mgr01服务器 /opt/greatsql 目录下
下载GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64.tar.xz 二进制安装包到 /opt/greatsql/ 下
[root@tidb04 greatsql]# ll /opt/greatsql/
total 330100
-rw-r--r-- 1 root root 333 Apr 10 12:42 check_mysql.yml
-rw-r--r-- 1 root root 337980016 Apr 7 10:57 GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64.tar.xz
-rw-r--r-- 1 root root 7561 Apr 12 08:44 greatsql.yml
-rw-r--r-- 1 root root 9592 Apr 10 12:42 LICENSE
drwxr-xr-x 3 root root 4096 Apr 12 08:50 mysql-support-files
-rw-r--r-- 1 root root 882 Apr 10 12:42 README.en.md
-rw-r--r-- 1 root root 811 Apr 10 12:42 README.md
-rw-r--r-- 1 root root 377 Apr 12 08:13 vars.yml
再次说明:以上安装脚本基于Greatsql8.0.27一键安装脚本改写完成
2.3、ansible脚本文件内容
greatsql.yml 文件是ansible安装剧本文件内容:
[root@tidb04 greatsql]# cat /opt/greatsql/greatsql.yml
- name: install GreatSQL
hosts: greatsql_dbs
remote_user: root
ignore_errors: yes
vars_files:
- vars.yml
tasks:
- include: check_mysql.yml
- block:
- name: modify selinux config file
lineinfile: dest=/etc/selinux/config regexp=SELINUX=enforcing line=SELINUX=disabled backrefs=yes state=present
- name: stop firewalld
command: /usr/bin/systemctl stop firewalld.service
- name: disable firewalld
command: /usr/bin/systemctl disable firewalld.service
- name: install jemalloc jemalloc-devel
raw: yum install -y jemalloc jemalloc-devel
- name: add group mysql
group: name=mysql_user state=present
- name: add user mysql
user: name=mysql_user group=mysql_user shell=/sbin/nologin
- name: create data_dir
file: path=data_dir/data state=directory owner=mysql_user group=mysql_user mode=0700
- name: create binlog_dir
file: path=data_dir/binlog state=directory owner=mysql_user group=mysql_user mode=0700
- name: create logs_dir
file: path=data_dir/logs state=directory owner=mysql_user group=mysql_user mode=0700
- name: extract GreatSQL tarball
unarchive: src=work_dir/file_name dest=extract_dir mode=755
- name: backup /etc/my.cnf
copy: src=my_cnf dest=my_cnf.orig ignore_errors=True
- name: copy my.cnf
copy: src=work_dir/mysql-support-files/my.cnf dest=my_cnf owner=mysql_user group=mysql_user mode=0644
- name: copy mysqld_pre_systemd
copy: src=work_dir/mysql-support-files/mysqld_pre_systemd dest=base_dir/bin/ owner=mysql_user group=mysql_user mode=0755
# - name: copy mysqld
# copy: src=work_dir/mysql-support-files/mysqld dest=base_dir/bin/ owner=mysql_user group=mysql_user mode=0755
# - name: copy mysql
# copy: src=work_dir/mysql-support-files/mysql dest=base_dir/bin/ owner=mysql_user group=mysql_user mode=0755
- name: replace mysqld_pre_systemd MYSQL_BASEDIR
replace:
path: "base_dir/bin/mysqld_pre_systemd"
regexp: (MYSQL_BASEDIR)=.*
replace: \\1=base_dir
- name: replace my.cnf server_id settings
replace:
path: " my_cnf "
regexp: (.*server_id.*)=.*
replace: \\1= 3306 1024 | random
- name: replace my.cnf group_replication_local_address settings
replace:
path: " my_cnf "
regexp: (.*group_replication_local_address.*)=.*
replace: \\1= inventory_hostname :33061
- name: replace my.cnf group_replication_group_seeds settings
replace:
path: " my_cnf "
regexp: (.*group_replication_group_seeds.*)=.*
replace: \\1= mgr_seeds
- name: replace my.cnf report_host settings
replace:
path: " my_cnf "
regexp: (.*report_host.*)=.*
replace: \\1= inventory_hostname
- name: copy sysconfig/mysql to /etc/sysconfig/mysql
copy: src=work_dir/mysql-support-files/sysconfig/mysql dest=/etc/sysconfig owner=root group=root mode=0644
- name: preload jemalloc
command: /usr/sbin/ldconfig
- name: copy mysql PATH
copy: src=work_dir/mysql-support-files/mysql.sh dest=/etc/profile.d/mysql.sh
- name: copy greatsql.server
copy: src=work_dir/mysql-support-files/greatsql.service dest=/usr/lib/systemd/system/ owner=root group=root mode=0644
- name: reload GreatSQL service
command: /usr/bin/systemctl daemon-reload
when: check_mysql_port.stdout == "True" and check_mysql_ps.stdout == "True"
- name: mgr primary
hosts: greatsql_mgr_primary
ignore_errors: yes
vars_files:
- vars.yml
tasks:
- include: check_mysql.yml
- block:
- name: start the GreatSQL service on PRIMARY NODE
command: /usr/bin/systemctl start greatsql
- name: wait for mysqld start
shell: sleep wait_for_start
delay: 1
- name: mgr primary init
shell: >
base_dir /bin/mysql -uroot -f -S data_dir /mysql.sock
-ANse "SET @@SESSION.SQL_LOG_BIN=0;
CREATE USER IF NOT EXISTS mgr_user IDENTIFIED WITH mysql_native_password BY mgr_user_pwd ;
GRANT REPLICATION SLAVE ON *.* TO mgr_user ;
CHANGE MASTER TO MASTER_USER= mgr_user , MASTER_PASSWORD= mgr_user_pwd FOR CHANNEL group_replication_recovery;
SET GLOBAL group_replication_local_address = inventory_hostname :33061;
SET GLOBAL group_replication_group_seeds = mgr_seeds ;
SET GLOBAL group_replication_bootstrap_group=ON;
START GROUP_REPLICATION;
SET GLOBAL group_replication_bootstrap_group=OFF; "
when: check_mysql_port.stdout == "True" and check_mysql_ps.stdout == "True"
- name: mgr secondary
hosts: greatsql_mgr_secondary
ignore_errors: yes
vars_files:
- vars.yml
tasks:
- include: check_mysql.yml
- block:
- name: start the GreatSQL service on SECONDARY NODE
command: /usr/bin/systemctl start greatsql
- name: wait for mysqld start
shell: sleep wait_for_start
delay: 1
- name: mgr secondary init
shell: >
base_dir /bin/mysql -uroot -f -S data_dir /mysql.sock
-ANse "SET @@SESSION.SQL_LOG_BIN=0;
CREATE USER IF NOT EXISTS mgr_user IDENTIFIED WITH mysql_native_password BY mgr_user_pwd ;
GRANT REPLICATION SLAVE ON *.* TO mgr_user ;
CHANGE MASTER TO MASTER_USER= mgr_user , MASTER_PASSWORD= mgr_user_pwd FOR CHANNEL group_replication_recovery;
SET GLOBAL group_replication_local_address = inventory_hostname :33061;
SET GLOBAL group_replication_group_seeds = mgr_seeds ;
START GROUP_REPLICATION; "
when: check_mysql_port.stdout == "True" and check_mysql_ps.stdout == "True"
- name: mgr arbitrator
hosts: greatsql_mgr_arbitrator
ignore_errors: yes
vars_files:
- vars.yml
tasks:
- include: check_mysql.yml
- block:
- name: replace my.cnf arbitrator settings
replace:
path: " my_cnf "
regexp: (.*_arbitrator.*)=.*
replace: \\1= 1
- name: start the GreatSQL service on ARBITRATOR NODE
command: /usr/bin/systemctl start greatsql
- name: wait for mysqld start
shell: sleep wait_for_start
delay: 1
- name: mgr arbitrator init
shell: >
base_dir /bin/mysql -uroot -f -S data_dir /mysql.sock
-ANse "SET @@SESSION.SQL_LOG_BIN=0;
CREATE USER IF NOT EXISTS mgr_user IDENTIFIED WITH mysql_native_password BY mgr_user_pwd ;
GRANT REPLICATION SLAVE ON *.* TO mgr_user ;
CHANGE MASTER TO MASTER_USER= mgr_user , MASTER_PASSWORD= mgr_user_pwd FOR CHANNEL group_replication_recovery;
SET GLOBAL group_replication_local_address = inventory_hostname :33061;
SET GLOBAL group_replication_group_seeds = mgr_seeds ;
START GROUP_REPLICATION; "
when: check_mysql_port.stdout == "True" and check_mysql_ps.stdout == "True"
[root@tidb04 greatsql]#
2.4、mysqld_pre_systemd脚本
这个是数据库初始化脚本中,下面展示的是初始化mysql这块的函数: 数据目录有改动 改成了/data/GreatSQL/data
[root@tidb04 mysql-support-files]# grep -wA 60 install_db () mysqld_pre_systemd
install_db ()
# Note: something different than datadir=/var/lib/mysql requires SELinux policy changes (in enforcing mode)
# mysql_upgrade_info file should be owned by mysql user since MySQL 8.0.16
fix_mysql_upgrade_info
# No automatic init wanted
[ -e /etc/sysconfig/mysql ] && . /etc/sysconfig/mysql
[ -n "$NO_INIT" ] && exit 0
local instance=$1
datadir=$(get_option mysqld datadir "/data/GreatSQL/data$instance:+-$instance" $instance)
log=$(get_option mysqld log[_-]error "/data/GreatSQL/$instance:+-$instance.log" $instance)
# Restore log, dir, perms and SELinux contexts
if [ ! -d "$datadir" -a ! -h "$datadir" -a "x$(dirname "$datadir")" = "x/var/lib" ]; then
install -d -m 0751 -omysql -gmysql "$datadir" || exit 1
fi
if [ ! -e "$log" -a ! -h "$log" -a x$(dirname "$log") = "x/var/log" ]; then
case $(basename "$log") in
mysql*.log) install /dev/null -m0640 -omysql -gmysql "$log" ;;
*) ;;
esac
fi
if [ -x /usr/sbin/restorecon ]; then
/usr/sbin/restorecon "$datadir"
[ -e "$log" ] && /usr/sbin/restorecon "$log"
for dir in /var/lib/mysql-files /var/lib/mysql-keyring ; do
if [ -x /usr/sbin/semanage -a -d /var/lib/mysql -a -d $dir ] ; then
/usr/sbin/semanage fcontext -a -e /var/lib/mysql $dir >/dev/null 2>&1
/sbin/restorecon -r $dir
fi
done
fi
# If special mysql dir is in place, skip db install
[ -d "$datadir/mysql" ] && exit 0
# Create initial db and install validate_password plugin
#initfile="$(install_validate_password_sql_file)"
$MYSQL_BASEDIR/bin/mysqld $instance:+--defaults-group-suffix=@$instance --initialize-insecure \\
--datadir="$datadir" --user=mysql
#rm -f "$initfile"
# Generate certs if needed
if [ -x $MYSQL_BASEDIR/bin/mysql_ssl_rsa_setup -a ! -e "$datadir/server-key.pem" ] ; then
$MYSQL_BASEDIR/bin/mysql_ssl_rsa_setup --datadir="$datadir" --uid=mysql >/dev/null 2>&1
fi
exit 0
install_db $1
exit 0
2.5、greatsql.service 这个文件是初始化mysql 和启动MySQL脚本
这个文件是初始化mysql 和启动MySQL脚本内容和greatsql官方的稍微不同
```html/xml
[root@tidb04 mysql-support-files]# cat greatsql.service
[Unit]
Description=GreatSQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
Type=forking
TimeoutSec=0
PermissionsStartOnly=true
ExecStartPre=/usr/local/GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64/bin/mysqld_pre_systemd
ExecStart=/usr/local/GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64/bin/mysqld --defaults-file=/etc/my.cnf --daemonize
EnvironmentFile=-/etc/sysconfig/mysql
LimitNOFILE = 65535
Restart=on-failure
RestartSec=20
RestartPreventExitStatus=1
PrivateTmp=false
### 2.6、vars.yml 是ansible安装脚本中定义的环境变量
```html/xml
[root@tidb04 greatsql]# cat vars.yml
work_dir: /opt/greatsql
extract_dir: /usr/local
data_dir: /data/GreatSQL
file_name: GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64.tar.xz
base_dir: /usr/local/GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64
my_cnf: /etc/my.cnf
mysql_user: mysql
mysql_port: 3306
mgr_user: repl
mgr_user_pwd: repl4MGR
mgr_seeds: 192.168.0.59:33061,192.168.0.246:33061,192.168.0.247:33061
wait_for_start: 30
2.7、整个脚本正常的安装过程输出
```html/xml
[root@tidb04 greatsql]# ansible-playbook ./greatsql.yml
PLAY [install GreatSQL] ****
TASK [Gathering Facts] *****
ok: [192.168.0.59]
ok: [192.168.0.246]
ok: [192.168.0.247]
TASK [check mysql port] ****
changed: [192.168.0.247]
changed: [192.168.0.59]
changed: [192.168.0.246]
TASK [check mysql processor] ***
changed: [192.168.0.246]
changed: [192.168.0.59]
changed: [192.168.0.247]
TASK [modify selinux config file] **
ok: [192.168.0.247]
ok: [192.168.0.59]
ok: [192.168.0.246]
TASK [stop firewalld] **
changed: [192.168.0.59]
changed: [192.168.0.246]
changed: [192.168.0.247]
TASK [disable firewalld] ***
changed: [192.168.0.59]
changed: [192.168.0.247]
changed: [192.168.0.246]
TASK [install jemalloc jemalloc-devel] *****
changed: [192.168.0.59]
changed: [192.168.0.246]
changed: [192.168.0.247]
TASK [add group mysql] *****
ok: [192.168.0.246]
ok: [192.168.0.59]
ok: [192.168.0.247]
TASK [add user mysql] **
ok: [192.168.0.59]
ok: [192.168.0.246]
ok: [192.168.0.247]
TASK [create data_dir] *****
changed: [192.168.0.247]
changed: [192.168.0.59]
changed: [192.168.0.246]
TASK [create binlog_dir] ***
changed: [192.168.0.59]
changed: [192.168.0.247]
changed: [192.168.0.246]
TASK [create logs_dir] *****
changed: [192.168.0.59]
changed: [192.168.0.246]
changed: [192.168.0.247]
TASK [extract GreatSQL tarball] ****
changed: [192.168.0.247]
changed: [192.168.0.59]
changed: [192.168.0.246]
TASK [backup /etc/my.cnf] **
fatal: [192.168.0.246]: FAILED! => "changed": false, "checksum": "0d659e26a7f136ba3764b8a097d8d601e4d4fbd4", "msg": "Unsupported parameters for (copy) module: ignore_errors Supported parameters include: _original_basename, attributes, backup, checksum, content, delimiter, dest, directory_mode, follow, force, group, local_follow, mode, owner, regexp, remote_src, selevel, serole, setype, seuser, src, unsafe_writes, validate"
...ignoring
fatal: [192.168.0.59]: FAILED! => "changed": false, "checksum": "0d659e26a7f136ba3764b8a097d8d601e4d4fbd4", "msg": "Unsupported parameters for (copy) module: ignore_errors Supported parameters include: _original_basename, attributes, backup, checksum, content, delimiter, dest, directory_mode, follow, force, group, local_follow, mode, owner, regexp, remote_src, selevel, serole, setype, seuser, src, unsafe_writes, validate"
...ignoring
fatal: [192.168.0.247]: FAILED! => "changed": false, "checksum": "0d659e26a7f136ba3764b8a097d8d601e4d4fbd4", "msg": "Unsupported parameters for (copy) module: ignore_errors Supported parameters include: _original_basename, attributes, backup, checksum, content, delimiter, dest, directory_mode, follow, force, group, local_follow, mode, owner, regexp, remote_src, selevel, serole, setype, seuser, src, unsafe_writes, validate"
...ignoring
TASK [copy my.cnf] *****
changed: [192.168.0.59]
changed: [192.168.0.247]
changed: [192.168.0.246]
TASK [copy mysqld_pre_systemd] *****
changed: [192.168.0.59]
changed: [192.168.0.247]
changed: [192.168.0.246]
TASK [replace mysqld_pre_systemd MYSQL_BASEDIR] ****
ok: [192.168.0.59]
ok: [192.168.0.247]
ok: [192.168.0.246]
TASK [replace my.cnf server_id settings] ***
changed: [192.168.0.246]
changed: [192.168.0.59]
changed: [192.168.0.247]
TASK [replace my.cnf group_replication_local_address settings] *****
changed: [192.168.0.59]
changed: [192.168.0.247]
changed: [192.168.0.246]
TASK [replace my.cnf group_replication_group_seeds settings] ***
changed: [192.168.0.59]
changed: [192.168.0.247]
changed: [192.168.0.246]
TASK [replace my.cnf report_host settings] *****
changed: [192.168.0.246]
changed: [192.168.0.59]
changed: [192.168.0.247]
TASK [copy sysconfig/mysql to /etc/sysconfig/mysql] ****
ok: [192.168.0.246]
ok: [192.168.0.59]
ok: [192.168.0.247]
TASK [preload jemalloc] ****
changed: [192.168.0.59]
changed: [192.168.0.247]
changed: [192.168.0.246]
TASK [copy mysql PATH] *****
ok: [192.168.0.246]
ok: [192.168.0.59]
ok: [192.168.0.247]
TASK [copy greatsql.server] ****
ok: [192.168.0.59]
ok: [192.168.0.246]
ok: [192.168.0.247]
TASK [reload GreatSQL service] *****
changed: [192.168.0.246]
changed: [192.168.0.59]
changed: [192.168.0.247]
PLAY [mgr primary] *****
TASK [Gathering Facts] *****
ok: [192.168.0.59]
TASK [check mysql port] ****
changed: [192.168.0.59]
TASK [check mysql processor] ***
changed: [192.168.0.59]
TASK [start the GreatSQL service on PRIMARY NODE] **
changed: [192.168.0.59]
TASK [wait for mysqld start] ***
changed: [192.168.0.59]
TASK [mgr primary init] ****
changed: [192.168.0.59]
PLAY [mgr secondary] ***
TASK [Gathering Facts] *****
ok: [192.168.0.246]
TASK [check mysql port] ****
changed: [192.168.0.246]
TASK [check mysql processor] ***
changed: [192.168.0.246]
TASK [start the GreatSQL service on SECONDARY NODE] ****
changed: [192.168.0.246]
TASK [wait for mysqld start] ***
changed: [192.168.0.246]
TASK [mgr secondary init] **
changed: [192.168.0.246]
PLAY [mgr arbitrator] **
TASK [Gathering Facts] *****
ok: [192.168.0.247]
TASK [check mysql port] ****
changed: [192.168.0.247]
TASK [check mysql processor] ***
changed: [192.168.0.247]
TASK [replace my.cnf arbitrator settings] **
ok: [192.168.0.247]
TASK [start the GreatSQL service on ARBITRATOR NODE] ***
changed: [192.168.0.247]
TASK [wait for mysqld start] ***
changed: [192.168.0.247]
TASK [mgr arbitrator init] *****
changed: [192.168.0.247]
PLAY RECAP *****
192.168.0.246 : ok=32 changed=22 unreachable=0 failed=0 skipped=0 rescued=0 ignored=1
192.168.0.247 : ok=33 changed=22 unreachable=0 failed=0 skipped=0 rescued=0 ignored=1
192.168.0.59 : ok=32 changed=22 unreachable=0 failed=0 skipped=0 rescued=0 ignored=1
### 2.8、验证安装结果
[root@tidb04 logs]# /usr/local/GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64/bin/mysql -uroot -S /data/GreatSQL/mysql.sock -e "select * from performance_schema.replication_group_members;"
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+
| group_replication_applier | 6fe63251-bd37-11ec-becd-00163e2c6a03 | 192.168.0.59 | 3306 | ONLINE | PRIMARY |
| group_replication_applier | b0689415-bd37-11ec-9714-00163e2c2eb3 | 192.168.0.246 | 3306 | ONLINE | SECONDARY |
| group_replication_applier | f6a2ac1c-bd37-11ec-8795-00163e0eced4 | 192.168.0.247 | 3306 | ONLINE | SECONDARY |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+
[root@tidb05 GreatSQL]# /usr/local/GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64/bin/mysql -uroot -S /data/GreatSQL/mysql.sock -e "select * from performance_schema.replication_group_members;"
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+
| group_replication_applier | 6fe63251-bd37-11ec-becd-00163e2c6a03 | 192.168.0.59 | 3306 | ONLINE | PRIMARY |
| group_replication_applier | b0689415-bd37-11ec-9714-00163e2c2eb3 | 192.168.0.246 | 3306 | ONLINE | SECONDARY |
| group_replication_applier | f6a2ac1c-bd37-11ec-8795-00163e0eced4 | 192.168.0.247 | 3306 | ONLINE | SECONDARY |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+
[root@tidb06 local]# /usr/local/GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64/bin/mysql -uroot -S /data/GreatSQL/mysql.sock -e "select * from performance_schema.replication_group_members;"
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+
| group_replication_applier | 6fe63251-bd37-11ec-becd-00163e2c6a03 | 192.168.0.59 | 3306 | ONLINE | PRIMARY |
| group_replication_applier | b0689415-bd37-11ec-9714-00163e2c2eb3 | 192.168.0.246 | 3306 | ONLINE | SECONDARY |
| group_replication_applier | f6a2ac1c-bd37-11ec-8795-00163e0eced4 | 192.168.0.247 | 3306 | ONLINE | SECONDARY |
+---------------------------+--------------------------------------+--------------+-------------+--------------+-------------+
## 三、遇到的问题
**登陆过程遇到的问题:**
[root@tidb04 GreatSQL]# /usr/local/GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64/bin/mysql -uroot
/usr/local/GreatSQL-5.7.36-39-Linux-glibc2.17-x86_64/bin/mysql: error while loading shared libraries: libreadline.so: cannot open shared object file: No such file or directory
**解决办法:**
yum install readline-devel readline-devel
写在最后的话:greatsql 开源版MGR 修复了好多MySQL官方MGR的bug问题。和官方MySQL MGR相比 性能和数据安全上提升非常大,而且greatsql社区非常活跃,再次力荐大家采用greatsql 的MGR产品。
下面是greatsql官方地址:https://gitee.com/GreatSQL/GreatSQL 。资料还是非常详细的.
以上是关于一键构建GreatSQL5.7.36-single-master模式MGR集群的主要内容,如果未能解决你的问题,请参考以下文章
构建Docker镜像实战之构建Tomcat9.0镜像(RPM一键安装Java环境)