【云硬盤】使用VBD共享云硬盤搭建RHCS集群(Linux)
簡介

本篇內容指導搭建RHCS(Red Hat Cluster Suite)集群系統,使用GFS2分布式文件系統,實現一個共享盤在多個云服務器之間可共享文件。
RHCS集群資源規劃
本示例中批量創建3臺云服務器,其中云服務器參數配置如?表1所示。這3臺服務器組成一個小型集群,其中1臺管理節點,兩臺業務節點。
節點類型
配置信息
管理節點
名稱:ecs-share-0003
鏡像:CentOS 6.5 64bit
規格:通用計算型、c2.large(2vCPUs、4GB內存)
彈性IP:122.3x.xx.xx
私有IP地址:192.168.108.96
節點1
名稱:ecs-share-0001
鏡像:CentOS 6.5 64bit
規格:通用計算型、c2.large(2vCPUs、4GB內存)
彈性IP:122.1x.xx.xx
私有IP地址:192.168.119.20
節點2
名稱:ecs-share-0002
鏡像:CentOS 6.5 64bit
規格:通用計算型、c2.large(2vCPUs、4GB內存)
彈性IP:122.2x.xx.xx
私有IP地址:192.168.92.223
本示例中創建了1個VBD共享云硬盤,并掛載至節點1和節點2,即ecs-share-0001和ecs-share-0002。
創建資源
創建云服務器
本示例中一共創建3臺云服務器,具體操作請參見PDF附件。
創建共享云硬盤
本示例中一共創建VBD共享云硬盤,并掛載至節點1和節點2,即ecs-share-0001和ecs-share-0002,具體操作請參見PDF附件。
配置云服務器網絡
本章節指導用戶配置3臺云服務器的網絡,以確保3臺云服務器網絡互通。
本操作以配置ecs-share-0001為例。
使用root用戶登錄云服務器。
執行以下命令,查看ecs-share-0001的host文件“/etc/hosts”。
cat /etc/hosts
回顯類似如下信息:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
執行以下命令,打開“/etc/hosts”文件。
vi /etc/hosts
按“i”進入編輯模式。
將3臺云服務器的私有IP以及對應的云服務器名稱添加至“hosts”文件,請按照以下回顯樣例進行配置:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.119.20 ecs-share-0001 192.168.92.223 ecs-share-0002 192.168.108.96 ecs-share-0003
按“Esc”,輸入“:wq”,并按“Enter”。
保存設置并退出vi編輯器。
參考1~6,配置其他2臺云服務器ecs-share-0002和ecs-share-0003的網絡。
安裝RHCS集群
搭建一個RHCS集群系統,需要分別為管理節點和其他節點安裝luci和ricci軟件,具體如下:
luci: RHCS集群管理工具的主控端,提供了管理RHCS集群的web頁面(High Availability Management),luci安裝在管理節點上,管理集群主要是通過跟集群中其他節點上的ricci通信來完成的。
ricci: RHCS集群管理工具的受控端,安裝在集群中的其他節點上,luci就是通過每一個節點上的ricci管理后端。
安裝ricci
本章節指導用戶為節點1和節點2(即云服務器ecs-share-0001和ecs-share-0002)安裝ricci并配置磁盤。
本文以云服務器的操作系統為“CentOS 6.5 64bit ”為例。不同云服務器的操作系統的配置可能不同,本文僅供參考,具體操作步驟和差異請參考對應操作系統的產品文檔。
本操作以配置ecs-share-0001為例,節點1和節點2的配置相同。
使用root用戶登錄云服務器。
執行以下命令,下載并安裝ricci軟件包。
yum install ricci openais cman rgmanager lvm2-cluster gfs2-utils
回顯類似如下信息:
...... Dependency Updated: cyrus-sasl.x86_64 0:2.1.23-15.el6_6.2 cyrus-sasl-gssapi.x86_64 0:2.1.23-15.el6_6.2 cyrus-sasl-lib.x86_64 0:2.1.23-15.el6_6.2 cyrus-sasl-plain.x86_64 0:2.1.23-15.el6_6.2 device-mapper.x86_64 0:1.02.117-12.el6_9.1 device-mapper-event.x86_64 0:1.02.117-12.el6_9.1 device-mapper-event-libs.x86_64 0:1.02.117-12.el6_9.1 device-mapper-libs.x86_64 0:1.02.117-12.el6_9.1 device-mapper-persistent-data.x86_64 0:0.6.2-0.1.rc7.el6 lvm2.x86_64 0:2.02.143-12.el6_9.1 lvm2-libs.x86_64 0:2.02.143-12.el6_9.1 sg3_utils-libs.x86_64 0:1.28-12.el6 Complete!
執行以下命令,關閉防火墻。
/etc/init.d/iptables stop
chkconfig iptables off
執行以下命令,暫停并關閉ACPI(Advanced Configuration and Power Interface,高級配置與電源接口)服務。
/etc/init.d/acpid stop
chkconfig acpid off
回顯類似如下信息:
[Infographics Show] 04 A Quick Insight into EVS [root@ecs-share--0001 ~]# /etc/init.d/acpid stop Stopping acpi daemon: [ OK ] [root@ecs-share--0001 ~]# chkconfig acpid off
執行以下命令,設置ricci密碼。
passwd ricci
回顯類似如下信息:
[root@ecs-share--0002 ~]# passwd ricci Changing password for user ricci. New password: Retype new password: passwd: all authentication tokens updated successfully.
根據回顯提示設置ricci密碼。
執行以下命令,啟動ricci。
/etc/init.d/ricci start
chkconfig ricci on
回顯類似如下信息:
[root@ecs-share--0001 ~]# /etc/init.d/ricci start Starting oddjobd: [ OK ] generating SSL certificates... done Generating NSS database... done Starting ricci: [ OK ] [root@ecs-share--0001 ~]# chkconfig ricci on
執行以下命令,查看云服務器掛載的磁盤。
fdisk -l
chkconfig acpid off
回顯類似如下信息:
[root@ecs-share--0001 ~]# fdisk -l Disk /dev/xvda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 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: 0x000d6814 Device Boot Start End Blocks Id System /dev/xvda1 1 523 4194304 82 Linux swap / Solaris Partition 1 does not end on cylinder boundary. /dev/xvda2 * 523 5222 37747712 83 Linux Disk /dev/xvdb: 107.4 GB, 107374182400 bytes 255 heads, 63 sectors/track, 13054 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: 0x00000000
執行以下命令,新建磁盤掛載目錄。
mkdir 掛載目錄
命令示例:
mkdir /mnt/gfs_vbd
執行以下命令,為磁盤創建GFS2分布式文件系統。
mkfs.gfs2 -p lock_dlm -t mycluster:gfs_vbd -j 4 /dev/xvdb
回顯類似如下信息:
[root@ecs-share--0001 ~]# mkfs.gfs2 -p lock_dlm -t mycluster:gfs_vbd -j 4 /dev/xvdb This will destroy any data on /dev/xvdb. It appears to contain: data Are you sure you want to proceed? [y/n] y Device: /dev/xvdb Blocksize: 4096 Device Size 100.00 GB (26214400 blocks) Filesystem Size: 100.00 GB (26214398 blocks) Journals: 4 Resource Groups: 400 Locking Protocol: "lock_dlm" Lock Table: "mycluster:gfs_vbd" UUID: ef5ff133-bfcb-826a-92e8-4decd04d4712
參考1~9,配置另一臺云服務器ecs-share-0002。
安裝luci
本章節指導用戶為管理節點(即云服務器ecs-share-0003)安裝配置luci。
使用root用戶登錄云服務器。
執行以下命令,下載并安裝luci集群軟件包。
yum install luci
回顯類似如下信息:
...... python-webflash.noarch 0:0.1-0.2.a9.el6 python-webhelpers.noarch 0:0.6.4-4.el6 python-webob.noarch 0:0.9.6.1-3.el6 python-webtest.noarch 0:1.2-2.el6 python-zope-filesystem.x86_64 0:1-5.el6 python-zope-interface.x86_64 0:3.5.2-2.1.el6 python-zope-sqlalchemy.noarch 0:0.4-3.el6 Complete!
執行以下命令,關閉防火墻。
/etc/init.d/iptables stop
chkconfig iptables off
執行以下命令,啟動luci。
/etc/init.d/luci start
chkconfig luci on
回顯類似如下信息:
[root@ecs-share--0003 ~]# /etc/init.d/luci start Adding following auto-detected host IDs (IP addresses/domain names), corresponding to `ecs-share--0003' address, to the configuration of self-managed certificate `/var/lib/luci/etc/cacert.config' (you can change them by editing `/var/lib/luci/etc/cacert.config', removing the generated certificate `/var/lib/luci/certs/host.pem' and restarting luci): (none suitable found, you can still do it manually as mentioned above) Generating a 2048 bit RSA private key writing new private key to '/var/lib/luci/certs/host.pem' Starting saslauthd: [ OK ] Start luci... [ OK ] Point your web browser to https://ecs-share--0003:8084 (or equivalent) to access luci [root@ecs-share--0003 ~]# chkconfig luci on
luci啟動成功后,即可以通過管理RHCS集群的web頁面(High Availability Management)來進行集群的相關配置。
創建集群并配置磁盤
本章節指導用戶登錄High Availability Management頁面創建集群并配置磁盤。
打開并登錄High Availability Management頁面。
地址:https://ecs-share-0003的彈性IP:8084
例如:https://122.3x.xx.xx:8084
帳號及密碼:創建ecs-share-0003時設置的root帳號及密碼
選擇“Manage Cluster”,創建集群。
在“Create New Cluser”頁面,根據頁面提示設置以下參數:
本示例在集群中添加了兩個節點。
Cluser Name:自定義集群名稱,例如,mycluster。
Node Name:分別設置計算節點的名稱,例如,ecs-share-0001。
Paasword:安裝ricci中設置的ricci密碼。
添加完第一個節點的信息后,單擊“Add Another Node”添加第二個節點。
參數設置完成后,單擊“Create Cluster”,開始創建集群。
創建成功后,兩臺云服務器均已添加至mycluster集群中。
注意:
如果重啟節點ecs-share-0001和ecs-share-0002,在重啟后,集群相關的服務(cman、rgmanager、ricci、modclusterd、clvmd)都會自動重啟,并且會自動加入集群。如果發現有節點沒有加入到mycluster集群,可以在High Availability Management中重新將節點加入到mycluster集群即可。
選擇“Resources”,為集群新建磁盤資源。
在“Add Resource to Cluster”頁面,根據頁面提示設置以下參數:
本示例添加了名稱為GFS_VBD的磁盤資源:
Name:自定義磁盤資源名稱,例如,GFS_VBD。
Mount Point:安裝ricci中設置的磁盤掛載目錄,例如,/mnt/gfs_vbd。
Device,FS Label,or UUID:此處以填寫安裝ricci中磁盤設備名稱為例,例如,/dev/xvdb。
Filesystem Type:此處選擇安裝ricci中設置的分布式文件系統,例如,GFS2。
參數設置完成后,單擊“Submit”,開始創建磁盤資源。
選擇“Failover Domains”,為集群服務新建故障切換域。
在“Add Failover Domain to Cluster”頁面,根據頁面提示設置以下參數:
Name:自定義故障切換域的名稱,例如,gfs_failover。
將節點1和節點2添加至故障切換域。
本示例添加了名稱為gfs_failover的故障切換域。
參數設置完成后,單擊“Create”,開始創建故障切換域。
創建成功后。
選擇“Service Groups”,為集群中的節點創建服務組。
以ecs-share-0001為例。
在“Add Service Group to Cluster”頁面,根據頁面提示設置以下參數:
本示例添加了名稱為GFS_SG_VBD_1的服務組,并添加了GFS_VBD磁盤資源。
Service Name:自定義服務組的名稱,例如,GFS_SG_VBD_1。
Failover Domain:選擇8中創建的故障切換域,例如,gfs_failover。
Add Resource:選擇5中創建的資源,例如,GFS_VBD。
參數設置完成后,單擊“Submit”,并選擇Start on ecs-share-0001節點,開始為ecs-share-0001創建服務組。
參考11~13,為另一個節點ecs-share-0002創建服務組。
服務組創建完成后,執行以下步驟,分別查看云服務器ecs-share-0001和ecs-share-0002的集群狀況。
以ecs-share-0001為例。
使用root用戶登錄計算節點。
執行以下命令,查看服務組。
clustat
回顯類似如下信息:
[root@ecs-share--0001 ~]# clustat Cluster Status for mycluster @ Wed Apr 11 16:56:51 2018 Member Status: Quorate Member Name ID Status ------ ---- ---- ------ ecs-share-0001 1 Online, Local, rgmanager ecs-share-0002 2 Online, rgmanager Service Name Owner (Last) State ------- ---- ----- ------ ----- service:GFS_SG_VBD_1 ecs-share-0001 started service:GFS_SG_VBD_2 ecs-share-0002 started
GFS_SG_VBD_1和GFS_SG_VBD_2即為14中創建的兩個服務組。
執行以下命令,查看磁盤分區及掛載信息。
df -h
回顯類似如下信息:
[root@ecs-share--0001 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda2 36G 2.8G 31G 9% / tmpfs 1.9G 32M 1.9G 2% /dev/shm /dev/xvdb 100G 518M 100G 1% /mnt/gfs_vbd
其中,“/dev/xvdb”即為共享盤設備名,分區成功并已掛載至“/mnt/gfs_vbd”目錄下。
注意:
如果執行完df -h命令發現分區表里沒有掛載的共享盤,請執行“mount 磁盤設備名稱 掛載目錄” 命令重新掛載磁盤,例如,mount /dev/xvdb /mnt/gfs_vbd,掛載后便可與其他云服務器同步使用該共享盤。
參考15.a~15.c,查看另一臺云服務器的集群狀況。
驗證磁盤共享功能
本章節指導用戶驗證共享盤是否可以實現在多臺云服務器之間共享文件。
使用root用戶登錄云服務器ecs-share-0001。
執行以下步驟,在云服務器ecs-share-0001的磁盤掛載目錄“/mnt/gfs_vbd”上新建文件“test-ecs1”。
執行以下命令,進入“/mnt/gfs_vbd/”目錄。
cd /mnt/gfs_vbd/
執行以下命令,打開“test-ecs1”文件。
vi test-ecs1
按“i”進入編輯模式。
為“test-ecs1”文件添加內容,例如“hello1”。
按“Esc”,輸入“:wq”,并按“Enter”。
保存設置并退出vi編輯器。
執行以下命令,查看“test-ecs1”文件內容。
cat test-ecs1
回顯類似如下信息:
[root@ecs-share--0001 gfs_vbd]# cat test-ecs1 hello1
表示“test-ecs1”文件內容添加成功。
執行以下命令,再次查看“test-ecs1”文件是否存在。
ls
回顯類似如下信息:
[root@ecs-share--0001 gfs_vbd]# ls test-ecs1
表示云服務器ecs-share-0001的“/mnt/gfs_vbd/”目錄下存在“test-ecs1”文件。
使用root用戶登錄云服務器ecs-share-0002。
執行以下步驟,驗證在云服務器ecs-share-0002的磁盤掛載目錄“/mnt/gfs_vbd”中是否可以查看到2中創建的“test-ecs1”文件。
執行以下命令,進入“/mnt/gfs_vbd/”目錄。
cd /mnt/gfs_vbd/
執行以下命令,查看“test-ecs1”文件是否存在。
ls
回顯類似如下信息:
[root@ecs-share--0002 gfs_vbd]# ls test-ecs1
表示通過云服務器ecs-share-0001創建的“test-ecs1”文件,在云服務器ecs-share-0002的“/mnt/gfs_vbd/”目錄下可以查看到。
執行以下命令,查看“test-ecs1”文件內容。
cat test-ecs1
回顯類似如下信息:
[root@ecs-share--0002 gfs_vbd]# cat test-ecs1 hello1
表示通過云服務器ecs-share-0001添加的“test-ecs1”文件內容,在云服務器ecs-share-0002中可以看到,內容同步成功。
執行以下步驟,驗證在云服務器ecs-share-0002上是否可以修改文件“test-ecs1”。
執行以下命令,打開“test-ecs1”文件。
vi test-ecs1
按“i”進入編輯模式。
為“test-ecs1”文件添加內容,例如“hello2”。
按“Esc”,輸入“:wq”,并按“Enter”。
保存設置并退出vi編輯器。
執行以下命令,查看“test-ecs1”文件內容。
cat test-ecs1
回顯類似如下信息:
[root@ecs-share--0002 gfs_vbd]# cat test-ecs1 hello1 hello2
表示在云服務器ecs-share-0002上也可以對“test-ecs1”文件內容進行修改。
使用root用戶登錄云服務器ecs-share-0001。
執行以下步驟,驗證在云服務器ecs-share-0001中是否可以讀取5中修改的“test-ecs1”文件內容。
執行以下命令,進入“/mnt/gfs_vbd/”目錄。
cd /mnt/gfs_vbd/
執行以下命令,查看“test-ecs1”文件內容。
cat test-ecs1
回顯類似如下信息:
[root@ecs-share--0001 gfs_vbd]# cat test-ecs1 hello1 hello2
表示通過云服務器ecs-share-0002修改的“test-ecs1”文件內容,在云服務器ecs-share-0001中也可以看到,內容同步成功。
如果您希望看到更多云硬盤的最佳實踐,請您留言給我,十分感謝~
ps: 您還可以通過華為云官網訪問該內容,https://support.huaweicloud.com/bestpractice-evs/zh-cn_topic_0107767325.html
附件: 使用VBD共享云硬盤搭建RHCS集群(Linux).pdf 831.6KB 下載次數:16次
云硬盤 EVS
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。