真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

配置及安裝drbd+corosync實(shí)現(xiàn)高可用mysql教程

下文給大家?guī)?lái)有關(guān)配置及安裝drbd+corosync實(shí)現(xiàn)高可用MySQL教程內(nèi)容,相信大家一定看過類似的文章。我們給大家?guī)?lái)的有何不同呢?一起來(lái)看看正文部分吧,相信看完配置及安裝drbd+corosync實(shí)現(xiàn)高可用mysql教程你一定會(huì)有所收獲。

創(chuàng)新互聯(lián)建站專注于鳳陽(yáng)網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供鳳陽(yáng)營(yíng)銷型網(wǎng)站建設(shè),鳳陽(yáng)網(wǎng)站制作、鳳陽(yáng)網(wǎng)頁(yè)設(shè)計(jì)、鳳陽(yáng)網(wǎng)站官網(wǎng)定制、微信小程序定制開發(fā)服務(wù),打造鳳陽(yáng)網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供鳳陽(yáng)網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。

前提:

本配置共有兩個(gè)測(cè)試節(jié)點(diǎn),分別node1和node2,相的IP地址分別為202.207.178.6和202.207.178.7,管理節(jié)點(diǎn)202.207.178.8,對(duì)node1和node2進(jìn)行配置。此時(shí)已經(jīng)配置好drbd,并且可以正常工作了!

(為避免影響,先關(guān)閉防火墻和SElinux,DRBD相關(guān)配置詳見http://10927734.blog.51cto.com/10917734/1867283)

一、安裝corosync

1、先停止drbd服務(wù),并禁止其開機(jī)自動(dòng)啟動(dòng)

主節(jié)點(diǎn):

[root@node2 ~]# umount /mydata/

[root@node2 ~]# drbdadm secondary mydrbd

[root@node2 ~]# service drbd stop

[root@node2 ~]# chkconfig drbd off

從節(jié)點(diǎn):

[root@node1 ~]# service drbd stop

[root@node1 ~]# chkconfig drbd off

2、安裝相關(guān)軟件包

[root@fsy ~]# for I in {1..2}; do ssh node$I 'mkdir /root/corosync/'; scp *.rpm node$I:/root/corosync; ssh node$I 'yum -y --nogpgcheck localinstall /root/corosync/*.rpm'; done

(將heartbeat-3.0.4-2.el6.i686.rpm和heartbeat-libs-3.0.4-2.el6.i686.rpm復(fù)制到主目錄下進(jìn)行)

[root@fsy ~]# for I in {1..2}; do ssh node$I 'yum -y install cluster-glue corosync            libesmtp pacemaker pacemaker-cts'; done

3、創(chuàng)建所需日志目錄

[root@node1 corosync]# mkdir /var/log/cluster

[root@node2 ~]# mkdir /var/log/cluster

4、配置corosync,(以下命令在node1上執(zhí)行),并嘗試啟動(dòng)

# cd /etc/corosync

# cp corosync.conf.example corosync.conf

接著編輯corosync.conf,添加如下內(nèi)容:

修改以下語(yǔ)句:

bindnetaddr: 202.207.178.0 #網(wǎng)絡(luò)地址,節(jié)點(diǎn)所在的網(wǎng)絡(luò)地址段

secauth: on #打開安全認(rèn)證

threads: 2 #啟動(dòng)的線程數(shù)

to_syslog: no (不在默認(rèn)位置記錄日志)

添加如下內(nèi)容,定義pacemaker隨corosync啟動(dòng),并且定義corosync的工作用戶和組:

service {

 ver:  0

 name: pacemaker

}

aisexec {

 user: root

 group: root

}

生成節(jié)點(diǎn)間通信時(shí)用到的認(rèn)證密鑰文件:

# corosync-keygen

將corosync和authkey復(fù)制至node2:

# scp -p corosync.conf authkey  node2:/etc/corosync/

嘗試啟動(dòng),(以下命令在node1上執(zhí)行):

# service corosync start

注意:?jiǎn)?dòng)node2需要在node1上使用如上命令進(jìn)行,不要在node2節(jié)點(diǎn)上直接啟動(dòng)

# ssh node2 '/etc/init.d/corosync start'

5、測(cè)試是否正常

查看corosync引擎是否正常啟動(dòng):

# grep -e "Corosync Cluster Engine" -e "configuration file"     /var/log/cluster/corosync.log

    輸出以下內(nèi)容:

Oct 23 00:38:06 corosync [MAIN  ] Corosync Cluster Engine ('1.4.7'): started and ready to provide service.

Oct 23 00:38:06 corosync [MAIN  ] Successfully read main configuration file '/etc/corosync/corosync.conf'

查看初始化成員節(jié)點(diǎn)通知是否正常發(fā)出:

# grep TOTEM /var/log/cluster/corosync.log

    輸出如下內(nèi)容:

