GlusterFS 分布式文件系統(tǒng)原理和centos安裝和配置(三)

一、概述

1、GlusterFS是集群式NAS存儲系統(tǒng),分布式文件系統(tǒng)(POSIX兼容),Tcp/Ip方式互聯(lián)的一個并行的網(wǎng)絡(luò)文件系統(tǒng),通過原生 GlusterFS 協(xié)議訪問數(shù)據(jù),也可以通過 NFS/CIFS 協(xié)議訪問數(shù)據(jù),沒有元數(shù)據(jù)服務(wù)器,實現(xiàn)整個系統(tǒng)的性能、可靠性和穩(wěn)定性。

2、GlusterFS 常見術(shù)語

名稱 解釋
Brick 最基本的存儲單元,表示為trusted storage pool中輸出的目錄,供客戶端掛載用。
Volume 一個卷。在邏輯上由N個bricks組成。
FUSE Unix-like OS上的可動態(tài)加載的模塊,允許用戶不用修改內(nèi)核即可創(chuàng)建自己的文件系統(tǒng)。
Glusterd Gluster management daemon,要在trusted storage pool中所有的服務(wù)器上運行。
POSIX 一個標準,GlusterFS兼容。

3、GlusterFS卷類型

基本卷:

(1) distribute volume:分布式卷

(2) stripe volume:條帶卷

(3) replica volume:復(fù)制卷

復(fù)合卷:

(4) distribute stripe volume:分布式條帶卷

(5) distribute replica volume:分布式復(fù)制卷

(6) stripe replica volume:條帶復(fù)制卷

(7) distribute stripe replicavolume:分布式條帶復(fù)制卷

基本卷:

哈希卷(distributed volume,文件通過hash算法在所有brick上分布,文件級raid0,不具有容錯能力);

復(fù)制卷(replicated volume,生產(chǎn)常用,文件同步復(fù)制到多個brick上,文件級raid1,具有容錯能力,w性能下降r性能提升);

條帶卷(striped volume,不建議使用,單個文件分布到多個brick上,支持超大文件,類似raid0,rr方式round-robin,通常用于HPC(high performance compute)中的超大文件(>10G的單個文件)及高并發(fā)環(huán)境(多人同時訪問同一個文件));

復(fù)合卷:

哈希復(fù)制卷(distributed replicated volume,生產(chǎn)常用,同時具有哈希卷和復(fù)制卷的特點);

哈希條帶卷(distributed striped volume);

復(fù)制條帶卷(replicated striped vlume);

哈希復(fù)制條帶卷(distributed replicated striped volume);

4、開源并行FS比較(glusterfs VS moosefs VS lustre VS ceph):
比較維度

