更多文章,欢迎关注作者公众号,欢迎一起交流。

1)部署 SandBox 环境

[root@serverc local]# mysqlshMySQL Shell 8.0.28-commercialCopyright (c) 2016, 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 '?' for help; '\quit' to exit.MySQL JS > dba.deploySandboxInstance(3307);MySQL JS > dba.deploySandboxInstance(3308);MySQL JS > dba.deploySandboxInstance(3309);

2)检查实例配置,若满足,则返回OK,否则修复配置项

MySQL localhost:3307 ssl JS > dba.checkInstanceConfiguration();Validating local MySQL instance listening at port 3307 for use in an InnoDB cluster...NOTE: Instance detected as a sandbox.Please note that sandbox instances are only suitable for deploying test clusters for use within the same host.This instance reports its own address as 127.0.0.1:3307Checking whether existing tables comply with Group Replication requirements...No incompatible tables detectedChecking instance configuration...Instance configuration is compatible with InnoDB clusterThe instance '127.0.0.1:3307' is valid to be used in an InnoDB cluster.{"status": "ok"}

3)配置实例

MySQL localhost:3307 ssl JS > dba.configureInstance('localhost:3307');Configuring local MySQL instance listening at port 3307 for use in an InnoDB cluster...NOTE: Instance detected as a sandbox.Please note that sandbox instances are only suitable for deploying test clusters for use within the same host.This instance reports its own address as 127.0.0.1:3307applierWorkerThreads will be set to the default value of 4.The instance '127.0.0.1:3307' is valid to be used in an InnoDB cluster.The instance '127.0.0.1:3307' is already ready to be used in an InnoDB cluster.Successfully enabled parallel appliers.

4)创建 MGR

MySQL localhost:3307 ssl JS > var cluster=dba.createCluster('testMGR');A new InnoDB cluster will be created on instance 'localhost:3307'.Validating instance configuration at localhost:3307...NOTE: Instance detected as a sandbox.Please note that sandbox instances are only suitable for deploying test clusters for use within the same host.This instance reports its own address as 127.0.0.1:3307Instance configuration is suitable.NOTE: Group Replication will communicate with other members using '127.0.0.1:33071'. Use the localAddress option to override.Creating InnoDB cluster 'testMGR' on '127.0.0.1:3307'...Adding Seed Instance...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 toone server failure.

5)添加成员

MySQL localhost:3307 ssl JS > cluster.addInstance('localhost:3308');NOTE: The target instance '127.0.0.1:3308' has not been pre-provisioned (GTID set is empty). The Shell is unable to decide whether incremental state recovery can correctly provision it.The safest and most convenient way to provision a new instance is through automatic clone provisioning, which will completely overwrite the state of '127.0.0.1:3308' with a physical snapshot from an existing cluster member. To use this method by default, set the 'recoveryMethod' option to 'clone'.The incremental state recovery may be safely used if you are sure all updates ever executed in the cluster were done with GTIDs enabled, there are no purged transactions and the new instance contains the same GTID set as the cluster or a subset of it. To use this method by default, set the 'recoveryMethod' option to 'incremental'.Please select a recovery method [C]lone/[I]ncremental recovery/[A]bort (default Clone):Validating instance configuration at localhost:3308...NOTE: Instance detected as a sandbox.Please note that sandbox instances are only suitable for deploying test clusters for use within the same host.This instance reports its own address as 127.0.0.1:3308Instance configuration is suitable.NOTE: Group Replication will communicate with other members using '127.0.0.1:33081'. Use the localAddress option to override.A new instance will be added to the InnoDB cluster. Depending on the amount ofdata on the cluster this might take from a few seconds to several hours.Adding instance to the cluster...Monitoring recovery process of the new cluster member. Press ^C to stop monitoring and let it continue in background.Clone based state recovery is now in progress.NOTE: A server restart is expected to happen as part of the clone process. If theserver does not support the RESTART command or does not come back after awhile, you may need to manually start it back.Waiting for clone to finish... NOTE: 127.0.0.1:3308 is being cloned from 127.0.0.1:3307 ** Stage DROP DATA: Completed ** Clone TransferFILE COPY ############################################################ 100% Completed PAGE COPY ############################################################ 100% Completed REDO COPY ############################################################ 100% Completed
NOTE: 127.0.0.1:3308 is shutting down...Waiting for server restart... ready
127.0.0.1:3308 has restarted, waiting for clone to finish... ** Stage RESTART: Completed
Clone process has finished: 72.61 MB transferred in about 1 second (~72.61 MB/s)
State recovery already finished for '127.0.0.1:3308'The instance '127.0.0.1:3308' was successfully added to the cluster.MySQL localhost:3307 ssl JS > cluster.addInstance('localhost:3309');

