RedHat 6.4 搭建rhcs集羣

架構拓撲(圖片摘自網絡)html

wKioL1mDPK-wt7NSAACrmTgZEAo075.png-wh_50

1、實驗環境
node

os:RedHat 6.4linux

node5    192.168.2.200    luci管理端web

node1    192.168.2.103    集羣節點apache

node2    192.168.2.111    集羣節點vim

虛擬IP     192.168.2.110服務器

初始化操做:關閉全部涉及設備的iptables、selinux=disabled、關閉NetworkManager
網絡

:在該步驟中node2.example.com對應上面環境中提到的node1node3.example.com對應上面環境中提到的node2192.168.2.121對應上面環境中提到的192.168.2.200.(因爲實驗是經過幾回完成的,期間涉及到實驗環境重置)架構


2、安裝配置app

2.1)配置YUM倉庫

將系統ISO掛載到本地目錄下,而後更改YUM配置文件。最終YUM倉庫以下(node1/2配置與node5相同):

[root@node5yum.repos.d]# cat rhel-source.repo

[rhel-source]

name=RedHat Enterprise Linux $releasever - $basearch - Source

baseurl=file:///media/

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


[server]

name=RedHat Enterprise Linux $releasever - $basearch - Source

baseurl=file:///media/Server/

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


[HighAvailability]

name=RedHat Enterprise Linux $releasever - $basearch - Source

baseurl=file:///media/HighAvailability/

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


[LoadBalancer]

name=RedHat Enterprise Linux $releasever - $basearch - Source

baseurl=file:///media/LoadBalancer/

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


[ScalableFileSystem]

name=Red HatEnterprise Linux $releasever - $basearch - Source

baseurl=file:///media/ScalableFileSystem/

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


[ResilientStorage]

name=RedHat Enterprise Linux $releasever - $basearch - Source

baseurl=file:///media/ResilientStorage/

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release


2.2)軟件安裝

node5:

安裝scsi-target-utilsluci

node1node2

安裝iscsi-initiator-utilsriccicmanlvm2-clustergfs2-utilsrgmanagerhttpd,部分軟件包在安裝以上包的同時會依賴安裝。

2.3)配置ISCSI Server

node5上待用做共享存儲的硬盤經過fdisk命令劃分區,而後在建立LV建立邏輯卷(也能夠直接將磁盤共享給節點,多種方式自行選擇。此環境中選擇將這個磁盤共享給節點)。

2.3.1)配置target

iSCSI target的名稱規則:iqn.年份-月份.域名反寫.設備識別。

示例:iqn = iSCSI Qualified Name          iqn.2014-07.dev.iscsi-target:iscsidisk

target的主要配置文件位於:/etc/tgt/ targets.conf

配置文件詳情以下:

# This is a sample config file fortgt-admin.

# By default, tgt-admin looks for itsconfig file in /etc/tgt/targets.conf

#

# The "#" symbol disables theprocessing of a line.

……

<targetiqn.2017-06.com.example:node5>

backing-store /dev/sdb

</target>

經過配置文件能夠看出iscsi能夠經過多種方式進行共享給相關主機。同時能夠限定能訪問到該邏輯卷的主機。

2.3.2)啓動iscsi服務

#/etc/init.d/tgtd start

#chkconfig tgtd on

2.3.3)查看iscsi target共享狀態

[root@node5 ~]# tgt-admin --show

Target 1: iqn.2017-6.com.example:node5

   System information:

       Driver: iscsi

       State: ready

   I_T nexus information:

   LUN information:

       LUN: 0

           Type: controller

           SCSI ID: IET     00010000

           SCSI SN: beaf10

            Size: 0 MB, Block size: 1

           Online: Yes

Removable media: No

           Prevent removal: No

           Readonly: No

           Backing store type: null

           Backing store path: None

           Backing store flags:

       LUN: 1

           Type: disk

           SCSI ID: IET     00010001

           SCSI SN: beaf11

           Size: 21475 MB, Block size: 512

           Online: Yes

           Removable media: No

           Prevent removal: No

           Readonly: No

           Backing store type: rdwr

           Backing store path: /dev/sdb

           Backing store flags:

   Account information:

   ACL information:

       ALL

