使用InnoDB Cluster解决MySQL数据库高可用方案
发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,下文主要给大家带来使用InnoDB Cluster解决MySQL数据库高可用方案,希望这些内容能够带给大家实际用处,这也是我编辑使用InnoDB Cluster解决MySQL数据库高可用方案这篇文章的
千家信息网最后更新 2026年11月03日使用InnoDB Cluster解决MySQL数据库高可用方案
下文主要给大家带来使用InnoDB Cluster解决MySQL数据库高可用方案,希望这些内容能够带给大家实际用处,这也是我编辑使用InnoDB Cluster解决MySQL数据库高可用方案这篇文章的主要目的。好了,废话不多说,大家直接看下文吧。
MySQL InnoDB Cluster为MySQL提供了一个完整的高可用解决方案。MySQL Shell包含AdminAPI,能够轻松地配置和管理至少三个MySQL云服务器实例组,以作为InnoDB集群。每个MySQL云服务器实例都运行MySQL Group Replication,它提供了在innodb集群中复制数据的机制,并内置故障转移。MySQL Router可以根据您部署的集群自动配置自己,将客户端应用程序透明地连接到云服务器实例。如果云服务器实例发生意外故障,群集将自动重新配置。在默认的单主模式下,InnoDB集群有一个读写云服务器实例--主云服务器。多个辅助云服务器实例是主云服务器的副本。如果主云服务器出现故障,辅助云服务器将自动提升为主云服务器的角色。MySQL Router检测到这一点,并将客户端应用程序转发到新的主云服务器。
[root@wallet01 ~]# mysql -uroot -pEnter password:mysql> grant all privileges on *.* to 'root'@'wallet01' identified by 'abcd@1234';Query OK, 0 rows affected, 1 warning (0.05 sec)mysql> flush privileges;Query OK, 0 rows affected (0.06 sec)[root@wallet01 ~]# yum install -y mysql-shell[root@wallet01 ~]# mysqlsh --log-level=DEBUG3MySQL Shell 8.0.18Copyright (c) 2016, 2019, 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. MySQL JS > shell.connect('root@wallet01:3306')Creating a session to 'root@wallet01:3306'Please provide the password for 'root@wallet01:3306': *********Save password for 'root@wallet01:3306'? [Y]es/[N]o/Ne[v]er (default No): yFetching schema names for autocompletion... Press ^C to stop.Your MySQL connection id is 290Server version: 5.7.27-log MySQL Community Server (GPL)No default schema selected; type \use to set one. MySQL wallet01:3306 JS > var cluster = dba.createCluster('walletCluster', {adoptFromGR: true})A new InnoDB cluster will be created based on the existing replication group on instance 'wallet01:3306'.Creating InnoDB cluster 'walletCluster' on 'wallet01:3306'...Adding Seed Instance...Adding Instance 'wallet03:3306'...Adding Instance 'wallet01:3306'...Adding Instance 'wallet02:3306'...Resetting distributed recovery credentials across the cluster...Cluster successfully created based on existing replication group. MySQL wallet01:3306 JS > cluster.status();{ "clusterName": "walletCluster", "defaultReplicaSet": { "name": "default", "primary": "wallet01:3306", "ssl": "DISABLED", "status": "OK", "statusText": "Cluster is ONLINE and can tolerate up to ONE failure.", "topology": { "wallet01:3306": { "address": "wallet01:3306", "mode": "R/W", "readReplicas": {}, "role": "HA", "status": "ONLINE" }, "wallet02:3306": { "address": "wallet02:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "ONLINE" }, "wallet03:3306": { "address": "wallet03:3306", "mode": "R/O", "readReplicas": {}, "role": "HA", "status": "ONLINE" } }, "topologyMode": "Single-Primary" }, "groupInformationSourceMember": "wallet01:3306"} MySQL wallet01:3306 JS > \quitBye! [root@wallet01 ~]# yum install -y mysql-router [root@wallet01 ~]# mysqlrouter --bootstrap root@wallet01:3306 --user=mysqlrouter --name=router01Please enter MySQL password for root: WARNING: The MySQL server does not have SSL configured and metadata used by the router may be transmitted unencrypted.# Reconfiguring system MySQL Router instance...- Checking for old Router accounts - No prior Router accounts found- Creating mysql account 'mysql_router1_a8933v9tcn8v'@'%' for cluster management- Storing account in keyring- Adjusting permissions of generated files- Creating configuration /etc/mysqlrouter/mysqlrouter.conf# MySQL Router 'router01' configured for the InnoDB cluster 'walletCluster'After this MySQL Router has been started with the generated configuration $ /etc/init.d/mysqlrouter restartor $ mysqlrouter -c /etc/mysqlrouter/mysqlrouter.confthe cluster 'walletCluster' can be reached by connecting to:## MySQL Classic protocol- Read/Write Connections: localhost:6446- Read/Only Connections: localhost:6447## MySQL X protocol- Read/Write Connections: localhost:64460- Read/Only Connections: localhost:64470Existing configuration backed up to '/etc/mysqlrouter/mysqlrouter.conf.bak'[root@wallet01 ~]# /etc/init.d/mysqlrouter startStarting mysqlrouter: [ OK ][root@wallet01 ~]# /etc/init.d/mysqlrouter statusmysqlrouter (pid 24451) is running...[root@wallet02 ~]# yum install -y mysql-router [root@wallet02 ~]# mysqlrouter --bootstrap root@wallet01:3306 --user=mysqlrouter --name=router02 [root@wallet02 ~]# /etc/init.d/mysqlrouter startStarting mysqlrouter: [ OK ][root@wallet02 ~]# /etc/init.d/mysqlrouter statusmysqlrouter (pid 6906) is running...[root@wallet03 ~]# yum install -y mysql-router [root@wallet03 ~]# mysqlrouter --bootstrap root@wallet01:3306 --user=mysqlrouter --name=router03[root@wallet03 ~]# /etc/init.d/mysqlrouter startStarting mysqlrouter: [ OK ][root@wallet03 ~]# /etc/init.d/mysqlrouter statusmysqlrouter (pid 18081) is running...
对于以上关于使用InnoDB Cluster解决MySQL数据库高可用方案,大家是不是觉得非常有帮助。如果需要了解更多内容,请继续关注我们的行业资讯,相信你会喜欢上这些内容的。
服务器
服务
实例
数据
方案
集群
数据库
内容
故障
配置
下文
客户
客户端
应用程序
程序
应用
辅助
意外
三个
副本
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
广州万易互联网科技有限公司
朗新科技与工业互联网
互联网科技的英文
未来的互联网科技
互联网科技ppt模板
深圳艾佳互联网科技
互联网科技公司介绍
互联网科技股有哪些
美国互联网前沿科技
盛创互联网科技有限公司
科技大学互联网专业好不好
中国科技互联网公司收入
团飞科技与伯堂互联网服务平台
重庆互联网医院沙龙医盟信息科技
阿大互联网科技有限公司
互联网保险科技创业
黑科技 体验场景 互联网大会
济南小医互联网科技有限公司招聘
互联网科技手抄报图片
宁波允成互联网科技有限公司
科技企业和互联网企业
九亚互联网科技
广州善班互联网科技
深圳艾佳互联网科技
互联网科技有限公司 翻译
长沙互联网科技
互联网科技包装股
云南互联网科技学费
深圳互联网科技园地址
恒生科技互联网指数十大成分股