6)查看集群状态

MySQL localhost:3307 ssl JS > cluster.status();{"clusterName": "testMGR","defaultReplicaSet": {"name": "default","primary": "127.0.0.1:3307","ssl": "REQUIRED","status": "OK","statusText": "Cluster is ONLINE and can tolerate up to ONE failure.","topology": {"127.0.0.1:3307": {"address": "127.0.0.1:3307","memberRole": "PRIMARY","mode": "R/W","readReplicas": {},"replicationLag": null,"role": "HA","status": "ONLINE","version": "8.0.28"},"127.0.0.1:3308": {"address": "127.0.0.1:3308","memberRole": "SECONDARY","mode": "R/O","readReplicas": {},"replicationLag": null,"role": "HA","status": "ONLINE","version": "8.0.28"},"127.0.0.1:3309": {"address": "127.0.0.1:3309","memberRole": "SECONDARY","mode": "R/O","readReplicas": {},"replicationLag": null,"role": "HA","status": "ONLINE","version": "8.0.28"}},"topologyMode": "Single-Primary"},"groupInformationSourceMember": "127.0.0.1:3307"}

7)使用SQL查看集群状态

MySQL localhost:3307 ssl JS > \sqlSwitching to SQL mode... Commands end with ;MySQL localhost:3307 ssl SQL > select * from performance_schema.replication_group_members\G;*************************** 1. row ***************************CHANNEL_NAME: group_replication_applierMEMBER_ID: 56c5f854-c95b-11ec-b051-080027f0b1d1MEMBER_HOST: 127.0.0.1MEMBER_PORT: 3308MEMBER_STATE: ONLINEMEMBER_ROLE: SECONDARYMEMBER_VERSION: 8.0.28MEMBER_COMMUNICATION_STACK: XCom*************************** 2. row ***************************CHANNEL_NAME: group_replication_applierMEMBER_ID: 5af915c7-c930-11ec-a32c-080027f0b1d1MEMBER_HOST: 127.0.0.1MEMBER_PORT: 3307MEMBER_STATE: ONLINEMEMBER_ROLE: PRIMARYMEMBER_VERSION: 8.0.28MEMBER_COMMUNICATION_STACK: XCom*************************** 3. row ***************************CHANNEL_NAME: group_replication_applierMEMBER_ID: 634aa2f6-c95b-11ec-b438-080027f0b1d1MEMBER_HOST: 127.0.0.1MEMBER_PORT: 3309MEMBER_STATE: ONLINEMEMBER_ROLE: SECONDARYMEMBER_VERSION: 8.0.28MEMBER_COMMUNICATION_STACK: XCom3 rows in set (0.0006 sec)ERROR: 1065 (42000): Query was empty

由此可见,利用MySQL Shell来搭建MGR则更为方便。