2.4)配置ISCSI Client

2.4.1)設置開機自啓動

#chkconfig iscsid on

#chkconfig iscsi on

2.4.2)更改配置文件

initiator的配置文檔位於/etc/iscsi/,該目錄下有兩個文件initiatorname.iscsiiscsid.conf,其中iscsid.conf 是其配置文件,initiatorname.iscsi 是標記initiator的名稱(默認在該文件下有標註iscsi target服務器的iqn號碼,將iqn號碼更改成本身定義的號碼),由於在target裏面,咱們並無設置訪問限制,因此iscsid.conf 文件並不須要修改。

2.4.3)偵測target

[root@node1 ~]# iscsiadm -m discovery -tsendtargets -p 192.168.2.200

192.168.2.200:3260,1iqn.2017-06.com.example:node5

2.4.4)查看節點

iscsiadm 偵測到的結果會寫入/var/lib/iscsi/nodes/中,所以只需啓動/etc/init.d/iscsi就可以在下次開機時,自動鏈接到正確的target了。

# ll -R /var/lib/iscsi/nodes/

[root@node1 ~]# ll -R /var/lib/iscsi/nodes/

/var/lib/iscsi/nodes/:

total 4

drw-------. 3 root root 4096 Jun 8 23:17 iqn.2017-06.com.example:node5

 

/var/lib/iscsi/nodes/iqn.2017-06.com.example:node5:

total 4

drw-------. 2 root root 4096 Jun 8 23:17 192.168.2.200,3260,1

 

/var/lib/iscsi/nodes/iqn.2017-06.com.example:node5/192.168.2.200,3260,1:

total 4

-rw-------. 1 root root 1815 Jun 8 23:17 default

2.4.5)鏈接target

查看系統下全部的target

[root@node1 ~]# iscsiadm -m node

192.168.2.200:3260,1iqn.2017-06.com.example:node5

登陸target

[root@localhost~]# iscsiadm -m node -T iqn.2017-06.com.example:node5 --login

Loggingin to [iface: default, target: iqn.2017-06.com.example:node5, portal:192.168.2.200,3260] (multiple)

Login to[iface: default, target: iqn.2017-06.com.example:node5, portal:192.168.2.200,3260] successful.à登陸成功

2.5)查看系統下磁盤情況

能夠發現系統下多了一塊sdb磁盤。在系統下能夠將新發現的磁盤sdb進行格式化。

[root@node1 ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disk identifier: 0x000d5cd9


Device Boot      Start         End      Blocks  Id  System

/dev/sda1  *       1          39      307200  83  Linux

Partition 1 does not end on cylinderboundary.

/dev/sda2          39            2342   18500608   83  Linux

/dev/sda3         2342         2611    2162688   82  Linux swap / Solaris


Disk /dev/sdb: 21.5 GB, 21474836480 bytes

64 heads, 32 sectors/track, 20480 cylinders

Units = cylinders of 2048 * 512 = 1048576bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disk identifier: 0x00000000

[root@node2 ~]# fdisk -l

 

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disk identifier: 0x00036e0d

 

Device Boot      Start         End      Blocks  Id  System

/dev/sda1  *       1        1275   10240000   83  Linux

/dev/sda2         1275        1301      204800  82  Linux swap / Solaris

 

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

64 heads, 32 sectors/track, 20480 cylinders

Units = cylinders of 2048 * 512 = 1048576bytes

Sector size (logical/physical): 512 bytes /512 bytes

I/O size (minimum/optimal): 512 bytes / 512bytes

Disk identifier: 0x00000000

2.6)RHCS相關配置

2.6.1)node1/node2配置

[root@node2 ~]# passwd ricci         à自定義密碼

Changing password for user ricci.

New password:

BAD PASSWORD: it is toosimplistic/systematic

BAD PASSWORD: is too simple

Retype new password:

passwd: all authentication tokens updatedsuccessfully.


[root@node2 ~]# /etc/init.d/ricci start  #啓動ricci端口爲11111

Starting oddjobd:               [  OK  ]

generating SSL certificates...  done

Generating NSS database...  done

Starting ricci:                [  OK  ]

[root@node2 ~]# chkconfig ricci on

[root@node2 ~]# chkconfig --list ricci

