# 卷擴(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é)束。