使用MySQL Shell搭建MGR环境

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

1)部署 SandBox 环境

[root@serverc local]# mysqlsh

MySQL Shell 8.0.28-commercial

Copyright (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:3307

Checking whether existing tables comply with Group Replication requirements...

No incompatible tables detected

Checking instance configuration...

Instance configuration is compatible with InnoDB cluster

The 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 suitab
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MySQL高可用(MGR)是一种在MySQL环境中实现高可用性和容错性的技术。下面是在Windows上使用MySQL ShellMySQL Router搭建MySQL高可用(MGR)的具体实现步骤: 1. 确认你已经安装MySQL ShellMySQL Router,并且它们都可以正常运行。 2. 打开MySQL Shell使用以下命令连接到MySQL Server: ``` mysqlsh --uri root@localhost:3306 ``` 3. 创建一个新的ReplicaSet: ``` var mysqlx = session.getSchema('mysql').getClient(); mysqlx.shardCreate("myCluster") ``` 4. 添加节点到ReplicaSet中: ``` mysqlx.addShardInstance("root@localhost:3307", {group: "myCluster"}) mysqlx.addShardInstance("root@localhost:3308", {group: "myCluster"}) ``` 5. 启动MySQL Router,并配置它来连接到ReplicaSet: ``` mysqlrouter --bootstrap root@localhost:3306 --directory router --conf-use-rewriter=1 --conf-base-port=3000 --conf-dest-port=3306 --conf-target-auth=mysql_native_password --conf-source=mysql://root@localhost:3306 --conf-use-ssl=0 --conf-routing-strategy=round-robin --user=mysqlrouter --name=router ``` 6. 验证MySQL Router是否可以连接到ReplicaSet: ``` mysqlsh --uri mysqlrouter://router:mysqlrouter@localhost:3000 \sql SELECT * FROM performance_schema.replication_group_members; ``` 如果上述命令能够成功执行,并且返回所有节点的信息,则说明MySQL高可用(MGR)已经成功搭建。 注意:以上命令可能需要根据你的实际情况进行一些修改,例如用户名、密码、ReplicaSet名称等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值