ricci     0:off 1:off 2:on 3:on 4:on 5:on 6:off

示例中顯示的操做在node2上執行,node1執行相同的操做

2.6.2)node5配置

[root@node5 ~]# /etc/init.d/luci restart

Stop luci...               [  OK  ]

Start luci...              [  OK  ]

Point your web browser tohttps://node5.example.com:8084 (or equivalent) to access luci

[root@node5 ~]# chkconfig --list luci

luci      0:off 1:off 2:on 3:on 4:on 5:on 6:off

2.6.3)經過web方式進行配置

能夠經過https://node5.example.com:8084也能夠經過https://192.168.2.200:8084訪問

wKioL1mDRG-iGBB7AAGXZ69deyo595.png-wh_50

redhat6中,luci的登陸用戶名和密碼與root帳號相同。而在redhat5中須要經過

#luci_admin init(沒有親測)來進行初始化而後再設置密碼,輸入兩次密碼後,就會默認建立一個登陸luci的用戶admin。有時候會在登陸界面左上角出現wrong credentials的歎號提示,此時能夠經過從新安裝luci的方式來解決該問題。

wKiom1mD-fTBBi-BAAE-JRPMTBM014.png-wh_50


登陸成功後的界面

wKiom1mD-k3SQg0zAAF20X6WaFM729.png-wh_50


建立集羣

wKioL1mD-ouwg85cAAHeJZ7Ygpc359.png-wh_50

Download Packages:表示在線下載並自動安裝RHCS軟件包。

Use Locally Installed Packages:表示利用本地安裝包進行安裝。因爲以前已經手動安裝了RHCS的相關組件,因此這裏能夠選擇該選項。

Enable Shared Storage Support:表示啓動共享存儲支持。

Reboot Nodes Before Joining Cluster:當節點加入集羣時,重啓系統。


wKioL1mD-rrQi4sBAAGsfn8i3rM415.png-wh_50

出現該錯誤界面修改ricci密碼以後從新啓動ricci便可消除


wKioL1mD-wuS-cXmAAGYMlZcvEQ916.png-wh_50

出現錯誤提示:不是集羣節點。出現該現象一般爲cman、rgmanager沒有啓動致使。在啓動cman過程當中會一直報錯,此時須要將NetworkManager關閉再次重啓cman服務便可。


wKioL1mD-9WCtdCoAAGWbr4sZbc327.png-wh_50

出現如上圖所示的效果表示rhcs建立成功。(但一個節點顯示uptime另外一個不顯示,經過點擊node1/node2兩個節點來查看節點啓動的相關服務,會發現節點啓動的服務不一致)


wKioL1mD_BOQvBEpAAIOk73s7rI046.png-wh_50

最終出現上圖所示的狀態,說明兩節點全部服務啓動正常。


wKiom1mD_HeiY65VAAE-e_56hV8896.png-wh_50

注意:

在集羣節點加入cluster以後,個別服務可能沒有啓動,所以須要執行下面命令。

#/etc/init.d/rgmanager start

#/etc/init.d/modclusterd start à若是該服務沒有啓動,則在uptime一欄顯示爲空

#/etc/init.d/clvmd start

#/etc/init.d/cman start

#chkconfig rgmanager on

#chkconfig modclusterd on

#chkconfig clvmd on

#chkconfig cman on


2.6.3.1)集羣驗證

經過上面的步驟最終完成了集羣的建立,此時能夠經過分別在node1/node2上執行命令查看集羣是否配置成功。

[root@node1 ~]# clustat

Cluster Status for cluster_test @ Mon Jul10 23:19:27 2017

Member Status: Quorate

 

 Member Name                          ID   Status

 ------ ----                                ----  ------

 node1                                 1  Online, Local

 node2                                 2  Online

[root@node2 ~]# clustat

Cluster Status for cluster_test @ Mon Jul10 23:19:16 2017

Member Status: Quorate

 

 Member Name                    ID   Status

 ------ ----                          ----  ------

 node1                            1 Online

 node2                            2  Online, Local


2.6.4)添加服務

2.6.4.1)添加fence

