暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
7.InnoDB Cluster.docx
53
73页
0次
2025-06-22
50墨值下载
手动创建集群
如果在已经配置好的组复制上创建 InnoDB Cluster,需要使用 MySQL Shell 来创建集群,
adoptFromGR 选项传递给 dba.createCluster()函数。创建的 InnoDB Cluster 会匹配复制组
是以单主数据库还是多主数据库运行。
初始化实例及创建元数据库,库名 mysql_innodb_cluster_metadata
1.安装 MySQL Shellmgr01mgr02mgr03
wget https://downloads.mysql.com/archives/get/p/43/file/mysql-shell-8.0.33-
1.el7.x86_64.rpm
yum -y install mysql-shell-8.0.33-1.el7.x86_64.rpm
2.连接数据库,添加元数据库
在第一次连接,创建元数据库时,需要从 primary 连接进去。否则会破坏 read_onlyroot
用户会破坏 super_read_only)
mysqlsh root:123456@mgr01:3306
添加元数据库
dba.create_cluster('cluster')
MySQL mgr01:3306 ssl JS > dba.createCluster('cluster')
A new InnoDB Cluster will be created on instance 'mgr02:3306'.
You are connected to an instance that belongs to an unmanaged replication group.
Do you want to setup an InnoDB Cluster based on this replication group? [Y/n]: Y
Creating InnoDB Cluster 'cluster' on 'mgr01:3306'...
Adding Seed Instance...
Adding Instance 'mgr01:3306'...
Adding Instance 'mgr02:3306'...
Adding Instance 'mgr03:3306'...
Resetting distributed recovery credentials across the cluster...
NOTE: User 'mysql_innodb_cluster_1'@'%' already existed at instance 'mgr01:3306'. It
will be deleted and created again with a new password.
NOTE: User 'mysql_innodb_cluster_2'@'%' already existed at instance 'mgr01:3306'. It
will be deleted and created again with a new password.
NOTE: User 'mysql_innodb_cluster_3'@'%' already existed at instance 'mgr01:3306'. It
will be deleted and created again with a new password.
Cluster successfully created based on existing replication group.
如果报以下错误,则添加相应权限
mysqlsh.DBError: MySQL Error (3630): Dba.create_cluster: Access denied; you need
SYSTEM_VARIABLES_ADMIN and PERSIST_RO_VARIABLES_ADMIN privileges
for this operation
--在主库上添加权限
grant SYSTEM_VARIABLES_ADMIN,PERSIST_RO_VARIABLES_ADMIN on *.* to
root;
3.查看集群状态
MySQL mgr01:3306 ssl JS > var cluster=dba.getCluster()
MySQL mgr01:3306 ssl JS > cluster.status()
{
"clusterName": "cluster",
"defaultReplicaSet": {
"name": "default",
"primary": "mgr01:3306",
"ssl": "DISABLED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
"mgr01:3306": {
"address": "mgr01:3306",
"instanceErrors": [
"NOTE: The required parallel-appliers settings are not enabled on the
instance. Use dba.configureInstance() to fix it."
],
"memberRole": "PRIMARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.33"
},
"mgr02:3306": {
"address": "mgr02:3306",
"instanceErrors": [
"NOTE: The required parallel-appliers settings are not enabled on the
instance. Use dba.configureInstance() to fix it."
],
"memberRole": "SECONDARY",
"mode": "R/O",
"readReplicas": {},
"replicationLag": "applier_queue_applied",
"role": "HA",
"status": "ONLINE",
"version": "8.0.33"
},
"mgr03:3306": {
"address": "mgr03:3306",
"instanceErrors": [
"NOTE: The required parallel-appliers settings are not enabled on the
instance. Use dba.configureInstance() to fix it."
],
of 73
50墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