1. 程式人生 > >GlusterFS分布式存儲集群-2. 使用

GlusterFS分布式存儲集群-2. 使用

read 之間 智慧 分片 服務 保存 pause 事務 ons

參考文檔:

  1. Quick Start Guide:http://gluster.readthedocs.io/en/latest/Quick-Start-Guide/Quickstart/
  2. Install-Guide:https://docs.gluster.org/en/latest/Install-Guide/Install/
  3. CentOS gluster-Quickstart:https://wiki.centos.org/SpecialInterestGroup/Storage/gluster-Quickstart
  4. Type of Volumes:https://docs.gluster.org/en/latest/Quick-Start-Guide/Architecture/#types-of-volumes
  5. Setting up GlusterFS Volumes:https://docs.gluster.org/en/latest/Administrator%20Guide/Setting%20Up%20Volumes/
  6. 腦裂:https://docs.gluster.org/en/latest/Administrator%20Guide/Split%20brain%20and%20ways%20to%20deal%20with%20it/
  7. Glusterfs技術詳解(推薦):https://czero000.github.io/2016/04/05/glusterfs-technical-explanation.html
    1. Glusterfs邏輯卷創建與使用

volume是brick的組合,並且大部分glusterfs文件系統的操作都在volume上。

glusterfs支持3種基本卷,並可以根據需求對3種基本卷進行組合形成多種擴展卷(得益於glusterfs的模塊化堆棧架構設計)。

以下主要展示各類型邏輯卷的功能性,未對性能做測試驗證。

  1. 分布式卷

分布式卷(Distributed Glusterfs Volume,又稱DHT),glusterfs創建volume不指定卷類型時,默認即分布式卷,特點如下:

  1. 根據hash算法,將多個文件分布到卷中的多個brick server上,類似(不是)raid0,但文件無分片;
  2. 方便擴展空間,但無冗余保護;
  3. 由於使用本地文件系統進行存儲(brick server 的本地文件系統),存取效率不高;
  4. 受限於本地文件系統對單文件容量的限制,支持超大型文件系統有問題。

技術分享圖片

創建存儲目錄(optional)

# 在brick server節點創建存儲目錄,即brick所在;

# 以glusterfs01節點為例,註意各brick server掛載磁盤的目錄名的不同

[root@glusterfs01 ~]# mkdir -p /brick1/dis_volume

創建分布式卷

# 命令:gluster volume create NEW-VOLNAME [transport [tcp | rdma | tcp,rdma]] NEW-BRICK...

# 以上命令在任意server節點操作均可,以glusterfs01節點為例;

# 演示分布式卷的創建,兩個server節點即可,創建名為"distributed-volume"的邏輯卷

[root@glusterfs01 ~]# gluster volume create distributed-volume glusterfs01:/brick1/dis_volume glusterfs02:/brick2/dis_volume

技術分享圖片

查看卷信息/狀態

# 命令"gluster volume list"可列出已創建的卷;

# 命令"gluster volume info"可不指定具體的卷,即列出所有卷信息;

# info中給出除卷名外,還有卷類型,狀態,brick組成等信息;

# 其中狀態為"Created",需要通過命令啟動後才可被掛載使用,在創建成功後的提示信息中有提到"please start the volume to access data"

[root@glusterfs01 ~]# gluster volume info distributed-volume

技術分享圖片

# 查看卷狀態;

# 展示卷中每個brick的狀態,以及每個brick服務的監聽端口

[root@glusterfs01 ~]# gluster volume status distributed-volume

技術分享圖片

啟動卷

[root@glusterfs01 ~]# gluster volume start distributed-volume

技術分享圖片

# 再次查看卷信息,狀態變為"Started"

[root@glusterfs01 ~]# gluster volume info distributed-volume

技術分享圖片

client掛載

# 在客戶端創建掛載目錄

[root@glusterfs-client ~]# mkdir /mnt/distributed

# 掛載時,可使用任意1臺已加入可信存儲池並已創建對應卷類型的server節點;