:在該步驟中node2.example.com對應上面環境中提到的node1node3.example.com對應上面環境中提到的node2192.168.2.121對應上面環境中提到的192.168.2.200.(因爲實驗是經過幾回完成的,期間涉及到實驗環境重置)

wKioL1mD_XSBRw3vAAIp_zG4mM0524.png-wh_50

wKiom1mD_ZGSo-DUAAHyJ_BO7eY353.png-wh_50

返回到nodes標籤下,選中其中一個節點(如node2.example.com),就會出現該節點的詳情信息。而後再點擊add fence method

wKiom1mD_cuBbQtCAAJ3UzWq-8s429.png-wh_50

注意:添加的method name爲剛纔建立的fence

wKiom1mD_fPCVEmTAAIAD9ZJloY692.png-wh_50

wKioL1mD_ifwKo9LAAKRg7GEl5Y530.png-wh_50

wKiom1mD_lWwoMfJAAHFb80JKmw315.png-wh_50


wKioL1mD_nzB7H6pAAGb5mNRRxw419.png-wh_50

此時能夠看到建立的fence已經被一個節點使用。

按照一樣的方法將剛剛建立的fence設備添加到集羣中的另外一個節點上。最終顯示的效果以下:

wKioL1mD_vaihpWbAAF09M4VJQ4070.png-wh_50


2.6.4.2)添加漂移IP(虛擬IP)

點擊luci頁面上的Resource,選擇IP Address,注意:Netmask Bits必須是掩碼位(81624)類型,不能是255.255.255.0,不然服務不能啓動。

wKiom1mD_1uxbi1tAAG7SKvPTsA828.png-wh_50

wKioL1mD_4SgmdhiAAH1jSOOTv4423.png-wh_50

wKioL1mD_7KwT6XsAAHKdgtRAHI222.png-wh_50


2.6.4.3)添加Apache資源

點擊luci頁面上的Resource,一般luci添加資源界面會有不少既定的資源選項,此時選擇apache(若是碰到沒有的選項則須要選擇script,指定個名字,還有腳本路徑便可。此實驗中嘗試選擇apache後發現添加的service groups老是failed,所以最終選擇添加script方式。以下圖所示)。

wKioL1mD__jiyRePAAIguR5EDus655.png-wh_50

在添加完成httpd服務以後,須要在apache的配置文件下/etc/httpd/conf/httpd.conf進行相關的更改,此例作的更改以下:

[root@node1 conf]# pwd

/etc/httpd/conf

[root@node1 conf]# ls

httpd.conf magic

[root@node1 conf]# vim httpd.conf à在配置文件的最末尾添加標紅字符,node2節點同理

……

<VirtualHost *:80>

        DocumentRoot /var/www/html/

        ServerName node1.example.com

</VirtualHost>

在每一個節點的/var/www/html目錄下建立index.html,且在index.html下編寫相關文字。


2.6.4.4)添加Failover Domain

將兩個節點加入fa失效域,當node1出現問題,服務將切換到node2上,默認服務啓動在node1上,由於數字越小,優先級越高。

wKioL1mEAXbRx8EwAAIFo1I1XzU825.png-wh_50

Prioritized 設定節點優先級
Restricted 指定運行某服務的節點主機 
No Failback 勾選時,優先級高的節點主機宕機服務轉移到其餘節點,其恢復後,服務再也不轉移到該節點。


2.6.4.5)添加Service Groups

輸入一個服務名user-testAutomatically Start This Service 自動啓動服務,將FailoverDomain設置爲fa,點擊Add resource添加剛纔加的資源。

wKioL1mEAcuRTh9wAAIlFZtXwSE390.png-wh_50

wKioL1mEAeiQjpw1AAH0ph9_Qw8843.png-wh_50

Run Exclusive 專注的運行這一種service

Recovery Policy選擇Relocate,服務節點出現問題,轉移服務至其它節點。


2.6.4.5.1)添加Resource到service groups

添加vip以及httpd服務

wKioL1mEApHTMZgsAABuV1C5i94082.png-wh_50

wKiom1mEAqyQb6m7AACcgAf5Ewg067.png-wh_50

而後服務組會自動運行在優先級高的節點機上,node1的優先級爲1node2的優先級爲10,數字越小優先級越高。


2.6.4.6)驗證配置結果

