mysql mic_MYSQL MIC 集群安装

本文介绍如何在CentOS 7系统上安装并配置MySQL InnoDB Cluster集群。包括安装MySQL环境、创建集群实例、配置MySQL Router等步骤,并提供集群状态检查的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Linux下安装mysql innoDB cluster

一 准备安装环境:

1.准备centos 7系统.

2.清空安装环境

[root@localhost ~]# yum list |grep mari

9538153.html

[root@localhost ~]# yum remove mariadb-libs.x86_64

9538153.html

二 安装

1. 下载安装包mysql80-community-release-el7-1.noarch,传入虚拟机

9538153.html

2. Yum安装mysql80-community-release-el7-1.noarch包,yum源

[root@localhost /]# yum install mysql80-community-release-el7-1.noarch.rpm

9538153.html

2.1

[root@localhost /]# yum makecache

9538153.html

2.2查看安装包

[root@localhost /]# yum list|grep mysql

9538153.html

2.3安装mysql-community-server.x86_64

[root@localhost /]# yum install -y mysql-community-server.x86_64

9538153.html

2.4安装mysql-shell.x86_64 mysql-router.x86_64

[root@localhost /]# yum install -y mysql-shell.x86_64 mysql-router.x86_64

9538153.html

3.进入mysqlsh初始化mysql实例

[root@localhost /]# mysqlsh

3.1查看命令

MySQL  JS > \? dba

NAME

dba - Global variable for InnoDB cluster management.

DESCRIPTION

The global variable dba is used to access the AdminAPI functionality and

perform DBA operations. It is used for managing MySQL InnoDB clusters.

PROPERTIES

verbose

Enables verbose mode on the dba operations.

FUNCTIONS

checkInstanceConfiguration(instance[, options])

Validates an instance for MySQL InnoDB Cluster usage.

configureInstance([instance][, options])

Validates and configures an instance for MySQL InnoDB Cluster

usage.

configureLocalInstance(instance[, options])

Validates and configures a local instance for MySQL InnoDB Cluster

usage.

createCluster(name[, options])

Creates a MySQL InnoDB cluster.

deleteSandboxInstance(port[, options])

Deletes an existing MySQL Server instance on localhost.

deploySandboxInstance(port[, options])

Creates a new MySQL Server instance on localhost.

dropMetadataSchema(options)

Drops the Metadata Schema.

getCluster([name][, options])

Retrieves a cluster from the Metadata Store.

help([member])

Provides help about this object and it's members

killSandboxInstance(port[, options])

Kills a running MySQL Server instance on localhost.

rebootClusterFromCompleteOutage([clusterName][, options])

Brings a cluster back ONLINE when all members are OFFLINE.

startSandboxInstance(port[, options])

Starts an existing MySQL Server instance on localhost.

stopSandboxInstance(port[, options])

Stops a running MySQL Server instance on localhost.

For more help on a specific function use: dba.help('')

e.g. dba.help('deploySandboxInstance')

3.2创建端口为3310、3320、3330的实例

MySQL  JS > dba.deploySandboxInstance(3310)

9538153.html

4.创建集群

4.1进入端口3310的实例

MySQL  JS > \connect root@localhost:3310

9538153.html

4.2定义集群

MySQL  localhost:3310 ssl  JS > var cluster=dba.createCluster('test')

9538153.html

4.3集群中加入实例3320、3330

MySQL  localhost:3310 ssl  JS > cluster.addInstance('root@localhost:3320')

MySQL  localhost:3310 ssl  JS > cluster.addInstance('root@localhost:3330')

9538153.html

5. Mysqlrouter启动

5.1连接3310

mysqlrouter --bootstrap root@localhost:3310 --user=mysqlrouter

9538153.html

5.2编辑mysqlrouter配置文件

[root@localhost ~]#  vi /etc/mysqlrouter/mysqlrouter.conf

9538153.html

5.3开启mysqlrouter

[root@localhost ~]#  mysqlrouter &

[1] 11085

6.通过mysqlrouter连入实例

[root@localhost ~]# mysql -uroot -h 127.0.0.1 -P 6446 -poracle

9538153.html

9538153.html

[root@localhost ~]# mysql -uroot -h 192.168.80.164 -P 6446 -poracle

9538153.html

7.查看集群状态

7.1 连入实例3310,获取数据

MySQL  JS > \connect root@localhost:3310

MySQL  localhost:3310 ssl  JS > cluster=dba.getCluster()

9538153.html

7.2 查看状态

MySQL  localhost:3310 ssl  JS > cluster.status()

9538153.html

MySQL  localhost:3310 ssl  JS > cluster=dba.getCluster()cluster.status()cluster.status()

{

"clusterName": "test",

"defaultReplicaSet": {

"name": "default",

"primary": "localhost:3310",

"ssl": "REQUIRED",

"status": "OK",

"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",

"topology": {

"localhost:3310": {

"address": "localhost:3310",

"mode": "R/W",

"readReplicas": {},

"role": "HA",

"status": "ONLINE"

},

"localhost:3320": {

"address": "localhost:3320",

"mode": "R/O",

"readReplicas": {},

"role": "HA",

"status": "ONLINE"

},

"localhost:3330": {

"address": "localhost:3330",

"mode": "R/O",

"readReplicas": {},

"role": "HA",

"status": "ONLINE"

}

}

},

"groupInformationSourceMember": "mysql://root@localhost:3310"

}

8.查看mysql进程

[root@localhost ~]# ps -ef |grep mysql

9538153.html

9.通过socket连入3310实例

[root@localhost 3310]# mysql -uroot -poracle -S /root/mysql-sandboxes/3310/sandboxdata/mysqld.sock

9538153.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值