比較緯度 Glusterfs Moosefs Lustre Ceph
成熟度 2003發(fā)布第一個版本lustre1.0,2013年發(fā)布v2.4.0,相當成熟,在HPC領(lǐng)域占有絕大比例 2008年發(fā)布第一個開源版本v1.5,13年發(fā)布GA版v1.6.27,穩(wěn)定,比較成熟的開源DFS 2003發(fā)布第一個版本lustre1.0,2013年發(fā)布v2.4.0,相當成熟,在HPC領(lǐng)域占有絕大比例 2013年發(fā)布v0.71,并已添加到linux kernel中作實驗內(nèi)核,目前不成熟有較多bug,更新穩(wěn)定都是實驗版
穩(wěn)定性 較穩(wěn)定,無重大bug,已有較多組織或機構(gòu)應(yīng)用于生產(chǎn)環(huán)境 較穩(wěn)定,無重大bug 很穩(wěn)定,在HPC領(lǐng)域應(yīng)用很多 核心組件RADOS較穩(wěn)定,每3個月更新一次穩(wěn)定版,有部分企業(yè)用于生產(chǎn)環(huán)境
復(fù)雜度 簡單,無元數(shù)據(jù)服務(wù),用戶空間實現(xiàn),架構(gòu)清晰,xlator樹形結(jié)構(gòu) 簡單,用戶空間實現(xiàn),代碼規(guī)模較小,高度模塊化 復(fù)雜度較高,依賴內(nèi)核實現(xiàn) 較復(fù)雜,c++實現(xiàn),功能較多
高性能 解除元數(shù)據(jù)瓶頸,并行化數(shù)據(jù)訪問 元數(shù)據(jù)單點瓶頸 高性能,HPC領(lǐng)域表現(xiàn)卓越 數(shù)據(jù)分布均衡,并行化度高
擴展性 彈性hash代替元數(shù)據(jù)服務(wù),線性擴展,可輕松擴展到數(shù)百PB量級,支持動態(tài)擴容 可增加存儲server,不能增加MDS 高擴展性,容量可達數(shù)百PB,可在不打斷任何操作的情況下,通過增加新的OSS來實現(xiàn)動態(tài)擴展 高擴展性,支持10-1000臺server,支持TB到PB的擴展,當組件發(fā)生變化時(添加或刪除),自動進行數(shù)據(jù)的重分布
可用性 多元數(shù)據(jù)服務(wù)設(shè)計,數(shù)據(jù)分布提供三種方式的分割:AFR、DHT、stripe,支持自動復(fù)制和自動修復(fù) 元數(shù)據(jù)+日志服務(wù)器,保障元數(shù)據(jù)server,運行時元數(shù)據(jù)放內(nèi)存,可設(shè)置副本 元數(shù)據(jù)集群,可部署主備切換工作方式,無副本設(shè)計,OSS之間可利用共享存儲實現(xiàn)自動故障恢復(fù) 元數(shù)據(jù)集群,沒有單點故障,多數(shù)據(jù)副本,自動管理、自動修復(fù),monitor監(jiān)控集群中所有節(jié)點狀態(tài),且可有多個monitor保證可靠性
可管理性 部署簡單,易于管理和維護,使用底層FS,ext3/zfs,客戶端負載增加;提供管理工具,如卷的擴容、數(shù)據(jù)LB、目錄配額及相關(guān)監(jiān)控等 部署簡單,提供web gui監(jiān)控界面,元數(shù)據(jù)恢復(fù),文件恢復(fù),回收站功能,快照 部署復(fù)雜,需升級kernel等,提供管理工具,如設(shè)置目錄stripe 部署較復(fù)雜,提供工具對集群進行監(jiān)控管理,包括集群狀態(tài),各組件狀態(tài)等
研發(fā)成本 用戶空間實現(xiàn),模塊化堆棧式架構(gòu) 用戶空間實現(xiàn),小規(guī)模 高,內(nèi)核空間實現(xiàn),且代碼規(guī)模大 較高,代碼規(guī)模大,功能多
適用性 適用以文件為對象的存儲體系,適合大文件存儲 小規(guī)模集群,元數(shù)據(jù)瓶頸,內(nèi)存消耗大 大文件,HPC領(lǐng)域 Ceph
NAS兼容 支持NFS、CIFS、HTTP、FTP、gluster原生協(xié)議,與POSIX標準兼容 支持CIFS、NFS,支持標準POSIX接口 支持CIFS、NFS,支持標準POSIX接口 支持CIFS、NFS,支持標準POSIX接口
采用指數(shù) ☆☆☆☆ ☆☆☆ ☆☆☆ ☆☆

二、配置安裝

1、環(huán)境

192.168.1.11 gluster-1-1

192.168.1.12 gluster-1-2

192.168.1.13 gluster-1-3

注意:hosts文件添加解析,時間同步,關(guān)閉iptables和SELinux,三臺各加10G硬盤做存儲數(shù)據(jù)。

2、下載gluster相關(guān)軟件包

vim /etc/yum.repos.d/gfs.repo
http://bits.gluster.org/pub/gluster/glusterfs/3.4.2/x86_64
依賴包:rpcbind    libaio   lvm2-devel
服務(wù)端:yum  install   glusterfs-server glusterfs glusterfs-cli   glusterfs-fuse  glusterfs-libs glusterfs-api 
客戶端:yum  install    glusterfs    glusterfs-fuse  glusterfs-libs 
磁盤分區(qū):mkfs.ext4  -L /brick1  /dev/sdb   分區(qū)、標簽、格式化

3、部署

1)創(chuàng)建目錄并啟動服務(wù)
mkdir /brick1
/etc/init.d/glusterd start

2)添加gluster節(jié)點服務(wù)器
gluster peer probe gluster-1-2
gluster peer probe gluster-1-3

3)查看節(jié)點服務(wù)器
gluster  peer  status

4、創(chuàng)建卷

1)創(chuàng)建testvol卷(默認是哈希卷)
gluster volume create testvol gluster-1-1:/brick1/b1 哈希卷
gluster volume create gs2 replica 2 gluster-1-1:/brick1/b1  gluster-1-2:/brick1/b2 復(fù)制卷