node1上查看集羣狀態

[root@node1 ~]# clustat

Cluster Status for mycluster @ Mon Jun 1202:24:52 2017

Member Status: Quorate

 

 Member Name                           ID   Status

 ------ ----                           ---- ------

 node1                               1Online, Local, rgmanager

 node2                               2 Online, rgmanager

 

 Service Name      Owner(Last)                State        

 ------- ----       ----- ------                     -----        

 service:userzr-ser                               node1                                                                                                         started    

查看漂移IP所在的位置

[root@node1 ~]# ip addr show

1: lo: <LOOPBACK,UP,LOWER_UP> mtu16436 qdisc noqueue state UNKNOWN

   link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

   inet 127.0.0.1/8 scope host lo

   inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>mtu 1500 qdisc pfifo_fast state UP qlen 1000

   link/ether 00:0c:29:e8:16:46 brd ff:ff:ff:ff:ff:ff

   inet 192.168.2.103/24 brd 192.168.2.255 scope global eth0

    inet 192.168.2.110/24 scope global secondary eth0

   inet6 fe80::20c:29ff:fee8:1646/64 scope link

      valid_lft forever preferred_lft forever

3: eth1:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen1000

   link/ether 00:0c:29:e8:16:50 brd ff:ff:ff:ff:ff:ff

   inet 10.0.0.2/24 brd 10.0.0.255 scope global eth1

   inet6 fe80::20c:29ff:fee8:1650/64 scope link

      valid_lft forever preferred_lft forever

4: pan0: <BROADCAST,MULTICAST> mtu1500 qdisc noop state DOWN

link/ether22:8c:60:ee:9f:24 brd ff:ff:ff:ff:ff:ff

查看httpd服務是否啓動

當集羣的owner(last)是哪一個節點,則哪一個節點上的相關服務就被啓動,此例子中的服務是httpd

[root@node1 ~]# /etc/init.d/httpd status

httpd (pid 19276) is running...


2.6.5)掛載文件系統

在客戶端設置完initiatorname.iscsi以後,執行以下命令便可:

# iscsiadm -m discovery -t sendtargets -p xxx(ip地址)

#iscsiadm -m node

# iscsiadm -m node -T iqn.2017-05.com.example:node5(iqn號碼自定義) --login

最終就會在系統下發現相關的分區

[root@node1 ~]# fdisk -l

 

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000d5cd9


  Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *        1          39      307200  83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2            39        2342    18500608  83  Linux

/dev/sda3         2342        2611     2162688  82  Linux swap / Solaris

 

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

64 heads, 32 sectors/track, 20480 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xb58b5eff

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1        1025    1049584   83  Linux

/dev/sdb2           1026       20480    19921920  83  Linux

此時能夠看出sdb爲新發現的磁盤。且分了兩個分區。


2.6.6)集羣文件系統的建立

CLVM的做用相似與LVM,但集羣文件系統後期若是有規劃在線擴容的操做必需要開啓clvmd(分發邏輯卷的狀態更新<一個節點上操做磁盤分區成功後、另外一個節點上也會發生一樣的效果變化>)這個功能。

[root@node1 ~]# lvmconf #查看幫助選項

usage: /sbin/lvmconf <command>

 

Commands:

Enable clvm: --enable-cluster [--lockinglibdir <dir>] [--lockinglib<lib>]

Disable clvm: --disable-cluster

Set locking library: --lockinglibdir <dir> [--lockinglib<lib>]


Global options:

Config file location: --file <configfile>

[root@node1 ~]# lvmconf --enable-cluster       使邏輯卷支持cluster,分別在node1/2執行

[root@node1 ~]# /etc/init.d/clvmd restart    兩個節點都執行。做用:只需在一個節點上執行邏輯卷操做,全部節點同步

Restarting clvmd:         [OK  ]

將新「映射」到node1/node2的磁盤(sdb)進行分區,在一臺機器上作,另外一臺也會出現建立的分區。


分別在node1/node2上建立pv。

[root@node1 ~]# pvcreate /dev/sdb2

  Physical volume"/dev/sdb2" successfully created

[root@node2 ~]# pvcreate /dev/sdb2

  Physical volume"/dev/sdb2" successfully created


