mysql mic_MYSQL MIC 集群安装

Linux下安装mysql innoDB cluster

一 准备安装环境:

1.准备centos 7系统.

2.

清空安装环境

[[email protected] ~]# yum list |grep mari

0818b9ca8b590ca3270a3433284dd417.png

[[email protected] ~]# yum remove mariadb-libs.x86_64

0818b9ca8b590ca3270a3433284dd417.png

二 安装

1. 下载安装包

mysql80-community-release-el7-1.noarch

,传入虚拟机

0818b9ca8b590ca3270a3433284dd417.png

2. Yum

安装

mysql80-community-release-el7-1.noarch

包,

yum

[[email protected] /]# yum install mysql80-community-release-el7-1.noarch.rpm

0818b9ca8b590ca3270a3433284dd417.png

2.1

[[email protected] /]# yum makecache

0818b9ca8b590ca3270a3433284dd417.png

2.2

查看安装包

[[email protected] /]# yum list|grep mysql

0818b9ca8b590ca3270a3433284dd417.png

2.3

安装

mysql-community-server.x86_64

[[email protected] /]# yum install -y mysql-community-server.x86_64

0818b9ca8b590ca3270a3433284dd417.png

2.4

安装

mysql-shell.x86_64 mysql-router.x86_64

[[email protected] /]# yum install -y mysql-shell.x86_64 mysql-router.x86_64

0818b9ca8b590ca3270a3433284dd417.png

3.

进入

mysqlsh

初始化

mysql

实例

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)

0818b9ca8b590ca3270a3433284dd417.png

4.

创建集群

4.1

进入端口

3310

的实例

MySQL  JS > \connect [email protected]:3310

0818b9ca8b590ca3270a3433284dd417.png

4.2

定义集群

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

0818b9ca8b590ca3270a3433284dd417.png

4.3

集群中加入实例

3320

3330

MySQL  localhost:3310 ssl  JS > cluster.addInstance(‘[email protected]:3320‘)

MySQL  localhost:3310 ssl  JS > cluster.addInstance(‘[email protected]:3330‘)

0818b9ca8b590ca3270a3433284dd417.png

5. Mysqlrouter

启动

5.1

连接

3310

mysqlrouter --bootstrap [email protected]:3310 --user=mysqlrouter

0818b9ca8b590ca3270a3433284dd417.png

5.2

编辑

mysqlrouter

配置文件

[[email protected] ~]#  vi /etc/mysqlrouter/mysqlrouter.conf

0818b9ca8b590ca3270a3433284dd417.png

5.3

开启

mysqlrouter

[[email protected] ~]#  mysqlrouter &

[1] 11085

6.

通过

mysqlrouter

连入实例

[[email protected] ~]# mysql -uroot -h 127.0.0.1 -P 6446 -poracle

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

[[email protected] ~]# mysql -uroot -h 192.168.80.164 -P 6446 -poracle

0818b9ca8b590ca3270a3433284dd417.png

7.

查看集群状态

7.1

连入实例

3310

,获取数据

MySQL  JS > \connect [email protected]:3310

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

0818b9ca8b590ca3270a3433284dd417.png

7.2

查看状态

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

0818b9ca8b590ca3270a3433284dd417.png

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://[email protected]:3310"

}

8.

查看

mysql

进程

[[email protected] ~]# ps -ef |grep mysql

0818b9ca8b590ca3270a3433284dd417.png

9.

通过

socket

连入

3310

实例

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

0818b9ca8b590ca3270a3433284dd417.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值