# brick以"SERVER:EXPORT"的形式標識

[root@glusterfs-client ~]# mount.glusterfs 172.30.200.51:distributed-volume /mnt/distributed/

查看掛載情況

# 通過"df -Th"命令可查看被掛載的volume,被掛載的文件系統,已經掛載卷的容量是2個brick容量之和

[root@glusterfs-client ~]# df -Th

技術分享圖片

查看brick的監聽端口

# server節點上每啟動1個brick,即啟動1個brick服務,具備相應的服務監聽端口,起始端口號是tcp49152

[root@glusterfs01 ~]# netstat -tunlp | grep gluster

技術分享圖片

# 另外,client連接的即brick服務的監聽端口

[root@glusterfs01 ~]# netstat -nt

技術分享圖片

存儲測試

# 在client的掛載目錄下創建若幹文件

[root@glusterfs-client ~]# cd /mnt/distributed/

[root@glusterfs-client distributed]# touch distributed{1..4}.txt

# glusterfs01節點

[root@glusterfs01 ~]# tree /brick1/dis_volume/

技術分享圖片

# glusterfs02節點

[root@glusterfs02 ~]# tree /brick2/dis_volume/

技術分享圖片

結論:分布式卷將多個文件分布存儲在多個brick server,但並無副本。

  1. 條帶卷(Deprecated)

條帶卷(Striped Glusterfs Volume),特點如下:

  1. 每個文件被分片成等同於brick數量的chunks,然後以round robin的方式將每個chunk存儲到1個brick,相當於raid0;
  2. 單一超大容量文件可被分片,不受brick server本地文件系統的限制;
  3. 文件分片後,並發粒度是chunks,分布式讀寫性能較高,但分片隨機讀寫可能會導致硬盤iops較高;
  4. 無冗余,1個server節點故障會導致所有數據丟失。

技術分享圖片

創建條帶卷

# 命令:gluster volume create NEW-VOLNAME [stripe COUNT] [transport [tcp | dma | tcp,rdma]] NEW-BRICK...

# 以上命令在任意server節點操作均可,以glusterfs01節點為例;

# 創建名為"strsipe-volume"的邏輯卷;

# 必須指定卷類型(默認為分布式卷)與對應的條帶數量,數量需要與後續使用brick server數量對等;

# "transport tcp"指定集群通信方式

[root@glusterfs01 ~]# gluster volume create stripe-volume stripe 3 transport tcp glusterfs01:/brick1/str_volume glusterfs02:/brick2/str_volume glusterfs03:/brick3/str_volume

技術分享圖片

啟動卷

[root@glusterfs01 ~]# gluster volume start stripe-volume

技術分享圖片

client掛載

[root@glusterfs-client ~]# mkdir /mnt/stripe

[root@glusterfs-client ~]# mount.glusterfs 172.30.200.51:stripe-volume /mnt/stripe/

查看掛載情況

# 已掛載卷的容量是3個brick容量之和

[root@glusterfs-client ~]# df -Th

技術分享圖片

存儲測試

# 在client的掛載目錄下創建若幹文件

[root@glusterfs-client ~]# cd /mnt/stripe/

[root@glusterfs-client stripe]# touch stripe{1..6}.txt

# 向strip1.txt文件寫入內容

[root@glusterfs-client stripe]# echo "this is stripe1.txt" >> strip1.txt

# glusterfs01節點

[root@glusterfs01 ~]# tree /brick1/str_volume/

[root@glusterfs01 ~]# cat /brick1/str_volume/strip1.txt

技術分享圖片

# glusterfs02節點

[root@glusterfs02 ~]# tree /brick2/str_volume/

[root@glusterfs02 ~]# cat /brick2/str_volume/strip1.txt

技術分享圖片

# glusterfs03節點

[root@glusterfs03 ~]# tree /brick3/str_volume/

[root@glusterfs03 ~]# cat /brick3/str_volume/strip1.txt

技術分享圖片

結論:條帶卷將1個文件分片存儲在多個brick server,但並無副本。

  1. 復制卷