注意:若是在一個節點上沒有運行clvmd服務,則建立pv會出現告警。

[root@node2 ~]# pvs

  clvmd not running onnode node2

  Unable to obtain globallock.

[root@node1 ~]# vgcreate --help

  vgcreate: Create avolume group

vgcreate

       [-A|--autobackup{y|n}]

       [--addtag Tag] 

       [--alloc AllocationPolicy]

       [-c|--clustered{y|n}]

       [-d|--debug]

       [-h|--help]

       [-l|--maxlogicalvolumesMaxLogicalVolumes]

       [-M|--metadatatype1|2]

       [--[vg]metadatacopies#copies]

       [-p|--maxphysicalvolumesMaxPhysicalVolumes]

       [-s|--physicalextentsizePhysicalExtentSize[bBsSkKmMgGtTpPeE]]

       [-t|--test]

       [-v|--verbose]

       [--version]

       [ PHYSICAL DEVICEOPTIONS ]

       VolumeGroupNamePhysicalDevicePath [PhysicalDevicePath...]

c 支持集羣功能,y---yes , n---no

[root@node1 ~]# vgcreate -cy clustervg /dev/sdb2

  Clustered volume group"clustervg" successfully created

(若是僅僅在node1上建立pv而後就直接在node1上建立vg/lv,會提示報錯:

Error locking on node node2: Volume group for uuid not found:d4EUWKtp6A37RownBShXDrj00ZuZYm7MdUJgXHMZTZ5CFXemlhEfJc1DrVJhHyMU

  Failed to activate newLV.)


[root@node1 ~]# lvcreate -l 4863 -n clusterlv clustervg

  Logical volume"clusterlv" created 

2.6.6.1)建立GFS文件系統

#cat /etc/cluster/cluster.conf  #查看集羣的名稱

[root@node1 /]# cman_tool status #查看集羣相關信息,其中涉及到集羣名稱

Version: 6.2.0

Config Version: 7

Cluster Name: cluster_test

Cluster Id: 42965

Cluster Member: Yes

Cluster Generation: 148

Membership state: Cluster-Member

Nodes: 2

Expected votes: 1

Total votes: 2

Node votes: 1

Quorum: 1 

Active subsystems: 9

Flags: 2node

Ports Bound: 0 11 177 

Node name: node1

Node ID: 1


Multicast addresses: 239.192.167.125

Node addresses: 192.168.2.103


格式化文件系統

[root@node1 /]# mkfs.gfs2 -p lock_dlm -t cluster_test:gfs -j 3/dev/clustervg/clusterlv

This will destroy any data on /dev/clustervg/clusterlv.