使用MySQL Shell搭建MGR环境相关推荐

  1. nextcloud+nginx+mysql,Ubuntu搭建Nginx-Nextcloud环境

    环境部署与安装 安装mysql-server "` $ sudo apt-get install mysql-server "` 安装的过程中会设置密码 进入mysql " ...

  2. MySQL Shell副本集和MGR快速搭建详解

    墨墨导读:本文是 MySQL Shell 快速搭建 副本集 和 MGR集群的全过程,分享至此,希望对大家有帮助. 简介 MySQL Shell是MySQL Server的高级客户端和代码编辑器.除了和 ...

  3. 服务器上搭建java环境,安装tomcat以及MySQL数据库-小白教程

    文章目录 前言 一.安装jdk,搭建java环境 二.安装MySQL 三.安装Tomcat 总结 前言 我第一次租服务器的时候也是从网上找方法,各种教程琳琅满目,太杂乱,我在这里做一个总结.我的系统是 ...

  4. 基于mysql搭建框架环境搭建_Maven+Spring+Spring MVC+MyBatis+MySQL,搭建SSM框架环境

    项目建设完成之后的结构: 数据库的表结构如下: 环境建设:搭建Maven环境.Tomcat环境.需要MySql 数据库支持,使用的编程工具Eclipse (这些是前期准备): 开始创建工程: 1.创建 ...

  5. wordpress支持MySQL5.5_CentOS 5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装Wordpress...

    一.总体介绍 系统环境  CentOS release 5.5 (Final)   ,kernel  2.6.18-194.el5 安装 Nginx . PHP(FastCGI)   . MySQL  ...

  6. 宝塔 运程mysql_宝塔面板使用详解(极简搭建各种环境、mysql数据库等)

    宝塔面板可能有些小伙伴不知道是个什么东西,做什么来用的.最近也是用得比较多,故写一份使用记录,刚接触的小伙伴也可以看看参考下. 宝塔面板其实就是可视化操作界面,可快速搭建站点.数据库.FTP等服务.顾 ...

  7. 【本地调试环境一键安装包】php+mysql平台搭建集成软件总汇【php环境汇总】

    [本地调试环境一键安装包]php+mysql平台搭建集成软件总汇[php环境汇总] ********************************************************** ...

  8. 【MySQL主从复制】使用MySQL8.0.17的clone技术在线搭建主从复制环境

    [MySQL主从复制]使用MySQL8.0.17的clone技术在线搭建主从复制环境 参考:https://www.xmmup.com/dbbao33shiyongmysql8-0-17declone ...

  9. Windows平台本地搭建PHP环境,超详细!(Apache+PHP+Mysql)

    之前一直在用比如PHPstudy,WampServer之类的集成环境,但毕竟是学计算机的,还是喜欢自己动手搭建一个用着舒服. 废话不多说,直接上教程.平台是windows7,是以Apache2.4+P ...

最新文章

  1. 30005 rust_Steam三连冠老游戏《腐蚀(RUST)》为什么突然火起来了?
  2. linux上的web spider开发
  3. vue 学习之路 —— 图片的引入
  4. python中pygame输入换行文字,Pygame:写多行
  5. 【编程好习惯】复用代码以提高可维护性
  6. c++ 从double变为long int 数据丢失_面试官:Java 中有几种基本数据类型是什么?各自占用多少字节?...
  7. openfire源码解读--用户登录
  8. 简化Simulink的建模与模型重构
  9. 手机照片分辨率dpi怎么调?一寸证件照照片dpi怎么调300?
  10. 手机刷的面具是什么_小米9刷Magisk(面具)详细教程
  11. UVA12304-2D Geometry 110 in 1!
  12. 基于毫米波雷达的手势识别原理
  13. 计算机基础的课程标准,《计算机基础》课程标准
  14. Could not find multidex.jar (com.android.support:multidex:1.0.2).
  15. mkcert制作信任的本地 SSL 证书
  16. 微信和qq哪个服务器好,王者荣耀微信区和QQ区选哪个比较好-王者荣耀哪个区比较好打 - QT软件园...
  17. 学习日志 Day 5
  18. IDEA-Java注释模板设置
  19. 证明:高斯白噪声的正交变换仍然是高斯白噪声
  20. (一)安卓智能广告机,实现广告分屏播放(根据图片/视频链接进行加载播放)

热门文章

  1. 比较全面的PS学习平台
  2. 树莓派我的世界服务器优化,用树莓派做我的世界服务端.md
  3. ipad打开javascript
  4. 戴耳机会对人体会造成哪些伤害,正确使用耳机的方法是这样
  5. 计算机专业可以考影视编导,影视编导专业需要艺考吗 注意事项有哪些
  6. ElasticSearch--learning
  7. Hikyuu 1.2.5 发布,高性能量化交易研究框架
  8. 7.Hadoop架构图解
  9. 公司中午开了周年庆典
  10. 关于 fscanf_s 的 bug