Oct 23 00:38:06 corosync [TOTEM ] Initializing transport (UDP/IP Multicast).

Oct 23 00:38:06 corosync [TOTEM ] Initializing transmit/receive security: libtomcrypt SOBER128/SHA1HMAC (mode 0).

Oct 23 00:38:06 corosync [TOTEM ] The network interface [202.207.178.6] is now up.

Oct 23 00:39:35 corosync [TOTEM ] A processor joined or left the membership and a new membership was formed.

檢查啟動(dòng)過程中是否有錯(cuò)誤產(chǎn)生:

# grep ERROR: /var/log/messages | grep -v unpack_resources

查看pacemaker是否正常啟動(dòng):

# grep pcmk_startup /var/log/cluster/corosync.log

    輸出如下內(nèi)容:

Oct 23 00:38:06 corosync [pcmk  ] info: pcmk_startup: CRM: Initialized

Oct 23 00:38:06 corosync [pcmk  ] Logging: Initialized pcmk_startup

Oct 23 00:38:06 corosync [pcmk  ] info: pcmk_startup: Maximum core file size is:     4294967295

Oct 23 00:38:06 corosync [pcmk  ] info: pcmk_startup: Service: 9

Oct 23 00:38:06 corosync [pcmk  ] info: pcmk_startup: Local hostname: node1

使用如下命令查看集群節(jié)點(diǎn)的啟動(dòng)狀態(tài):

# crm_mon

Last updated: Tue Oct 25 17:28:10 2016          Last change: Tue Oct         25 17:21:56 2016 by hacluster via crmd on node1

Stack: classic openais (with plugin)

Current DC: node1 (version 1.1.14-8.el6_8.1-70404b0) - partition with         quorum

2 nodes and 0 resources configured, 2 expected votes

Online: [ node1 node2 ]

從上面的信息可以看出兩個(gè)節(jié)點(diǎn)都已經(jīng)正常啟動(dòng),并且集群已經(jīng)處于正常工作狀態(tài)。

二、配置資源及約束

1、安裝crmsh軟件包:

    pacemaker本身只是一個(gè)資源管理器,我們需要一個(gè)接口才能對(duì)pacemker上的資源進(jìn)行定義與管理,而crmsh即是pacemaker的配置接口,從pacemaker 1.1.8開始,crmsh 發(fā)展成一個(gè)獨(dú)立項(xiàng)目,

pacemaker中不再提供。crmsh提供了一個(gè)命令行的交互接口來(lái)對(duì)Pacemaker集群進(jìn)行管理,它具有更強(qiáng)大的管理功能,同樣也更加易用,在更多的集群上都得到了廣泛的應(yīng)用,類似軟件還有 pcs;

在/etc/yum.repo.d/ 下的配置文件中添加以下內(nèi)容

[ewai]

name=aaa

baseurl=http://download.opensuse.org/repositories/network:/ha-            clustering:/Stable/CentOS_CentOS-6/

enabled=1

gpgcheck=0

# yum clean all

# yum makecache

[root@node1 yum.repos.d]# yum install crmsh

2、檢查配置文件有無(wú)語(yǔ)法錯(cuò)誤,并進(jìn)行相關(guān)配置

crm(live)configure# verify

我們里可以通過如下命令先禁用stonith:

# crm configure property stonith-enabled=false 

或 crm(live)configure# property stonith-enabled=false

  crm(live)configure# commit

配置不具備法定票數(shù)的處理方式:

crm(live)configure# property no-quorum-policy=ignore

crm(live)configure# verify

crm(live)configure# commit

配置資源粘性,使資源更愿意留在當(dāng)前節(jié)點(diǎn)

crm(live)configure# rsc_defaults resource-stickiness=100

crm(live)configure# verify

crm(live)configure# commit

3、配置資源

定義一個(gè)名為mysqldrbd的資源:

(interval:定義監(jiān)控的時(shí)間間隔)

crm(live)configure# primitive mysqldrbd ocf:linbit:drbd params drbd_resource=mydrbd op start timeout=240 op stop timeout=100 op monitor role=Master interval=20 timeout=30 op monitor role=Slave interval=30 timeout=30

crm(live)configure# verify

定義一個(gè)名為ms_mysqldrbd的主從類型的資源:

指明是mysqldrbd的克隆,master-max=1:定義最多出現(xiàn)1個(gè)主資源,master-node-max=1:主資源在同一時(shí)刻只能出現(xiàn)在一個(gè)節(jié)點(diǎn)上,clone-max=2:定義最多有兩個(gè)克隆資源,clone-node-max:定義在每個(gè)節(jié)點(diǎn)上只能啟動(dòng)1個(gè)克隆資源

crm(live)configure# ms ms_mysqldrbd mysqldrbd meta master-max=1 master-node-max=1               clone-max=2 clone-node-max=1 notify=true