2)啟動卷
gluster volume start testvol

3)查看卷
gluster volume info 

4)刪除卷
gluster volume remove-brick testvol gluster-1-2:/brick1/b2
5、客戶端測試

1)客戶端掛載卷
mount -t glusterfs gluster-1-1:/testvol /mnt

2)測試
df -h   mount    等
touch  {1..9}.txt
rm 4.txt

6、節(jié)點操作

1)刪除節(jié)點服務(wù)器
gluster peer detach gluster-1-2 不能刪除自己

2)添加節(jié)點服務(wù)器
gluster peer probe gluster-1-2
gluster volume add-brick testvol gluster-1-2:/brick1/b2 (b2下面不能有文件)

3)重新LB,要在閑時做,分兩步,先fix-layout將hash算法重分配,再將數(shù)據(jù)重分配
gluster volume rebalance testvol fix-layout start
gluster volume rebalance testvol start

4)查看rebalance平衡狀態(tài)
gluster volume rebalance testvol status

7、刪除卷

1)卸載掛載點
umount /mnt -lf
2)刪除卷
gluster volume stop testvol
gluster volume delete testvol (卷刪除后,內(nèi)容還在)
rm -rf /brick1/b1 

8、恢復(fù)卷信息

1)卷信息的目錄
ll /var/lib/glusterd/vols/testvol/

2)恢復(fù)命令
gluster volume sync gluster-1-1  all

9、其他

1)允許可信任客戶端IP
gluster volume set testvol auth.allow 192.168.1.*

2)關(guān)閉gluster的nfs功能
ps -ef | grep nfs
gluster volume set testvol nfs.disable on

10、故障

1)復(fù)制卷數(shù)據(jù)不一致
故障現(xiàn)象:雙副本卷數(shù)據(jù)出現(xiàn)不一致
故障模擬:刪除其中一個brick數(shù)據(jù)
修復(fù)方法
  cat 文件
 觸發(fā)自修復(fù):遍歷并訪問文件
 find /mnt -type f -print0 | xargs -0 head -c1

2)glusterfs集群節(jié)點配置信息不正確
恢復(fù)復(fù)制卷 brick
 故障現(xiàn)象:雙副本卷中一個brick損壞
 恢復(fù)流程
a、重新建立故障brick目錄
  mkdir b2
b、設(shè)置擴展屬性(參考另一個復(fù)制 brick)
 getfattr -d -m . -e hex b1/  獲取擴展屬性
 setfattr -n trusted.glusterfs.volume-id -v 0x1fa96ed0a0624ccf9e4f07cb9d84296f b2
 setfattr -n trusted.gfid -v 0x00000000000000000000000000000001  b2
 setfattr -n trusted.glusterfs.dht -v 0x000000010000000000000000ffffffff b2
c、重啟 glusterd服務(wù)
 /etc/init.d/glusterd restart
 gluster volume stop testvol
 gluster volume start testvol
d、觸發(fā)數(shù)據(jù)自修復(fù)
 find /mntpoint -type f -print0 | xargs -0 head -c1 >/dev/null


3)修復(fù)磁盤數(shù)據(jù)(在使用server1時宕機,使用server2替換,執(zhí)行數(shù)據(jù)同步)
gluster volume replace-brick testvol server1:/brick1/b1 server2:/brick1/b1 commit force
gluster volume heal testvol full

GlusterFS 客戶端常用命令

命令 功能
gluster peer probe 添加節(jié)點
gluster peer detach 移除節(jié)點
gluster volume create 創(chuàng)建卷
gluster volume start 啟動卷
gluster volume stop 停止卷
gluster volume delete 刪除卷
gluster volume quota enable 開啟卷配額
gluster volume quota enable 關(guān)閉卷配額
gluster volume quota limit-usage 設(shè)定卷配額

創(chuàng)建卷

1、創(chuàng)建分布卷
 gluster volume create dis_vol  gluster-1-1:/brick1/b1 gluster-1-2:/brick1/b2   gluster-1-3:/brick1/b3
 
2、創(chuàng)建復(fù)制卷
 gluster volume create rep_vol replica 2 gluster-1-1:/brick1/b1 gluster-1-2:/brick1/b2  gluster-1-3:/brick1/b3