復制卷(Replicated Glusterfs Volume,又稱AFR(Auto File Replication)),特點如下:

  1. 每個文件同步復制鏡像到多個brick,相當於文件級raid1;
  2. 副本數量通常設置為2或3,設置的副本數量需要是brick數量(至少為2)的倍數(如2臺brick server,可設置副本數為2/4/6/…;如3臺brick server,可設置副本數為3/6/9/…;依次類推),且每個brick的容量相等;
  3. 讀性能提升,寫性能下降,因為glusterfs的復制是同步事務操作,即寫文件時,先把這個文件鎖住,然後同時寫兩個或多個副本,寫完後解鎖,操作結束(ceph采用異步寫副本,即寫到一個主OSD便返回,這個OSD再通過內部網絡異步寫到其余OSD);
  4. 通常與分布式卷或條帶卷組合使用,解決前兩者的冗余問題;
  5. 提升數據可靠性,但磁盤利用率低;
  6. 副本數設置為2時,可能會有腦裂(Split-brain)的風險(風險提示,但可配置),主要因在兩個副本不一致時,無法仲裁以哪個副本為準,解決方案是加入仲裁或者設置3副本。

技術分享圖片

創建復制卷

# 命令:gluster volume create NEW-VOLNAME [replica COUNT] [transport [tcp | rdma | tcp,rdma]] NEW-BRICK...

# 以上命令在任意server節點操作均可,以glusterfs01節點為例;

# 創建名為"replica-volume"的邏輯卷;

# 必須指定卷類型(默認為分布式卷)與對應的副本數量,數量需要與後續使用brick server數量對等;

# "transport tcp"指定集群通信方式;

# 副本數為2時,有腦裂風險提示,提示采用3副本或仲裁機制,驗證環境略過即可

[root@glusterfs01 ~]# gluster volume create replica-volume replica 2 transport tcp glusterfs01:/brick1/repl_volume glusterfs02:/brick2/repl_volume

技術分享圖片

啟動卷

[root@glusterfs01 ~]# gluster volume start replica-volume

[root@glusterfs01 ~]# gluster volume info replica-volume

技術分享圖片

client掛載

[root@glusterfs-client ~]# mkdir /mnt/replica

[root@glusterfs-client ~]# mount.glusterfs 172.30.200.51:replica-volume /mnt/replica/

查看掛載情況

# 已掛載卷的容量是1個brick的容量

[root@glusterfs-client ~]# df -Th

技術分享圖片

存儲測試

# 在client的掛載目錄下創建若幹文件

[root@glusterfs-client ~]# cd /mnt/replica/

[root@glusterfs-client replica]# touch replica{1..4}.txt

# 向replica1.txt文件寫入內容

[root@glusterfs-client replica]# echo "this is replica1.txt" >> replica1.txt

# glusterfs01節點

[root@glusterfs01 ~]# tree /brick1/repl_volume/

[root@glusterfs01 ~]# cat /brick1/repl_volume/replica1.txt

技術分享圖片

# glusterfs02節點

[root@glusterfs02 ~]# tree /brick2/repl_volume/

[root@glusterfs02 ~]# cat /brick2/repl_volume/replica1.txt

技術分享圖片

結論:復制卷將1個文件同步鏡像到多個brick server,數據有冗余備份。

AFR恢復原理

數據恢復只針對復制卷,AFR數據修復主要涉及三個方面:ENTRY,META,DATA。

記錄描述副本狀態的稱之為ChangeLog,記錄在每個副本文件擴展屬性裏,讀入內存後以矩陣形式判斷是否需要修復以及要以哪個副本為Source進行修復;初始值以及正常值為0(註:ENTRY和META,DATA分布對應著一個數值)。

