日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

MySQL高可用架构InnoDB Cluster (和NDB Cluster是两码事)

發(fā)布時間:2024/2/28 数据库 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL高可用架构InnoDB Cluster (和NDB Cluster是两码事) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

MySQL的高可用架構無論是社區(qū)還是官方,一直在技術上進行探索,這么多年提出了多種解決方案,比如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


創(chuàng)建集群
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")
查看集群狀態(tài)
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模式,執(zhí)行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是两码事)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。