![孙巧梅](https://public.zaoge.com/wwwroot/202203/29/op_1742306242d4868cd3a.png)
![](/pc/images/p38.png)
![](/pc/images/p39.png)
MySQL Group Replication(下简称MGR)准确来说是官方推出的高知可用解决方案,基于原生复制技术,并以插件的方式提供。
1、使用前,关掉防火墙,包括 selinux,firewalld,或者 MySQL 企业版的firewall(如果用了企业版的话)2、两台机器:(4 台 MySQL 实例)192.168.2.219 centos-ytt57-1 3311/3312192.168.2.229 centos-ytt57-2 3311/33123、安装 MySQL(两台都装), MySQL Shell(任意一台), mysqlrouter(任意一台,官方建议和应用程序装在一个服务器上)yum install mysql-community-server mysql-shell mysql-router-community
4、搭建 InnoDB-Cluster(两台都装)
1. 配置文件如下:shell>vi /etc/my.cnfmaster-info-repository=tablerelay-log-info-repository=tablegtid_mode=ONenforce_gtid_consistency=ONbinlog_checksum=NONElog_slave_updates=ONbinlog_format=ROWtransaction_write_set_extraction=XXHASH642. 系统 HOSTS 配置(两台都配)
shell>vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.219 centos-ytt57-2
192.168.2.229 centos-ytt57-3
用 MySQL coalesce 函数确认下 report-host 是否设置正确(root@localhost) : [(none)] >SELECT coalesce(@@report_host, @@hostname) as r;+----------------+| r |+----------------+| centos-ytt57-1 |+----------------+1 row in set (0.00 sec)
3. 创建管理员用户搭建 GROUP REPLICATION (四个节点都要)
create user root identified by "Root@123";grant all on *.* to root with grant option;flush privileges;
4. MySQLsh 连接其中一台节点:
[root@centos-ytt57-1 mysql]# mysqlsh root@localhost:3321
5. 检查配置正确性:(如果这里不显示 OK,把对应的参数加到配置文件重启 MySQL 再次检查)dba.checkInstanceConfiguration("root@centos-ytt57-2:3311");dba.checkInstanceConfiguration("root@centos-ytt57-2:3312");dba.checkInstanceConfiguration("root@centos-ytt57-3:3311");dba.checkInstanceConfiguration("root@centos-ytt57-3:3312");mysqlsh 执行检测
[root@centos-ytt57-1 mysql]# mysqlsh --log-level=8 root@localhost:3311
MySQL localhost:3311 ssl JS > dba.checkInstanceConfiguration("root@centos-ytt57-2:3311")
{
"status": "ok"
}
6. 创建集群,节点 1 上创建。(结果显示 Cluster successfully created 表示成功)
MySQL localhost:3311 ssl JS > var cluster = dba.createCluster("ytt_mgr");
Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.
At least 3 instances are needed for the cluster to be able to withstand up to
one server failure.
7. 添加节点 2,3,4(全部显示 OK,表示添加成功)MySQL localhost:3311 ssl JS > cluster.addInstance("root@centos-ytt57-2:3312");MySQL localhost:3311 ssl JS > cluster.addInstance("root@centos-ytt57-3:3311");MySQL localhost:3311 ssl JS > cluster.addInstance("root@centos-ytt57-3:3312");
8. 查看拓扑图:(describe 简单信息,status 详细描述)
MySQL localhost:3311 ssl JS > cluster.describe()
{
"clusterName": "ytt_mgr",
"defaultReplicaSet": {
"name": "default",
"topology": [
{
![何槟洋](https://public.zaoge.com/wwwroot/202207/15/op_14271662d108c4b8eea.png)
![](/pc/images/p38.png)
![](/pc/images/p39.png)
光凭这句话,看不出来MGR的意思。但是,在这句话前面就应该曾经把这个简称的全名写出来过。可以自己去查查看。
![](/pc/images/p25.png)
![深圳公司名称的查询途径和查询步骤有哪些](https://public.zaoge.com/wwwroot/202310/13/poster_16562365290637e91fc.png)
![怎么简化商标注册名称的字数](https://public.zaoge.com/wwwroot/202401/19/poster_18441865aa5282af138.png)
![查询商标注册号的方法](https://public.zaoge.com/wwwroot/202301/06/poster_16550663b7e1eaf369d.png)
![商标命名的原则和方法有哪些](https://public.zaoge.com/wwwroot/202212/20/poster_10155263a11ad8c87f1.png)
![版权证书的宣传与推广](https://public.zaoge.com/wwwroot/202406/06/poster_1755166661878476ef4.png)
![](/pc/images/p33.png)
![](/pc/images/p36.png)