以冗余度為2,即含有2個副本A和B的DATA修復為例,write的步驟分解為:

  1. 下發Write操作;
  2. 加鎖Lock;
  3. 向A,B副本的ChangeLog分別加1,記錄到各副本的擴展屬性中;
  4. 對A,B副本進行寫操作;
  5. 若副本寫成功則ChangeLog減1,若該副本寫失敗則ChangLog值不變,記錄到各個副本的擴展屬性中;
  6. 解鎖UnLock;
  7. 向上層返回,只要有一個副本寫成功就返回成功。

上述操作在AFR中是完整的一個transaction動作,根據兩個副本記錄的ChangeLog的數值確定了副本的幾種狀態:

  1. WISE:智慧的,即該副本的ChangeLog中對應的值是0,而另一副本對應的數值大於0;
  2. INNOCENT:無辜的,即兩副本的ChangeLog對應的值都是0;
  3. FOOL:愚蠢的,即該副本的ChangeLog對應的值大於是0,而另一副本對應的數值是0;
  4. ,忽略的,即該副本的ChangeLog丟失。

IGNORANT

恢復分以下場景:

  1. 1個節點changelog狀態為WISE,其余節點為FOOL或其他非WISE狀態,以WISE節點去恢復其他節點;
  2. 所有節點是IGNORANT狀態,手動觸發heal,通過命令以UID最小的文件作為source,去恢復大小為0的其他文件;
  3. 多個狀態是WISE時,即出現腦裂狀態,腦裂的文件通常讀不出來,時報"Input/Output error",可查看日誌/var/log/glusterfs/glustershd.log。

    腦裂原理及解決方案:https://docs.gluster.org/en/latest/Administrator%20Guide/Split%20brain%20and%20ways%20to%20deal%20with%20it/

# 通過命令查看副本文件的擴展屬性:getfattr -m . -d -e hex [filename]

# "trusted.afr.xxx"部分即擴展屬性,值是24bit,分3部分,依次標識DATA ,META, ENTRY 3者的changelog

[root@glusterfs01 ~]# getfattr -m . -d -e hex /brick1/repl_volume/replica1.txt

技術分享圖片

  1. 分布式復制卷

分布式復制卷(Distributed Replicated Glusterfs Volume),是分布式卷與復制卷的組合,兼具兩者的功能,特點如下:

  1. 若幹brick組成1個復制卷,另外若幹brick組成其他復制卷;單個文件在復制卷內數據保持副本,不同文件在不同復制卷之間進行哈希分布;即分布式卷跨復制卷集(replicated sets );
  2. brick server數量是副本數量的倍數,且>=2倍,即最少需要4臺brick server,同時組建復制卷集的brick容量相等。

技術分享圖片

創建分布式復制卷

# 命令:gluster volume create NEW-VOLNAME [replica COUNT] [transport [tcp | rdma | tcp,rdma]] NEW-BRICK...

# 以上命令在任意server節點操作均可,以glusterfs01節點為例;

# 創建名為"distributed-replica-volume"的邏輯卷;

# 必須指定卷類型(默認為分布式卷)與對應的副本數量,brick server數量是副本數量的倍數,且>=2倍;

# 不需要指出分布式卷類型,只要副本數量與brick server數量不等且符合倍數關系,即是分布式復制卷;

# "transport tcp"指定集群通信方式;

# 副本數為2時,有腦裂風險提示,提示采用3副本或仲裁機制,驗證環境略過即可

[root@glusterfs01 ~]# gluster volume create distributed-replica-volume replica 2 transport tcp \

glusterfs01:/brick1/dis_repl_volume

glusterfs02:/brick2/dis_repl_volume

glusterfs03:/brick3/dis_repl_volume

glusterfs04:/brick4/dis_repl_volume

技術分享圖片

啟動卷

# 卷類型:分布式復制卷

# "Number of Bricks":2副本,2個副本集(replicated sets ),4個brick server

[root@glusterfs01 ~]# gluster volume start distributed-replica-volume

[root@glusterfs01 ~]# gluster volume info distributed-replica-volume

技術分享圖片

client掛載

[root@glusterfs-client ~]# mkdir /mnt/distributed-replica