crm(live)configure# verify

crm(live)configure# commit

4、測(cè)試

[root@node1 ~]# crm status

Last updated: Sun Oct 23 13:05:43 2016 Last change: Sun Oct 23         13:03:52 2016 by root via cibadmin on node1

Stack: classic openais (with plugin)

Current DC: node1 (version 1.1.14-8.el6_8.1-70404b0) - partition with         quorum

2 nodes and 2 resources configured, 2 expected votes

Online: [ node1 node2 ]

Full list of resources:

Master/Slave Set: ms_mysqldrbd [mysqldrbd]

Masters: [ node1 ]

Slaves: [ node2 ]

[root@node1 ~]# drbd-overview 

0:mydrbd  Connected Primary/Secondary UpToDate/UpToDate C r----- 

[root@node1 ~]# crm node standby

[root@node1 ~]# crm status

Last updated: Sun Oct 23 13:06:30 2016 Last change: Sun Oct 23             13:06:25 2016 by root via crm_attribute on node1

Stack: classic openais (with plugin)

Current DC: node1 (version 1.1.14-8.el6_8.1-70404b0) - partition with         quorum

2 nodes and 2 resources configured, 2 expected votes

Node node1: standby

Online: [ node2 ]

Full list of resources:

Master/Slave Set: ms_mysqldrbd [mysqldrbd]

Masters: [ node2 ]

Stopped: [ node1 ]

[root@node1 ~]# crm node online

[root@node1 ~]# crm status

Last updated: Sun Oct 23 13:07:00 2016 Last change: Sun Oct 23         13:06:58 2016 by root via crm_attribute on node1

Stack: classic openais (with plugin)

Current DC: node1 (version 1.1.14-8.el6_8.1-70404b0) - partition with         quorum

2 nodes and 2 resources configured, 2 expected votes

Online: [ node1 node2 ]

Full list of resources:

Master/Slave Set: ms_mysqldrbd [mysqldrbd]

Masters: [ node2 ]

Slaves: [ node1 ]

服務(wù)正常!

5、配置一個(gè)文件系統(tǒng)資源,使DRBD自動(dòng)掛載,并配置排列約束,使此資源和主節(jié)點(diǎn)在一起;同時(shí)配置一個(gè)順序約束,實(shí)現(xiàn)先啟動(dòng)drbd,再啟動(dòng)mystor

crm(live)configure# primitive mystore ocf:Filesystem params device=/dev/drbd0               directory=/mydata fstype=ext4 op start timeout=60 op stop               timeout=60

crm(live)configure# verify

crm(live)configure# colocation mystore_with_ms_mysqldrbd inf: mystore                   ms_mysqldrbd:Master

crm(live)configure# order mystore_after_ms_mysqldrbd mandatory:                       ms_mysqldrbd:promote mystore:start

crm(live)configure# verify

crm(live)configure# commit

測(cè)試:

[root@node2 ~]# crm node standby

[root@node2 ~]# crm status

Last updated: Sun Oct 23 13:45:26 2016 Last change: Sun             Oct 23 13:45:20 2016 by root via crm_attribute on node2

Stack: classic openais (with plugin)

Current DC: node2 (version 1.1.14-8.el6_8.1-70404b0) - partition             with quorum

2 nodes and 3 resources configured, 2 expected votes

Node node2: standby

Online: [ node1 ]

Full list of resources:

Master/Slave Set: ms_mysqldrbd [mysqldrbd]

Masters: [ node1 ]

Stopped: [ node2 ]

mystore (ocf::heartbeat:Filesystem): Started node1

[root@node1 yum.repos.d]# ls /mydata/

fsy  lost+found

此時(shí)測(cè)試,一切正常!

三、安裝Mysql(先在主節(jié)點(diǎn)上,后在從節(jié)點(diǎn)上)

1.將下載好的壓縮包解壓至/usr/local,并進(jìn)入此目錄

#tar xf mysql-5.5.52-linux2.6-i686.tar.gz -C /usr/local

#cd /usr/local/

2.為解壓后的目錄創(chuàng)建一個(gè)鏈接,并進(jìn)入此目錄

#ln -sv mysql-5.5.52-linux2.6-i686 mysql

#cd mysql

3.創(chuàng)建MySQL用戶(使其成為系統(tǒng)用戶)和MySQL組

#groupadd -r -g 306 mysql

#useradd -g 306 -r -u 306 mysql

4.使mysql下的所有文件都屬于mysql用戶和mysql組

#chown -R mysql:mysql /usr/local/mysql/*

5.創(chuàng)建數(shù)據(jù)目錄,并使其屬于mysql用戶和mysql組,其他人無(wú)權(quán)限

#mkdir /mydata/data

#chown -R mysql:mysql /mydata/data/