It appears to contain: symbolic link to `../dm-0'

 

Are you sure you want to proceed? [y/n] y

Device:                   /dev/clustervg/clusterlv

Blocksize:                4096

Device Size               19.00 GB (4979712 blocks)

Filesystem Size:          19.00 GB (4979711 blocks)

Journals:                 3

Resource Groups:          76

Locking Protocol:         "lock_dlm"

Lock Table:               "cluster_test:gfs"

UUID:                     4561c8ab-66a6-c41a-d95c-38ce9314b516


格式話完成以後,在系統下能夠出現以下所示的效果:

[root@node1 conf]# blkid

/dev/sda1: UUID="797995cc-52d1-4a15-b38b-b522ad8ede2d"TYPE="ext4"

/dev/sda2:UUID="wtLL6x-4JQJ-X3VL-3QKM-jF1u-f5YX-IfuXnM"TYPE="LVM2_member"

/dev/mapper/VolGroup-lv_root:UUID="7b7c269f-aa59-446f-b610-087438bce9d5" TYPE="ext4"

/dev/mapper/VolGroup-lv_swap:UUID="f06cd436-49fa-4ad6-b6e1-ccc896187d9f" TYPE="swap"

/dev/sdb2: UUID="7hRtF5-WfJo-RRcv-luEx-IdkC-Zho8-RPL2x2"TYPE="LVM2_member"

/dev/mapper/clustervg-clusterlv: LABEL="test:gfs"UUID="ca9baac8-413b-cd0a-a7b6-1ccf6d0f652b" TYPE="gfs2"

注意:

若是出現上述結果,說明文件系統格式化徹底,sdb2分區所建立的lv被系統完美的識別。但另一個節點會存在沒有上述紅色字體所示的效果,此時能夠將該節點reboot


經過將新建的lv臨時掛載在本地的某個目錄下來驗證新建的lv是否已經生效,同時掛載後還能查看文件系統格式是否正確。驗證以後再將lv卸載掉。

node1上掛載新建的LV

[root@node1 /]# mount /dev/clustervg/clusterlv /data/ànode2上執行一樣操做

[root@node1 /]# df -hT

Filesystem    Type    Size Used Avail Use% Mounted on

/dev/sda2     ext4     18G 2.5G   15G  15% /

tmpfs        tmpfs    491M  32M  460M   7% /dev/shm

/dev/sda1     ext4    291M  33M  243M  12% /boot

/dev/sr0   iso9660    3.5G 3.5G     0 100% /mnt/cdrom

/dev/mapper/clustervg-clusterlv

              gfs2     19G 388M   19G   2% /data

2.6.6.2)添加gfs文件系統資源

wKiom1mECA7zScaIAAGJj-p82ok619.png-wh_50

將文件系統資源添加到servicegroups,是的文件系統in use顯示爲勾。

wKioL1mECEyiZP9VAAGJj-p82ok688.png-wh_50

2.6.7)仲裁盤


[root@node1 ~]# mkqdisk --help

mkqdisk v3.0.12.1

 

mkqdisk: invalid option -- '-'

mkqdisk: invalid option -- 'e'

mkqdisk: invalid option -- '-'

usage: mkqdisk -L | -f <label> | -c <device> -l<label> [-d]


[root@node1 ~]# mkqdisk -c /dev/sdb1 -l myqdisk


mkqdisk v3.0.12.1

 

Writing new quorum disk label 'myqdisk' to /dev/sdb1.

WARNING: About to destroy all data on /dev/sdb1; proceed [N/y] ?y

Initializing status block for node 1...

Initializing status block for node 2...

Initializing status block for node 3...

Initializing status block for node 4...

Initializing status block for node 5...

Initializing status block for node 6...

Initializing status block for node 7...

Initializing status block for node 8...

Initializing status block for node 9...

Initializing status block for node 10...

Initializing status block for node 11...

Initializing status block for node 12...

Initializing status block for node 13...

Initializing status block for node 14...

Initializing status block for node 15...

Initializing status block for node 16...


驗證是否建立成功


[root@node1 ~]# mkqdisk -L

mkqdisk v3.0.12.1

 

/dev/block/8:17:

/dev/disk/by-id/scsi-1IET_00010001-part1:

/dev/disk/by-path/ip-192.168.2.200:3260-iscsi-iqn.2017-6.com.example:node5-lun-1-part1:

/dev/disk/by-uuid/f57a4f43-b2df-492c-893d-6b251ff4ae22:

/dev/sdb1:

       Magic:                eb7a62c2

       Label:                myqdisk

       Created:              Tue Jul 18 15:30:50 2017

       Host:                 node1

       Kernel SectorSize:   512

       Recorded SectorSize: 512


仲裁盤的配置

wKioL1mECL6BRJqFAAHYVRDOcuk873.png-wh_50

wKiom1mECNnzph0_AAIbj04L-II743.png-wh_50

查看仲裁盤配置是否成功

wKiom1mECQmTWEt0AAJ1248x_HE894.png-wh_50

啓動仲裁服務


[root@node1 ~]# /usr/sbin/qdiskd status

QDisk services already running

qdisk啓動後,若是配置正確,qdisk磁盤將自動進入online狀態,相關信息以下:

[root@node1 ~]# clustat -l

Cluster Status for cluster_test @ Tue Jul 18 17:24:39 2017

Member Status: Quorate

 Member Name               ID   Status

 ------ ----               ---- ------

 node1                   1 Online, Local,rgmanager

 node2                   2 Online, rgmanager

 /dev/block/8:17           0 Online, QuorumDisk

 

Service Information

------- -----------

 

Service Name      :service:user_cluster

  Current State   : started (112)

  Flags           : none (0)

  Owner           : node1

  Last Owner      : node2


  Last Transition : TueJul 18 16:38:26 2017

此時qdisk已經開始運行。

2.7)集羣測試

手動切換節點

[root@node2 html]# clusvcadm -r user-test -m node3.example.com


模擬一個節點宕機

在另一個節點上查看日誌文件

[root@node3 log]# tail -f messages

Aug 3 16:21:16 node3 kernel: GFS2: fsid=test:gfs.0: Joined cluster. Nowmounting FS...

Aug 3 16:21:16 node3 kernel: GFS2: fsid=test:gfs.0: jid=0, already lockedfor use

Aug 3 16:21:16 node3 kernel: GFS2: fsid=test:gfs.0: jid=0: Looking atjournal...

Aug 3 16:21:16 node3 kernel: GFS2: fsid=test:gfs.0: jid=0: Done

Aug 3 16:21:16 node3 kernel: GFS2: fsid=test:gfs.0: jid=1: Trying to acquirejournal lock...

Aug 3 16:21:16 node3 kernel: GFS2: fsid=test:gfs.0: jid=1: Looking atjournal...

Aug 3 16:21:16 node3 kernel: GFS2: fsid=test:gfs.0: jid=1: Done

Aug  3 16:21:16 node3 rgmanager[24184]: [ip]Adding IPv4 address 192.168.2.110/24 to eth0

Aug 3 16:21:20 node3 rgmanager[24270]: [script] Executing /etc/init.d/httpdstart

Aug  3 16:21:20 node3 rgmanager[2323]: Serviceservice:user-test started

Aug  3 16:21:38 node3 qdiskd[1625]: Node 1shutdown

Aug 3 16:21:39 node3 kernel: dlm: closing connection to node 1

Aug 3 16:21:39 node3 corosync[1575]:  [QUORUM] Members[1]: 2

Aug 3 16:21:39 node3 corosync[1575]:  [TOTEM ] A processor joined or left the membership and a new membershipwas formed.

Aug 3 16:21:39 node3 corosync[1575]:  [CPG   ] chosen downlist: senderr(0) ip(192.168.2.120) ; members(old:2 left:1)

Aug 3 16:21:39 node3 corosync[1575]:  [MAIN  ] Completed servicesynchronization, ready to provide service.

Aug 3 16:21:39 node3 dlm_controld[1823]: node_history_cluster_remove nonodeid 1

Aug 3 16:21:39 node3 gfs_controld[1873]: node_history_cluster_remove nonodeid 1

Aug 3 16:21:40 node3 ricci[24325]: Executing '/usr/bin/virsh nodeinfo'

Aug 3 16:21:40 node3 ricci[24327]: Executing'/usr/libexec/ricci/ricci-worker -f /var/lib/ricci/queue/954519272'

Aug 3 16:21:41 node3 ricci[24443]: Executing '/usr/libexec/ricci/ricci-worker-f /var/lib/ricci/queue/2133287837'

Aug 3 16:21:51 node3 rgmanager[24468]: [script] Executing /etc/init.d/httpdstatus

Aug 3 16:22:22 node3 rgmanager[24911]: [script] Executing /etc/init.d/httpdstatus

Aug 3 16:23:01 node3 rgmanager[25205]: [script] Executing /etc/init.d/httpdstatus

 

[root@node3 log]# clustat

Cluster Status for test @ Thu Aug  3 16:24:13 2017

Member Status: Quorate

 Member Name           ID   Status

 ------ ----           ---- ------ 

node2.example.com        1 Offline

node3.example.com        2 Online,Local, rgmanager

/dev/block/8:17          0Online, Quorum Disk

 

 Service Name    Owner(Last)      State        

 ------- ----    ----- ------     -----        

 service:user-test    node3.example.com    started

經過以上兩種測試方法,能夠發現即便一個節點宕機也不會妨礙服務的正常運行。


2.6.8)總結

因爲設備的限制,沒有真實的fence。實驗中使用的fence是經過參考網絡上的資料(http://zaizai1573.blog.51cto.com/4515471/1564605)所得知。經過查找相關資料發現存在多種fence可是因爲條件的限制以及我的知識的侷限,僅僅經過了上面的步驟將搭建環境還原,若有問題請指正。

相關文章
相關標籤/搜索