[root@glusterfs-client ~]# mount.glusterfs 172.30.200.51:distributed-replica-volume /mnt/distributed-replica/

查看掛載情況

# 已掛載卷的容量是2個副本集(replicated sets )容量之和

[root@glusterfs-client ~]# df -Th

技術分享圖片

存儲測試

# 在client的掛載目錄下創建若幹文件

[root@glusterfs-client ~]# cd /mnt/distributed-replica/

[root@glusterfs-client distributed-replica]# touch distributed-replica{1..6}.txt

# 向distributed-replica1.txt文件寫入內容

[root@glusterfs-client distributed-replica]# echo "this is distributed-replica1.txt" >> distributed-replica1.txt

# glusterfs01節點

[root@glusterfs01 ~]# tree /brick1/dis_repl_volume/

技術分享圖片

# glusterfs02節點

[root@glusterfs02 ~]# tree /brick2/dis_repl_volume/

技術分享圖片

# glusterfs03節點

[root@glusterfs03 ~]# tree /brick3/dis_repl_volume/

[root@glusterfs03 ~]# cat /brick3/dis_repl_volume/distributed-replica1.txt

技術分享圖片

# glusterfs04節點

[root@glusterfs04 ~]# tree /brick4/dis_repl_volume/

[root@glusterfs04 ~]# cat /brick4/dis_repl_volume/distributed-replica1.txt

技術分享圖片

結論:分布式復制卷將數據文件分布在多個復制集(replicated sets )中,每個復制集中數據有鏡像冗余。

  1. 分布式條帶卷(Deprecated)

分布式條帶卷(Distributed Striped Glusterfs Volume),是分布式卷與條帶卷的組合,兼具兩者的功能,特點如下:

  1. 若幹brick組成1個條帶卷,另外若幹brick組成其他條帶卷;單個文件在條帶卷內數據以條帶的形式存儲,不同文件在不同條帶卷之間進行哈希分布;即分布式卷跨條帶卷;
  2. brick server數量是條帶數的倍數,且>=2倍,即最少需要4臺brick server。

技術分享圖片

創建分布式條帶卷

# 命令:gluster volume create NEW-VOLNAME [stripe COUNT] [transport [tcp | rdma | tcp,rdma]] NEW-BRICK...

# 以上命令在任意server節點操作均可,以glusterfs01節點為例;

# 創建名為"distributed-stripe-volume"的邏輯卷;

# 必須指定卷類型(默認為分布式卷)與對應的條帶數,brick server數量是條帶數量的倍數,且>=2倍;

# 不需要指出分布式卷類型,只要條帶數量與brick server數量不等且符合倍數關系,即是分布式復制卷;

# "transport tcp"指定集群通信方式;

[root@glusterfs01 ~]# gluster volume create distributed-stripe-volume stripe 2 transport tcp

glusterfs01:/brick1/dis_str_volume

glusterfs02:/brick2/dis_str_volume

glusterfs03:/brick3/dis_str_volume

glusterfs04:/brick4/dis_str_volume

技術分享圖片

啟動卷

# 卷類型:分布式條帶卷

# "Number of Bricks":2副本,2個副本集(replicated sets ),4個brick server

[root@glusterfs01 ~]# gluster volume start distributed-stripe-volume

[root@glusterfs01 ~]# gluster volume info distributed-stripe-volume技術分享圖片

client掛載

[root@glusterfs-client ~]# mkdir /mnt/distributed-stripe

[root@glusterfs-client ~]# mount.glusterfs 172.30.200.51:distributed-stripe-volume /mnt/distributed-stripe/

查看掛載情況

# 已掛載卷的容量是4個brick容量之和

[root@glusterfs-client ~]# df -Th

技術分享圖片

存儲測試

# 在client的掛載目錄下創建若幹文件

[root@glusterfs-client ~]# cd /mnt/distributed-stripe/

[root@glusterfs-client distributed-stripe]# touch distributed-stripe{1..6}.txt

# 向distributed-stripe1.txt文件寫入內容

