Gluster部署及ganesha導出實踐

1.   基礎環境

機器:騰訊雲CVM

OScentos7.4x86——64

IP地址:

      10.154.14.207

10.154.51.185

10.105.17.180

10.105.73.90

         注意:爲了掛載和ganesha導出方便,沒有進行hosts配置,直接使用ip操作。同時這裏採用直接在gluster機器上面直接安裝nfs-ganesha導出

2.   安裝ganesha

這裏我們在10.154.14.207上安裝ganesha,來測試功能。

#安裝ganesha
yum install -y nfs-ganesha*

3.   安裝gluster

yum install -y centos-release-gluster
yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma
systemctl start glusterd.service
systemctl enable glusterd.service

4.   gluster環境配置

4.1.  添加節點到gluster集羣

10.154.14.207機器上面執行probe命令將其他節點添加進來:

gluster peer probe 10.154.51.185
gluster peer probe 10.105.17.180
gluster peer probe 10.105.73.90

4.2.  查看集羣狀態

查看集羣狀態命令:

gluster peer status

doc_image_0_w723_h315.jpg

可見其他三個節點都被成功的添加進來了。

5.   創建gluster volume

Gluster volume可分爲基本卷和複合卷,基本捲包括:distributed volume, replicated volume,striped volume; 複合捲包括: distributed replicated volume, distributed striped volume, replicated striped volume, distributed replicated striped volumeDistributed volume(哈希卷)爲默認的卷。這裏我們創建一個哈希卷和哈希複製卷。

5.1.  創建brick目錄

爲了方便,我們直接在/data目錄下創建我們所需要的brick

分別在四臺機器上面創建如下目錄:

mkdir –p /data/dht_volume1
mkdir –p /data/replica_volume1

5.2.  創建volume

#創建哈希卷:dht-volume1
gluster volume create dht-volume1 10.105.73.90:/data/dht_volume1 10.105.17.180:/data/dht_volume1 10.154.14.207:/data/dht_volume1 10.154.51.185:/data/dht_volume1 force
#創建哈希複製卷:dht-rep-volume1
gluster volume create dht-rep-volume1 replica 2 10.105.73.90:/data/replica_volume1 10.105.17.180:/data/replica_volume1 10.154.14.207:/data/replica_volume1 10.154.51.185:/data/replica_volume1 force

doc_image_1_w1546_h175.jpg

         注意:由於我們直接在data目錄下創建的brick,故需要在創建volume的時候增加force參數。不然會報錯,如“volume create: dht-volume1: failed: The brick 10.154.14.207:/data/dht_volume1 is being created in the root partition. It is recommended that you don't use the system's root partition for storage backend. Or use 'force' at the end of the command if you want to override this behavior.”

5.3.  啓動volume

#啓動卷命令
gluster volume start volume-name
gluster volume start dht-volume1
gluster volume start dht-rep-volume1
doc_image_2_w746_h116.jpg

5.4.  查看volume

#查看volume信息命令:
gluster volume info [volume_name]
#查看volume狀態命令:
gluster volume status [volume_name]

doc_image_3_w678_h754.jpg

doc_image_4_w1035_h628.jpg

doc_image_5_w1018_h671.jpg

6.   本地掛載gluster volume

在任意一臺gluster機器上面執行掛載命令,如:

mount -t glusterfs localhost:/dht-volume1 /mnt/dht_volume1

doc_image_6_w921_h270.jpg

df可以發現,每臺機器上面的”/”容量爲50G4臺機器總容量爲200G,哈希卷的總容量等於各個brick的容量相加。

同時,由於我們客戶機器屬於gluster機器,故直接掛載localhost即可。否則localhost位置需要更改爲volume包含的brick所在的任何一臺機器的ip即可。

7.   通過ganesha導出

7.1.  編輯配置文件

在安裝了ganesha的機器10.154.14.207上,編輯配置文件/etc/ganesha/ganesha.conf

doc_image_7_w1026_h777.jpg

決定volume導出目錄的是FSAl block中的volpath,和path以及pseudo無關。

7.2.  啓動ganesha

#啓動ganesha命令
systemctl start nfs-ganesha

7.3.  查看導出點

showmount -e localhost      

doc_image_8_w652_h100.jpg

可見兩個卷已經被導出

7.4.  掛載文件系統

我們在10.105.17.180上面掛載ganesha導出的文件系統。

7.4.1.   安裝nfs客戶端

#安裝nfs客戶端
yum install –y nfs-utils

7.4.2.   掛載

#掛載nfs文件系統
mount -t nfs4 10.154.14.207:/dht-volume1-seudo /mnt/dht_volume1
mount -t nfs4 10.154.14.207:/dht-rep-volume1-seudo /mnt/dht_rep_volume1

doc_image_9_w1068_h320.jpg

容量按照原理也是正確的。

8.   掛載方式區別

gluster-fuse本地掛載,走的是fuse,路徑較長;

ganesha導出,走的爲libglusterfs庫,路徑較短。

原理上,ganesha導出的性能會更好。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章