MySQL高可用架构InnoDB Cluster (和NDB Cluster是两码事)
来源:互联网 发布:inc在单片机什么意思 编辑:程序博客网 时间:2024/06/05 22:36
MySQL的高可用架构无论是社区还是官方,一直在技术上进行探索,这么多年提出了多种解决方案,比如MMM, MHA, NDB Cluster, Galera Cluster, InnoDB Cluster, 腾讯的PhxSQL, MySQL Fabric. 本文主要介绍MySQL的高可用架构InnoDB Cluster。 MySQL InnoDB Cluster解决方案其实是由MySQL的几个不同产品和技术组成的,比如MySQL Shell, MySQL Router, Group Replication.
安装mysql, mysql shell, mysql router
略
部署多个实例
mysqlsh
mysql-js> dba.deployLocalInstance(3310)
mysql-js> dba.deployLocalInstance(3320)
mysql-js> dba.deployLocalInstance(3330)
3310作为master, 3320和3330作为slave
创建集群
mysql-js> \c root@localhost:3310
mysql-js> cluster = dba.createCluster('mycluster')
向集群添加实例
mysql-js> cluster.addInstance("root@localhost:3320")
mysql-js> cluster.addInstance("root@localhost:3330")
查看集群状态
mysql-js> cluster.status()
{
"clusterName": "mycluster",
"defaultReplicaSet": {
"status": "Cluster tolerant to up to ONE failure.",
"topology": {
"localhost:3310": {
"address": "localhost:3310",
"status": "ONLINE",
"role": "HA",
"mode": "R/W",
"leaves": {
"localhost:3330": {
"address": "localhost:3330",
"status": "ONLINE",
"role": "HA",
"mode": "R/O",
"leaves": {}
},
"localhost:3320": {
"address": "localhost:3320",
"status": "ONLINE",
"role": "HA",
"mode": "R/O",
"leaves": {}
}
}
}
}
}
}
部署MySQL Router
mysqlrouter --bootstrap localhost:3310
返回信息
...
Please enter the administrative MASTER key for the MySQL InnoDB cluster:
MySQL Router has now been configured for the InnoDB cluster 'mycluster'.
The following connection information can be used to connect to the cluster.
Classic MySQL protocol connections to cluster 'mycluster':
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
启动Mysql Router
mysqlrouter&
客户端连接Router
mysqlsh --uri root@localhost:6446
mysql-js> \sql
Switching to SQL mode... Commands end with ;
mysql-sql> select @@port;
+--------+
| @@port |
+--------+
| 3310 |
+--------+
1 row in set (0.00 sec)
故障模拟
mysql-js> dba.killLocalInstance(3310)
切换到sql模式,执行sql语句Select @@port
mysql-js> \sql
Switching to SQL mode... Commands end with ;
mysql-sql> SELECT @@port;
ERROR: 2013 (HY000): Lost connection to MySQL server during query
The global session got disconnected.
Attempting to reconnect to 'root@localhost:6446'...
The global session was successfully reconnected.
mysql-sql> SELECT @@port;
+--------+
| @@port |
+--------+
| 3330 |
+--------+
1 row in set (0.00 sec)
可以看到,故障被检查到了,并自动重连,转到了 3330 实例
参考资料
https://dev.mysql.com/doc/refman/5.7/en/mysql-innodb-cluster-userguide.html
http://mysqlserverteam.com/mysql-innodb-cluster-setting-up-a-real-world-cluster/
- MySQL高可用架构InnoDB Cluster (和NDB Cluster是两码事)
- Mysql 高可用方案 InnoDB Cluster
- LVS & MySQL NDB Cluster
- Mysql ndb cluster初试
- mysql ndb cluster 安装
- MySQL NDB Cluster
- MySQL NDB Cluster实战
- MySQL(9) -- Cluster NDB使用
- Mysql Cluster NDB配置介绍
- MySQL Cluster (NDB) Installation Guide
- MySQL NDB Cluster 集群简介
- MySQL InnoDB Cluster搭建高可用数据库集群(centos7.x)
- MySQL高可用方案之集群(Cluster)
- keepalived+LVS+MySql Cluster 高可用配置
- Redis高可用-Cluster
- redis高可用cluster
- MySQL InnoDB Cluster搭建
- MySQL InnoDB Cluster安装
- DAY_03 HTML小白学习笔记
- Mybatis Generator 生成的mapper只有insert方法
- dubbo泛化处理(转)
- 【jQWidgets】jqxGrid控件在页面上重新加载的问题
- eclipse中解决svg文件报错的问题
- MySQL高可用架构InnoDB Cluster (和NDB Cluster是两码事)
- 超时机制、断路器模式简介
- HorizontalRefresh 一个可以左右拖动刷新的控件
- 解决vmware虚拟机策略太旧的方法
- tarjan算法--求无向图的割点和桥
- Flink广播的使用
- swift学习笔记0
- http://www.suthink.com/ 商标 世誉鑫诚 问问,免费注册
- android调试+及JNI相关