mysql cluster复制_MySQL 5.7: 把现有的复制组迁移到InnoDB Cluster

可以使用MySQL Shell来配置MySQL服务器组以创建一个MySQL InnoDB数据库集群.

默认为单主模式, 集群中的服务器只有一个能写.

余下的服务器作为主服务器的备用.

创建集群至少需要三台机器.

客户端应用程序通过MySQL Router连接到主服务器.

如果主服务器失败, 集群自动选主, MySQL Router自动把连接路由到新主上

高级用于可以配置集群有多主

由于前面我们已经创建了一个复制组.

mysql> SELECT * FROM performance_schema.replication_group_members;

+---------------------------+--------------------------------------+----------------+-------------+--------------+

| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE |

+---------------------------+--------------------------------------+----------------+-------------+--------------+

| group_replication_applier | 255a577c-c68f-11e7-a0a7-00163e0c0288 | 172.18.149.215 | 3306 | ONLINE |

| group_replication_applier | 77befd8c-c68e-11e7-9623-00163e0af475 | 172.18.149.213 | 3306 | ONLINE |

| group_replication_applier | a44c7ec7-c68e-11e7-9cf8-00163e0afda9 | 172.18.149.214 | 3306 | ONLINE |

+---------------------------+--------------------------------------+----------------+-------------+--------------+

3 rows in set (0.00 sec)

现在我们只需要安装MySQL Router和MySQL Shell

wget https://dev.mysql.com/get/mysql-apt-config_0.8.9-1_all.deb

dpkg -i mysql-apt-config_0.8.9-1_all.deb

查看版本信息

root:~# mysqlrouter --version

MySQL Router v2.1.4 on Linux (64-bit) (GPL community edition)

使用 MySQL Shell 配置集群

登录

root:~# mysqlsh --uri root@172.18.149.213:3306

Creating a Session to 'root@172.18.149.213:3306'

Enter password:

Your MySQL connection id is 80

Server version: 5.7.20-log MySQL Community Server (GPL)

No default schema selected; type \use to set one.

MySQL Shell 1.0.10

Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.

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.

Currently in JavaScript mode. Use \sql to switch to SQL mode and execute queries.

mysql-js>

创建集群

mysql-js> var cluster = dba.createCluster('dc', {adoptFromGR: true});

执行成功后会自动创建一个新的数据库: mysql_innodb_cluster_metadata, 用于存放集群的元数据, 该元数据会被MySQL Router用到, 以实现高可用性.

参考资料

dba.createCluster('dc', {adoptFromGR: true}) 的BUG

root:~# mysqlsh --version

mysqlsh Ver 1.0.10 for Linux on x86_64 - for MySQL 5.7.19 (MySQL Community Server (GPL))

从现有的复制组创建 InnoDB 集群的问题: https://bugs.mysql.com/bug.ph... MySQL Shell 的一个BUG, 降级到 1.0.9 正常.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值