[root@glusterfs-client distributed-stripe]# echo "this is distributed-stripe1.txt" >> distributed-stripe1.txt

# glusterfs01節點

[root@glusterfs01 ~]# tree /brick1/dis_str_volume/

技術分享圖片

# glusterfs02節點

[root@glusterfs02 ~]# tree /brick2/dis_str_volume/

技術分享圖片

# glusterfs03節點

[root@glusterfs03 ~]# tree /brick3/dis_str_volume/

[root@glusterfs03 ~]# cat /brick3/dis_str_volume/distributed-stripe1.txt

技術分享圖片

# glusterfs04節點

[root@glusterfs04 ~]# tree /brick4/dis_str_volume/

[root@glusterfs04 ~]# cat /brick4/dis_str_volume/distributed-stripe1.txt

技術分享圖片

結論:分布式條帶卷將數據文件分布在多個條帶集中,每個條帶集中數據再以條帶的形式存儲在對應條帶集中的全部brick上,數據無冗余備份。

  1. 條帶鏡像卷(Deprecated)

條帶復制卷(STRIPE REPLICA Volume),是條帶與復制卷的組合,兼具兩者的功能,特點如下:

  1. 若幹brick組成1個復制卷,另外若幹brick組成其他復制卷;單個文件以條帶的形式存儲在2個或多個復制集(replicated sets ),復制集內文件分片以副本的形式保存;相當於文件級raid01;
  2. brick server數量是副本數的倍數,且>=2倍,即最少需要4臺brick server。

技術分享圖片

  1. 分布式條帶鏡像卷(Deprecated)

分布式條帶復制卷(DISTRIBUTE STRIPE REPLICA VOLUME),是分布式卷,條帶與復制卷的組合,兼具三者的功能,特點如下:

  1. 多個文件哈希分布到到多個條帶集中,單個文件在條帶集中以條帶的形式存儲在2個或多個復制集(replicated sets ),復制集內文件分片以副本的形式保存;
  2. brick server數量是副本數的倍數,且>=2倍,即最少需要4臺brick server。

技術分享圖片

  1. 糾刪卷

