![程涛](https://public.zaoge.com/wwwroot/202203/26/op_135632623eab10458e2.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/202203/29/op_1827236242df0b6f987.png)
![](/pc/images/p38.png)
![](/pc/images/p39.png)
光凭这句话,看不出来MGR的意思。但是,在这句话前面就应该曾经把这个简称的全名写出来过。可以自己去查查看。
![](/pc/images/p25.png)
![商标注册的时间这么长的原因](https://public.zaoge.com/wwwroot/202206/07/poster_162109629f0a7596d77.png)
![注册厦门公司的流程与步骤](https://public.zaoge.com/wwwroot/202310/21/poster_15265365337d3d7d25b.png)
![税收完税证明的查询方法和查询流程](https://public.zaoge.com/wwwroot/202307/04/poster_18125564a3f0a7b839e.png)
![未来软件分发有哪些变化](https://public.zaoge.com/wwwroot/202401/04/poster_17512365967f9bdc511.png)
![《工伤保险条例》对工伤认定的相关规定](https://public.zaoge.com/wwwroot/202212/21/poster_21015763a303c520310.png)
![](/pc/images/p33.png)
![](/pc/images/p36.png)