glusterfs 卷擴(kuò)容與收縮

# 卷擴(kuò)容(由于副本數(shù)設(shè)置為2,至少要添加2(4、6、8..)臺機(jī)器)

gluster peer probe10.0.21.243# 加節(jié)點(diǎn)

gluster peer probe10.0.21.244# 加節(jié)點(diǎn)

gluster volume add-brick gv010.0.21.243:/data/glusterfs10.0.21.244:/data/glusterfs # 合并卷

# 收縮卷(收縮卷前gluster需要先移動數(shù)據(jù)到其他位置)

gluster volume remove-brick gv010.0.21.243:/data/glusterfs10.0.21.244:/data/glusterfs start # 開始遷移

gluster volume remove-brick gv010.0.21.243:/data/glusterfs10.0.21.244:/data/glusterfs status # 查看遷移狀態(tài)

gluster volume remove-brick gv010.0.21.243:/data/glusterfs10.0.21.244:/data/glusterfs commit # 遷移完成后提交

# 遷移卷

gluster peer probe10.0.21.245# 將10.0.21.246數(shù)據(jù)遷移到10.0.21.245先將10.0.21.245加入集群

gluster volume replace-brick gv010.0.21.246:/data/glusterfs10.0.21.245:/data/glusterfs start # 開始遷移

gluster volume replace-brick gv010.0.21.246:/data/glusterfs10.0.21.245:/data/glusterfs status # 查看遷移狀態(tài)

gluster volume replace-brick gv0 10.0.21.246:/data/glusterfs 10.0.21.245:/data/glusterfs commit # 數(shù)據(jù)遷移完畢后提交

gluster volume replace-brick gv0 10.0.21.246:/data/glusterfs 10.0.21.245:/data/glusterfs commit -force # 如果機(jī)器10.0.21.246出現(xiàn)故障已經(jīng)不能運(yùn)行,執(zhí)行強(qiáng)制提交

gluster volume heal gv0 full # 同步整個卷

本文介紹的是GlusterFS基礎(chǔ)的用法,感覺它的最大優(yōu)點(diǎn)就是文件使用哈希散列,而不需要單獨(dú)去維護(hù)MetaData以避開單點(diǎn)問題,而目錄則是所有節(jié)點(diǎn)都一致的。節(jié)點(diǎn)信息會在變化過程中自動同步!不過增刪節(jié)點(diǎn),需要做Rebalance數(shù)據(jù)才會重新分布。

C.在clinet上安裝客戶端軟件:

#yum -y install glusterfs glusterfs-fuse

GlusterFS客戶端連接

在客戶端client.zhaogang.int上使用mount命令,把服務(wù)器上新建的GlusterFS邏輯卷gv0掛載到本地目錄/mnt/glusterfs上:

[root@localhost ~]# mkdir /mnt/glusterfs

[root@localhost ~]# mount -t glusterfs 10.0.21.241:/gv0 /mnt/glusterfs

[root@localhost ~]#

確認(rèn)掛載結(jié)果:

[root@localhost ~]# mount -t fuse.glusterfs

10.0.21.241:/gv0 on /mnt/glusterfs type fuse.glusterfs (rw,default_permissions,allow_other,max_read=131072)

如果希望系統(tǒng)重啟后可以自動掛載,在/etc/fstab文件中加入此行:

10.0.0.241:/data/gfsdata? ? ? /mnt/glusterfs? ? glusterfs? defaults? ? ? ? 0 0

客戶端測試連接

client端成功掛載邏輯卷之后,在掛載目錄/mnt/glusterfs建立文件以測試GlusterFS是否正常工作。

[root@localhost glusterfs]# cd /mnt/glusterfs/

[root@localhost glusterfs]# touch file1 file2 file3

[root@localhost glusterfs]# ls -l

total 0

-rw-r--r--. 1 root root 0 Aug 29 21:07 file1

-rw-r--r--. 1 root root 0 Aug 29 21:07 file2

-rw-r--r--. 1 root root 0 Aug 29 21:07 file3

因?yàn)閯?chuàng)建卷gv0的時候使用的是鏡像存儲(Replicated),所以在gv0上寫入的文件應(yīng)該同時出現(xiàn)在兩個服務(wù)器的/data/gfsdata目錄上。

在server1和server2查看/data/gfsdata/目錄,可以看到兩個服務(wù)器均出現(xiàn)這三個文件:

[root@server1 ~]# cd /data/gfsdata/

[root@server1 gfsdata]# ls -l

total 0

-rw-r--r--. 2 root root 0 Aug 29 21:07 file1

-rw-r--r--. 2 root root 0 Aug 29 21:07 file2

-rw-r--r--. 2 root root 0 Aug 29 21:07 file3

[root@server2 ~]# cd /data/gfsdata/

[root@server2 gfsdata]# ls -l

total 0

-rw-r--r--. 2 root root 0 Aug 29 21:07 file1

-rw-r--r--. 2 root root 0 Aug 29 21:07 file2

-rw-r--r--. 2 root root 0 Aug 29 21:07 file3

自此GlusterFS快速安裝過程結(jié)束。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容