3、創(chuàng)建條帶卷
 gluster volume create str_vol  stripe 3 gluster-1-1:/brick1/b1 gluster-1-2:/brick1/b2  gluster-1-3:/brick1/b3

4、創(chuàng)建分布條帶卷
 gluster volume create dir_str_vol stripe 4  gluster-1-1:/brick1/b1 gluster-1-2:/brick1/b2  gluster-1-3:/brick1/b3

5、創(chuàng)建分布復(fù)制卷
 gluster volume create dir_rep_vol replica 2  gluster-1-1:/brick1/b1 gluster-1-2:/brick1/b2  gluster-1-3:/brick1/b3

6、創(chuàng)建分布條帶復(fù)制
 gluster volume create dis_str_rep_vol stri  2 repl 2  gluster-1-1:/brick1/b1 gluster-1-2:/brick1/b2  gluster-1-3:/brick1/b3

7、創(chuàng)建條帶復(fù)制卷
 gluster volume create str_rep_vol stripe 2 replica 2  gluster-1-1:/brick1/b1 gluster-1-2:/brick1/b2  gluster-1-3:/brick1/b3

8、創(chuàng)建分散卷(不常用)
 gluster volume create disperse_vol disperse 4 gluster-1-1:/brick1/b1 gluster-1-2:/brick1/b2  gluster-1-3:/brick1/b3

資源定義

Brick: 存儲的基本單元,表現(xiàn)為服務(wù)器上可信存儲池的導(dǎo)出目錄
Volume: 卷是bricks的邏輯集合
Cluster: 一組計算機組成的集群
Distributed File System: 允許多個客戶端通過網(wǎng)絡(luò)并發(fā)訪問的文件系統(tǒng)
GFID: 每個GlusterFs中的文件或者目錄都有一個128bit的數(shù)字標識稱為GFID
glusterd: 管理守護進程需要運行在所有的提供授信存儲池的服務(wù)器上
Namespace: 名稱空間是被創(chuàng)建的一個抽象容器或環(huán)境用來保存唯一標識符號
Quorum: 設(shè)置一個可信的存儲池中最多失效的主機節(jié)點數(shù)量
Quota: 允許通過目錄或者卷設(shè)置對磁盤空間使用的限制
Posix: 可移植操作系統(tǒng)接口是IEEE定義的一系列相關(guān)api標準
Vol File: Vol文件是glusterfs進程使用的配置文件
Distributed: 分布卷
Replicated: 復(fù)本卷
Distributed Replicated: 分布式復(fù)制卷
Geo-Replication: 異地備份為站點通過局域網(wǎng)、廣域網(wǎng)、互聯(lián)網(wǎng)提供一個連續(xù)的異步的和增量復(fù)制服務(wù)
Metedata: 元數(shù)據(jù)定義為關(guān)于數(shù)據(jù)的數(shù)據(jù)描述信息,在GlusterFs沒有專用的元數(shù)據(jù)存儲內(nèi)容
Extended Attributes: 擴展屬性是文件系統(tǒng)的一個特性 
FUSE: 用戶空間的文件系統(tǒng)是一個用于類Unix操作系統(tǒng)的可加載內(nèi)核模塊,以允許非特權(quán)用戶在適用內(nèi)核代碼的情況下創(chuàng)建自己的文件系統(tǒng)。實現(xiàn)了在用戶空間下運行文件系統(tǒng)代碼

創(chuàng)建volume

Distributed:分布式卷,文件通過hash算法隨機的分布到由bricks組成的卷上。 
Replicated:復(fù)制式卷,類似raid1,replica數(shù)必須等于volume中brick所包含的存儲服務(wù)器數(shù),可用性高。 
Striped:條帶式卷,類似與raid0,stripe數(shù)必須等于volume中brick所包含的存儲服務(wù)器數(shù),文件被分成數(shù)據(jù)塊,以Round Robin的方式存儲在bricks中,并發(fā)粒度是數(shù)據(jù)塊,大文件性能好。 
Distributed Striped:分布式的條帶卷,volume中brick所包含的存儲服務(wù)器數(shù)必須是stripe的倍數(shù)(>=2倍),兼顧分布式和條帶式的功能。 
Distributed Replicated:分布式的復(fù)制卷,volume中brick所包含的存儲服務(wù)器數(shù)必須是 replica 的倍數(shù)(>=2倍),兼顧分布式和復(fù)制式的功能。

其他資料:https://www.cnblogs.com/xingxiz/p/10615888.html

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

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

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