糾刪卷(Creating Dispersed Volumes)是v3.6版本後發布的一種volume特點如下:

  1. 基於糾刪碼(erasure codes, EC)實現,類似於raid5/6(取決於redundancy等級);
  2. 通過配置redundancy(冗余)級別提高可靠性,在保證較高的可靠性同時,可以提升物理存儲空間的利用率;
  3. 文件被分割成大小相同的chunk(塊),每個chunk又被分割成fragment,冗余信息的fragment隨之生成,且同一個fragment只會保存一個brick上;
  4. redundancy均勻分布存儲在所有的brick,邏輯卷的有效空間是<usable size> = <brick size> * (#bricks - redundancy);
  5. 在數據恢復時,只要(#bricks - redundancy)個fragment(數據或冗余信息)可用,就能正常恢復數據;
  6. 卷中所有brick容量需要相同,否則最小的brick滿容量時,數據無法寫入;
  7. 實際部署時,redundancy < #bricks / 2 (or equivalently, redundancy * 2 < #bricks),即brick至少是3個;redundancy設置為0時,DispersedVolume等同於分布式卷;若redundancy設置為brick/2時,DispersedVolume等同於復制卷。

創建糾刪卷

# 命令:gluster volume create [disperse [<count>]] [redundancy <count>] [transport tcp | rdma | tcp,rdma]

# 以上命令在任意server節點操作均可,以glusterfs01節點為例;

# 創建名為"disperse-volume"的邏輯卷;

# 必須指定卷類型(默認為分布式卷)與對應的brick server數量;

# 冗余等級"redundancy"需要根據使用brick server數量("disperse conunt"),並結合期望的冗余度數綜合考量;

# 也可不設置冗余等級"redundancy",系統會根據brick server數量("disperse conunt")自動計算最優值,確認即可;如disperse conunt=3,則redundancy=1(無"warning message");disperse conunt=6,則redundancy=2(有"warning message");但disperse conunt=4,則無最優值,此時使用默認redundancy=1(有"warning message");

# "transport tcp"指定集群通信方式,默認即tcp;

[root@glusterfs01 ~]# gluster volume create disperse-volume disperse 3 transport tcp

glusterfs01:/brick1/disperse_volume

glusterfs02:/brick2/disperse_volume

glusterfs03:/brick3/disperse_volume

技術分享圖片

啟動卷

# 卷類型:disperse卷

# "Number of Bricks":rudundancy=1,3個brick server

[root@glusterfs01 ~]# gluster volume start disperse-volume

[root@glusterfs01 ~]# gluster volume info disperse-volume

技術分享圖片

client掛載

[root@glusterfs-client ~]# mkdir /mnt/disperse

[root@glusterfs-client ~]# mount.glusterfs 172.30.200.51:disperse-volume /mnt/disperse/

查看掛載情況

# 已掛載卷的容量是2個brick容量之和,<usable size> = <brick size> * (#bricks - redundancy)

[root@glusterfs-client ~]# df -Th

技術分享圖片

存儲測試

# 在client的掛載目錄下創建若幹文件

[root@glusterfs-client ~]# cd /mnt/disperse/

[root@glusterfs-client disperse]# touch disperse{1..4}.txt

# 向distributed-replica1.txt文件寫入內容

[root@glusterfs-client disperse]# echo "this is disperse1.txt" >> disperse1.txt

# glusterfs01節點

[root@glusterfs01 ~]# tree /brick1/disperse_volume/

[root@glusterfs01 ~]# cat /brick1/disperse_volume/disperse1.txt

技術分享圖片

# glusterfs02節點

[root@glusterfs02 ~]# tree /brick2/disperse_volume/

[root@glusterfs02 ~]# cat /brick2/disperse_volume/disperse1.txt

技術分享圖片

# glusterfs03節點

[root@glusterfs03 ~]# tree /brick3/disperse_volume/

[root@glusterfs03 ~]# cat /brick3/disperse_volume/disperse1.txt

技術分享圖片

結論:糾刪卷將數據文件(含冗余信息)分布在多個brick中,數據有冗余。

  1. 分布式糾刪卷

分布式糾刪卷(Distributed Dispersed Volumes)等效於分布式復制卷,但使用的是糾刪子卷,而非復制子卷。

  1. Glusterfs管理

  1. 均衡卷

# 不遷移數據

gluster volume VOLNAME rebalance [fix-layout start | start | startforce | status | stop]

# 修復卷(只針對復制卷)

gluster volume heal REPLICATE-VOLNAME/DISPERSE-VOLNAME #只修復有問題的文件

gluster volume heal REPLICATE-VOLNAME/DISPERSE-VOLNAME full #修復所有文件

gluster volume heal REPLICATE-VOLNAME/DISPERSE-VOLNAME info #查看自愈詳情

gluster volume heal REPLICATE-VOLNAME/DISPERSE-VOLNAME info healed|heal-failed|split-brain

# 設置卷

gluster volume set options

  1. 刪除卷

# 刪除卷操作,必須先停用卷;

# 最後可清空brick server節點對應目錄下的內容

gluster volume stop distributed-volume

gluster volume delete distributed-volume

rm -f /brick1/dis_volume

  1. brick管理

# 添加brick

gluster volume add-brick VOLNAME NEW-BRICK

# 移除brick

gluster volume remove-brick VOLNAME BRICK [start | status | commit]

# 替換brick

gluster volume replace-brick VOLNAME BRICKNEW-BRICK [start | pause | sbortstatus | commit]

  1. 日誌

相關日誌,在/var/log/glusterfs/目錄下,可根據需要查看;

如/var/log/glusterfs/brick/下是各brick創建的日誌;

如/var/log/glusterfs/cmd_history.log是命令執行記錄日誌;

如/var/log/glusterfs/glusterd.log是glusterd守護進程日誌

GlusterFS分布式存儲集群-2. 使用