#chmod o-rx /mydata/data/

6.準(zhǔn)備就緒,開始安裝

#scripts/mysql_install_db --user=mysql --datadir=/mydata/data/

7.安裝完成后為了安全,更改/usr/local/mysql下所有文件的權(quán)限

#chown -R root:mysql /usr/local/mysql/*

8.準(zhǔn)備啟動(dòng)腳本,并禁止其開機(jī)自動(dòng)啟動(dòng)

#cp support-files/mysql.server /etc/init.d/mysqld

#chkconfig --add mysqld

#chkconfig mysqld off

9.編輯數(shù)據(jù)庫(kù)配置文件

#cp support-files/my-large.cnf /etc/my.cnf

#vim /etc/my.cnf,修改和添加以下內(nèi)容:

thread_concurrency =2(因?yàn)槲业腃PU數(shù)為1,所以線程數(shù)改為2)

datadir = /mydata/data

10.啟動(dòng)mysql

# service mysqld start

# /usr/local/mysql/bin/mysql

11.測(cè)試是否正常

mysql> show databases;

mysql> CREATE DATABASE mydb;

mysql> show databases;

12.關(guān)閉主節(jié)點(diǎn)上的mysql服務(wù),使從節(jié)點(diǎn)變?yōu)橹鞴?jié)點(diǎn),安裝mysql

[root@node1 mysql]# service mysqld stop

[root@node1 mysql]# crm node standby

[root@node1 mysql]# crm node online

13.將下載好的壓縮包解壓至/usr/local,并進(jìn)入此目錄

#tar xf mysql-5.5.52-linux2.6-i686.tar.gz -C /usr/local

#cd /usr/local/

14.為解壓后的目錄創(chuàng)建一個(gè)鏈接,并進(jìn)入此目錄

#ln -sv mysql-5.5.52-linux2.6-i686 mysql

#cd mysql

15.創(chuàng)建MySQL用戶(使其成為系統(tǒng)用戶)和MySQL組

#groupadd -r -g 306 mysql

#useradd -g 306 -r -u 306 mysql

16.使mysql下的所有文件都屬于root用戶和mysql組

#chown -R root:mysql /usr/local/mysql/*

17.準(zhǔn)備啟動(dòng)腳本,并禁止其開機(jī)自動(dòng)啟動(dòng)

#cp support-files/mysql.server /etc/init.d/mysqld

#chkconfig --add mysqld

#chkconfig mysqld off

18.編輯數(shù)據(jù)庫(kù)配置文件

#cp support-files/my-large.cnf /etc/my.cnf

#vim /etc/my.cnf,修改和添加以下內(nèi)容:

thread_concurrency =2(因?yàn)槲业腃PU數(shù)為1,所以線程數(shù)改為2)

datadir = /mydata/data

19.啟動(dòng)mysql

# service mysqld start

# /usr/local/mysql/bin/mysql

20.測(cè)試是否正常

mysql> show databases;

發(fā)現(xiàn)有mydb數(shù)據(jù)庫(kù)!

測(cè)試成功!

四、配置mysql資源

1、停止主節(jié)點(diǎn)上的mysql服務(wù)

# service mysqld stop

2、定義主資源

crm(live)configure# primitive mysqld lsb:mysqld

crm(live)configure# verify

3、定義資源約束

定義排列約束,使mysqld和mystore在一起

crm(live)configure# colocation mysqld_with_mystore inf: mysqld                       mystore

crm(live)configure# verify

定義順序約束,使mystore先啟動(dòng),mysqld后啟動(dòng)

crm(live)configure# order mysqld_after_mystore mandatory: mystore                       mysqld

crm(live)configure# verify

crm(live)configure# commit

4、測(cè)試

1)在主節(jié)點(diǎn)上連接mysql,并創(chuàng)建數(shù)據(jù)庫(kù)

mysql> CREATE DATABASES hellodb;

mysql> show databases;

2)節(jié)點(diǎn)切換(主節(jié)點(diǎn)上)

# crm node standby

# crm node online

3)在原來(lái)的從節(jié)點(diǎn)(及現(xiàn)在的主節(jié)點(diǎn)上測(cè)試)

mysql> show databases;

發(fā)現(xiàn)有hellodb數(shù)據(jù)庫(kù)!

測(cè)試成功!

至此,drbd+corosync的高可用mysql配置完成!

對(duì)于上文關(guān)于配置及安裝drbd+corosync實(shí)現(xiàn)高可用mysql教程,大家覺得是自己想要的嗎?如果想要了解更多相關(guān),可以繼續(xù)關(guān)注我們的行業(yè)資訊板塊。


網(wǎng)站題目:配置及安裝drbd+corosync實(shí)現(xiàn)高可用mysql教程
網(wǎng)頁(yè)路徑:http://weahome.cn/article/ggppgg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部