久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

MySQL8.0 MIC高可用集群的搭建過程

137次閱讀
沒有評論

共計 4979 個字符,預計需要花費 13 分鐘才能閱讀完成。

本篇內容主要講解“MySQL8.0 MIC 高可用集群的搭建過程”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓丸趣 TV 小編來帶大家學習“MySQL8.0 MIC 高可用集群的搭建過程”吧!

一,集群部署

1.1 安裝環境;

操作系統:Linux,版本:CentOS-7-x86

介質準備:無

環境清理

釋放 yum 進程

[root@bug ~]# ps -ef|grep yum
root    
22481
 1694
 5
17:23
?        00:00:03
/usr/bin/python /usr/share/PackageKit/helpers/yum/yumBackend.py
get-updates none
root    
22591
22507
 1
17:24
pts/
   00:00:00
grep –color=auto yum
[root@bug ~]# kill -9
22481

查看是否有多余系統,有則卸載

1

2

[root@bug ~]# rpm -qa|grep mairadb

[root@bug ~]# rpm -qa|grep mysql

關閉防火墻

1

2

3

4

[root@bug ~]# systemctl status firewalld.service

● firewalld.service – firewalld – dynamic firewall daemon

 Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)

 Active: inactive (dead)

關閉 selinux,重啟系統后生效

[root@bug selinux]# vi /etc/selinux/config
SELINUX=disabled

[root@bug selinux]# reboot

1.2 安裝 MySQL8.0

1

2

3

[root@bug ~]# yum install -y wget https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

[root@bug ~]# yum list|grep mysql

[root@bug ~]# yum install -y mysql-community-client.x86_64 mysql-router.x86_64 mysql-shell.x86_64

采用 YUM 源安裝方式,總下載量約 400M,

1.3 自動集群部署

部署節點 1

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

[root@bug ~]# mysqlsh

 

 MySQL  JS   dba.deploySandboxInstance(3310);

A new MySQL sandbox instance will be created on this host in

/root/mysql-sandboxes/3310

 

Warning: Sandbox instances are only suitable for deploying and

running on your local machine for testing purposes and are not

accessible from external networks.

 

Please enter a MySQL root password for the new instance: ******

Deploying new MySQL instance…

 

Instance localhost:3310 successfully deployed and started.

Use shell.connect(root@localhost:3310 to connect to the instance.

第一個節點部署完畢,端口設置為 3310,登陸賬號為 root@localhost,密碼  ******

使用本地認證的方式,登陸數據庫實例,進行驗證。

1

2

3

[root@bug ~]# mysql -uroot -porange -S /root/mysql-sandboxes/3310/sandboxdata/mysqld.sock

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

同樣的方法,部署節點 2,節點 3。

1

2

3

MySQL  JS   dba.deploySandboxInstance(3320);

 

MySQL  JS dba.deploySandboxInstance(3330);

1.4 創建集群

此實驗采用簡單的創建本地集群。

1

2

3

4

5

6

7

8

9

10

11

12

MySQL  JS   \connect root@localhost:3310

Creating a session to  root@localhost:3310

 

*****************************************************

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

A new InnoDB cluster will be created on instance  root@localhost:3310 .

 

*********************************************************

 

Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.

At least 3 instances are needed for the cluster to be able to withstand up to

one server failure.

集群系統已經創建成功,最后一行:At least 3 instances are needed for the cluster to be able to withstand up to one server failure. 提示需要至少三個實例,才能保證災備,所以接下來,將節點 2,3 添加進集群。

1

2

3

4

5

6

7

8

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

 

The instance  root@localhost:3320  was successfully added to the cluster.

 

 

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

 

The instance  root@localhost:3330  was successfully added to the cluster.

查看集群狀態

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

MySQL  localhost:3310 ssl  JS dba.getCluster().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

}

一個簡單的包含三個節點的集群已經創建完成。可以完成數據同步,讀寫分離等功能,比如此刻 3310 端口的狀態是 R/W,同時 read 與 write,3320 與 3330 的狀態是 R/O,只讀模式。

1.5 配置中間件

此時的集群的高可用性還不完整,需要 MySQL-router 來完成集群與外部的對接,實現自動切換,故障轉移等功能。

MySQL-router 的作用類似 keepalived 類的中間件。當主機發生故障后,自動將應用切換到其他實例。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

[root@bug ~]#  mysqlrouter –bootstrap root@localhost:3310 –user=mysqlrouter

Please enter MySQL password for root: *****

 

Bootstrapping system MySQL Router instance…

Checking for old Router accounts

Creating account mysql_router2_j05xzi45m81x@ %

MySQL Router  has now been configured for the InnoDB cluster  test .

 

The following connection information can be used to connect to the cluster.

 

Classic MySQL protocol connections to cluster  test :

– Read/Write Connections: localhost:6446

– Read/Only Connections: localhost:6447

X protocol connections to cluster  test :

– Read/Write Connections: localhost:64460

– Read/Only Connections: localhost:64470

 

Existing configurations backed up to  /etc/mysqlrouter/mysqlrouter.conf.bak

[root@bug ~]# mysqlrouter

[1] 25602

[root@bug ~]#  ps -ef|grep router

mysqlro+ 25602 22507  8 19:35 pts/0  00:00:01 mysqlrouter

root  25619 22507  0 19:36 pts/0  00:00:00 grep –color=auto router

驗證 MySQL-router 安裝效果

在 MySQL-router 默認配置下,

主機端口:6446

從庫端口:6447

1

2

3

4

5

[root@bug ~]#  mysql -uroot -h 127.0.0.1 -P 6446 -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

********************************************************8

mysql

證明 MySQL-router 配置完成可用。

 1.6 驗證集群效果

1, 通過 router 同時登陸三個節點,查看端口號。

2, 在節點 1 構造數據,在節點 2,3 差看狀態,驗證數據同步性。

3, 節點 1(主機)離線,查看集群狀態與節點 2,節點 3 狀態,驗證災備能力。

到此,相信大家對“MySQL8.0 MIC 高可用集群的搭建過程”有了更深的了解,不妨來實際操作一番吧!這里是丸趣 TV 網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-28發表,共計4979字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 鄢陵县| 光泽县| 图们市| 新龙县| 鄢陵县| 庆安县| 昭苏县| 囊谦县| 夏邑县| 古田县| 康保县| 安岳县| 福州市| 湟中县| 中方县| 天镇县| 长沙县| 彰武县| 鄂州市| 炎陵县| 灌阳县| 宝兴县| 哈巴河县| 青铜峡市| 自贡市| 巴林左旗| 喀喇沁旗| 吐鲁番市| 沭阳县| 金湖县| 吴堡县| 札达县| 容城县| 托克托县| 车致| 林周县| 赤壁市| 松溪县| 革吉县| 丹阳市| 梁平县|