一、前言
1、概述
參考資料:
beegfs源碼地址
beegfs官方文檔
beegfs FAQ
BeeGFS是行業領先的並行集群文件系統,設計時優先考慮性能強大的同時,安裝和管理非常方便,是I/O密集型工作負載的優質存儲開源解決方案,軟件整體架構如下圖所示:
組件名稱 | 組件包名稱 | 說明 |
---|---|---|
管理服務 | beegfs-mgmtd | 管理服務用於監控所有已注冊服務的狀態,不存儲用戶任何數據 注:在進行元數據服務、存儲服務、客戶端服務配置時,都需要指向管理服務節點IP地址, 一般集群部署需要第一個部署的服務,有且只有一個 |
元數據服務 | beegfs-meta | 元數據服務用於存儲文件的元數據信息,如目錄結構、權限信息、數據分片存放位置等, 一個文件對應一個元數據文件,客戶端打開文件時,由元數據服務向客戶端提供數據具體存放節點位置, 之后客戶端直接與存儲服務進行數據讀寫操作,可支持橫向擴展,增加多個元數據服務用以提升文件系統性能 |
存儲服務 | beegfs-storage | 存儲服務用於存儲條帶化后的數據塊文件 |
客戶端服務 | beegfs-client beegfs-helperd |
客戶端服務用於集群存儲空間掛載,當服務開啟時自動掛載到本地路徑, 之后可通過nfs/samba服務將本地掛載點導出,提供linux/windows客戶端訪問 注:掛載路徑通過/etc/beegfs/beegfs-mounts.conf 配置文件指定 beegfs-helperd主要用於日志寫入,不需要任何額外配置 |
命令行組件 | beegfs-utils beegfs-common |
提供命令行工具,如beegfs-ctl、beegfs-df、beegfs-fsck等 |
- 配置文件路徑:/etc/beegfs/{package-name}.conf
- 日志文件路徑:/var/log/{package-name}.log
- 服務控制控制管理:systemctl status/start/stop/restart {package-name}
- 應用程序文件路徑:/opt/beegfs/sbin/
注:{package-name}為對應組件包名稱,如beegfs-mgmtd等
二、安裝部署
節點名 | 節點IP | 節點角色 | 軟件版本 |
---|---|---|---|
node190 | 172.16.21.190 | mgmtd、meta、storage、client | 系統版本:CentOS 7.6 軟件版本:BeeGFS 7.2.4 |
node191 | 172.16.21.191 | meta、storage、client | 系統版本:CentOS 7.6 軟件版本:BeeGFS 7.2.4 |
1、配置集群ssh免密登錄
- 配置集群節點主機名和IP映射關系,同步到所有集群節點上
[root@node190 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.16.21.190 node190
172.16.21.191 node191
[root@node190 ~]# scp /etc/hosts 172.16.21.191:/etc/
- 配置機器A到機器B ssh免密登錄
機器A執行ssh-keygen
:在本地~/.ssh
目錄下生成公鑰文件id_rsa.pub
和私鑰文件id_rsa
機器A執行ssh-copy-id {target-hostname}
:將機器A公鑰文件id_rsa.pub
信息追加到機器B~/.ssh/authorized_keys
文件,實現機器A到機器B ssh免密登錄
配置node190->node191 ssh免密登錄
[root@node190 ~]# ssh-keygen
[root@node190 ~]# ssh-copy-id node191
配置node190<-node191 ssh免密登錄
[root@node191 ~]# ssh-keygen
[root@node191 ~]# ssh-copy-id node190
2、軟件安裝
查看beegfs最新穩定版本源:https://www.beegfs.io/release/beegfs_7.2.4/dists/beegfs-rhel7.repo
示例如下:
yum install wget -y
yum install ca-certificates -y
wget -O /etc/yum.repos.d/beegfs-rhel7.repo https://www.beegfs.io/release/latest-stable/dists/beegfs-rhel7.repo
yum install beegfs-mgmtd -y
yum install beegfs-meta -y
yum install beegfs-storage -y
yum install beegfs-helperd beegfs-client beegfs-utils -y
3、集群部署
3.1、部署管理服務
1)、部署服務:
/opt/beegfs/sbin/beegfs-setup-mgmtd -p {mgmtd_path}
- -p:
mgmtd_path
為管理服務數據存放目錄
注:執行此命令后,會在mgmtd_path
下生成format.conf
文件,更新/etc/beegfs/beegfs-mgmtd.conf
配置文件(storeMgmtdDirectory
、storeAllowFirstRunInit
參數)
2)、啟動服務:
systemctl restart beegfs-mgmtd
示例如下:
mkdir -p /data/mgmtd
/opt/beegfs/sbin/beegfs-setup-mgmtd -p /data/mgmtd/
systemctl restart beegfs-mgmtd
3.2、部署元數據服務
1)、部署服務:
/opt/beegfs/sbin/beegfs-setup-meta -p {meta_path} -s {meta_id} -m {mgmtd_host}
- -p:
meta_path
為元數據服務數據存放目錄 - -s:
meta_id
為元數據服務ID,同一集群元數據服務id值不能重復 - -m:
mgmtd_host
為管理服務節點主機名或者IP地址,此處任選其一均可
注:執行此命令后,會在meta_path
下生成format.conf
和nodeNumID
文件,更新/etc/beegfs/beegfs-meta.conf
配置文件(sysMgmtdHost
、storeMetaDirectory
、storeAllowFirstRunInit
、storeFsUUID
參數)
2)、啟動服務:
systemctl restart beegfs-meta
示例如下:
--node190節點使用/dev/sdb1存放元數據,分配元數據服務ID為190,指定管理服務節點主機名為node190--
mkdir /data/meta -p
mount /dev/sdb1 /data/meta/
/opt/beegfs/sbin/beegfs-setup-meta -p /data/meta/ -s 190 -m node190
systemctl restart beegfs-meta
--node191節點使用/dev/sdb1存放元數據,分配元數據服務ID為191,指定管理服務節點主機名為node190--
mkdir /data/meta -p
mount /dev/sdb1 /data/meta/
/opt/beegfs/sbin/beegfs-setup-meta -p /data/meta/ -s 191 -m node190
systemctl restart beegfs-meta
3.3、部署存儲服務
1)、部署服務:
/opt/beegfs/sbin/beegfs-setup-storage -p {storage_path} -s {storage_host_id} -i {storage_id} -m {mgmtd_host}
- -p:
storage_path
為存儲服務數據存放目錄 - -s:
storage_host_id
為存儲服務節點id,同一節點上的存儲服務id一致,一般以ip地址命名 - -i:
storage_id
為存儲服務id,同一集群存儲服務id值不能重復 - -m:
mgmtd_host
為管理服務節點主機名或者IP地址,此處任選其一均可
注:執行此命令后,會在storage_path
下生成format.conf
、nodeNumID
、targetNumID
文件,更新/etc/beegfs/beegfs-client.conf
配置文件(sysMgmtdHost
、storeStorageDirectory
、storeAllowFirstRunInit
、storeFsUUID
參數)
- 啟動服務:
systemctl restart beegfs-storage
示例如下:
--node190節點使用/dev/sdc1和/dev/sdd1存放數據,指定存儲服務節點ID為190,存儲服務ID為1901和1902,管理服務節點主機名為node190--
mkdir /data/storage0{1..2} -p
mount /dev/sdc1 /data/storage01/
mount /dev/sdd1 /data/storage02/
/opt/beegfs/sbin/beegfs-setup-storage -p /data/storage01 -s 190 -i 1901 -m node190
/opt/beegfs/sbin/beegfs-setup-storage -p /data/storage02 -s 190 -i 1902 -m node190
systemctl restart beegfs-storage
--node191節點使用/dev/sdc1和/dev/sdd1存放數據,指定存儲服務節點ID為191,存儲服務ID為1911和1912,管理服務節點主機名為node190--
mkdir /data/storage0{1..2} -p
mount /dev/sdc1 /data/storage01/
mount /dev/sdd1 /data/storage02/
/opt/beegfs/sbin/beegfs-setup-storage -p /data/storage01 -s 191 -i 1911 -m node190
/opt/beegfs/sbin/beegfs-setup-storage -p /data/storage02 -s 191 -i 1912 -m node190
systemctl restart beegfs-storage
3.4、部署客戶端服務
1)、部署服務:
/opt/beegfs/sbin/beegfs-setup-client -m {mgmtd_host}
- -m:
mgmtd_host
為管理服務節點主機名或者IP地址,此處任選其一均可
注:執行此命令后,會更新/etc/beegfs/beegfs-client.conf
配置文件(sysMgmtdHost
參數)
客戶端默認將集群目錄掛載到/mnt/beegfs
,如需修改掛載點,修改/etc/beegfs/beegfs-mounts.conf
配置文件即可
2)、啟動服務:
systemctl restart beegfs-helperd; systemctl restart beegfs-client
示例如下:
/opt/beegfs/sbin/beegfs-setup-client -m node190
systemctl restart beegfs-helperd; systemctl restart beegfs-client
4、配置鏡像組
參考wiki:BuddyGroups
參考aws:如何在 AWS 上構建並行文件系統 BeeGFS – 高可用篇
4.1、概述
4.1.1、BuddyGroups說明
beegfs通過BuddyGroups實現數據和元數據冗余,通常一個Buddy Group為一組兩個目標,組內兩個目標彼此進行數據復制,當一個目標出現故障時仍可以訪問所有的數據,可以將Buddy Group兩個目標存放於不同災備區域(如不同機房、機架、節點),實現機房、機架、節點級別故障冗余。
Buddy Group兩個目標有主輔之分,一個目標為主存儲(primary),一個目標為輔存儲(secondary),進行數據讀寫時,讀寫操作先發送到主存儲,之后主存儲同步寫入到輔存儲,當兩個副本讀寫操作完成后,返回前端應用操作完成。
4.1.2、BuddyGroups故障切換
當Buddy Group主目標無法訪問時,等待短暫時間后仍無法恢復,則會被標記為脫機狀態,此時輔目標將會成為新的主目標接管服務
可通過beegfs-ctl --listtargets --nodetype={node_type} --state
查詢目標狀態,相關狀態描述如下:
[root@node190 ~]# beegfs-ctl --listtargets --nodetype=meta --state
TargetID Reachability Consistency NodeID
======== ============ =========== ======
1 Online Good 1
2 Online Good 2
[root@node190 ~]# beegfs-ctl --listtargets --nodetype=storage --state
TargetID Reachability Consistency NodeID
======== ============ =========== ======
1 Online Good 190
3 Online Good 191
- Reachability(可達性)
用於描述系統是否可以訪問到目標,當管理服務監控到Buddy Group中的主目標無法訪問,會自動進行故障轉移,由輔目標提供讀寫操作
- Online:可以訪問此目標
- Probably-offline:檢測到此目標通信失敗,有可能是服務重啟或者短期網絡故障造成,此狀態下,關於該目標可能出現故障的信息將會廣播到所有節點,以便系統做好故障轉移准備
- Offline:無法達到此目標,如果此目標為某一Buddy Group組的主目標,將會在目標轉換為脫機狀態時立即發起故障轉移,由同組Buddy Group輔目標接管讀寫操作
- Consistency(一致性)
用於描述數據一致性狀態
- Good:目標數據被認為是好的
- Needs-resync:目標數據被認為是不同步的,嘗試重新同步中
- Bad:目標數據被認為是不同步的,嘗試重新同步失敗
4.2、配置說明
- 自動創建鏡像組:
beegfs-ctl --addmirrorgroup --automatic --nodetype={node_type}
注:如需手動指定Buddy Group目標分布,確保同一Buddy Group組兩個目標落在不同故障域上,可使用beegfs-ctl --addmirrorgroup --nodetype={node_type} --primary={target_id} --secondary={target_id} --groupid={group_id}
示例如下,自動創建元數據、數據鏡像組:
[root@node190 ~]# beegfs-ctl --addmirrorgroup --automatic --nodetype=meta
New mirror groups:
BuddyGroupID Node type Node
============ ========= ====
1 primary 1 @ beegfs-meta node190 [ID: 1]
secondary 2 @ beegfs-meta node191 [ID: 2]
Mirror buddy group successfully set: groupID 1 -> target IDs 1, 2
[root@node190 ~]# beegfs-ctl --addmirrorgroup --automatic --nodetype=storage
New mirror groups:
BuddyGroupID Target type Target
============ =========== ======
1 primary 1 @ beegfs-storage node190 [ID: 190]
secondary 3 @ beegfs-storage node191 [ID: 191]
Mirror buddy group successfully set: groupID 1 -> target IDs 1, 3
- 激活元數據鏡像:
beegfs-ctl --mirrormd
注:執行此操作前,需要停止所有客戶端掛載操作systemctl stop beegfs-client
執行此操作后,需要重啟元數據服務systemctl restart beegfs-meta
,重新掛載客戶端systemctl restart beegfs-client
示例如下:
[root@node190 ~]# beegfs-ctl --mirrormd
Operation succeeded.
NOTE:
To complete activating metadata mirroring, please remount any clients and
restart all metadata services now.
- 設置條帶模式:
beegfs-ctl --setpattern --pattern={pattern_type} --chunksize={chunk_size} --numtargets={target_num} {mount_path}
{pattern_type}
:設置使用的條帶模式,可選raid0
(默認值)或buddymirror
{chunk_size}
:每個存儲目標條帶大小,默認為512K
{target_num}
:每個文件條帶目標數,當設置為buddymirror模式時,參數值為buddy group組數
三、Q&A
1、常用操作
1.1、集群使用多元數據部署
在實踐操作中,往往我們需要通過部署多元數據來提升集群性能,示例為單節點起3個元數據服務(meta1、meta2、meta3),參考步驟如下:
1)、創建元數據配置文件,指定服務日志路徑及服務監聽端口
默認情況下,元數據日志路徑為/var/log/beegfs-meta.log
,服務監聽端口為8005
,由於需要起多個元數據服務,故針對不同元數據服務指定不同的日志路徑和服務監聽端口
- 創建3個目錄用於存放3個元數據服務配置文件,將默認配置文件
/etc/beegfs/beegfs-meta.conf
拷貝到對應目錄下
mkdir /etc/beegfs/meta{1..3}.d/
cp /etc/beegfs/beegfs-meta.conf /etc/beegfs/meta1.d/
cp /etc/beegfs/beegfs-meta.conf /etc/beegfs/meta2.d/
cp /etc/beegfs/beegfs-meta.conf /etc/beegfs/meta3.d/
- 修改元數據服務配置文件,指定日志路徑和監聽端口
指定元數據服務meta1日志路徑為/var/log/beegfs-meta1.log
,服務監聽端口為8005
指定元數據服務meta2日志路徑為/var/log/beegfs-meta2.log
,服務監聽端口為8007
指定元數據服務meta3日志路徑為/var/log/beegfs-meta3.log
,服務監聽端口為8009
sed -i 's#logStdFile = /var/log/beegfs-meta.log#logStdFile = /var/log/beegfs-meta1.log#' /etc/beegfs/meta1.d/beegfs-meta.conf
sed -i 's#logStdFile = /var/log/beegfs-meta.log#logStdFile = /var/log/beegfs-meta2.log#' /etc/beegfs/meta2.d/beegfs-meta.conf
sed -i 's#connMetaPortTCP = 8005#connMetaPortTCP = 8007#' /etc/beegfs/meta2.d/beegfs-meta.conf
sed -i 's#connMetaPortUDP = 8005#connMetaPortUDP = 8007#' /etc/beegfs/meta2.d/beegfs-meta.conf
sed -i 's#logStdFile = /var/log/beegfs-meta.log#logStdFile = /var/log/beegfs-meta3.log#' /etc/beegfs/meta3.d/beegfs-meta.conf
sed -i 's#connMetaPortTCP = 8005#connMetaPortTCP = 8009#' /etc/beegfs/meta3.d/beegfs-meta.conf
sed -i 's#connMetaPortUDP = 8005#connMetaPortUDP = 8009#' /etc/beegfs/meta3.d/beegfs-meta.conf
- 部署元數據服務:
/opt/beegfs/sbin/beegfs-setup-meta -c {meta_config} -p {meta_path} -s {meta_id} -m {mgmtd_host}
- -c:
meta_config
為元數據服務配置文件路徑 - -p:
meta_path
為元數據服務數據存放目錄 - -s:
meta_id
為元數據服務ID,同一集群元數據服務id值不能重復 - -m:
mgmtd_host
為管理服務節點主機名或者IP地址,此處任選其一均可
- -c:
/opt/beegfs/sbin/beegfs-setup-meta -c /etc/beegfs/meta1.d/beegfs-meta.conf -p /data/meta1 -s 1 -m node190
/opt/beegfs/sbin/beegfs-setup-meta -c /etc/beegfs/meta2.d/beegfs-meta.conf -p /data/meta2 -s 2 -m node190
/opt/beegfs/sbin/beegfs-setup-meta -c /etc/beegfs/meta3.d/beegfs-meta.conf -p /data/meta3 -s 3 -m node190
- 啟動元數據服務
systemctl restart beegfs-meta@meta1
systemctl restart beegfs-meta@meta2
systemctl restart beegfs-meta@meta3
1.2、指定beegfs集群通訊使用網卡
參考官方文檔:Network Configuration
1)、操作步驟
- 添加需要使用的網卡名稱到配置文件
/etc/beegfs/tcp-only-interfaces.conf
如使用網卡bond0作為beegfs集群通訊使用網卡,echo bond0 > /etc/beegfs/tcp-only-interfaces.conf
- 添加
connInterfacesFile = /etc/beegfs/tcp-only-interfaces.conf
配置到所有beegfs服務配置中
sed -i 's#connInterfacesFile =#connInterfacesFile = /etc/beegfs/tcp-only-interfaces.conf#' /etc/beegfs/beegfs-mgmtd.conf
systemctl restart beegfs-mgmtd
sed -i 's#connInterfacesFile =#connInterfacesFile = /etc/beegfs/tcp-only-interfaces.conf#' /etc/beegfs/meta1.d/beegfs-meta.conf
sed -i 's#connInterfacesFile =#connInterfacesFile = /etc/beegfs/tcp-only-interfaces.conf#' /etc/beegfs/meta2.d/beegfs-meta.conf
sed -i 's#connInterfacesFile =#connInterfacesFile = /etc/beegfs/tcp-only-interfaces.conf#' /etc/beegfs/meta3.d/beegfs-meta.conf
systemctl restart beegfs-meta@meta1
systemctl restart beegfs-meta@meta2
systemctl restart beegfs-meta@meta3
sed -i 's#connInterfacesFile =#connInterfacesFile = /etc/beegfs/tcp-only-interfaces.conf#' /etc/beegfs/beegfs-storage.conf
systemctl restart beegfs-storage
sed -i 's#connInterfacesFile =#connInterfacesFile = /etc/beegfs/tcp-only-interfaces.conf#' /etc/beegfs/beegfs-client.conf
systemctl restart beegfs-client
2)、驗證測試
- 執行
beegfs-check-servers
命令,查看beegfs集群角色通訊使用IP地址跟指定網卡是否匹配
[root@node57 ~]# beegfs-check-servers
Management
==========
node57 [ID: 1]: reachable at 172.16.33.101:8008 (protocol: TCP)
Metadata
==========
571 [ID: 1]: reachable at 172.16.33.101:8005 (protocol: TCP)
572 [ID: 2]: reachable at 172.16.33.101:8009 (protocol: TCP)
573 [ID: 3]: reachable at 172.16.33.101:8007 (protocol: TCP)
Storage
==========
node57 [ID: 57]: reachable at 172.16.33.101:8003 (protocol: TCP)
2、常用命令
- 查看集群服務連接情況:
beegfs-net
- 查看集群服務詳細信息:
beegfs-ctl --listnodes --nodetype={node_type} --details
注:{node_type}
為beegfs集群節點類型,可選mgmt
、meta
、storage
、client
- 查看集群服務狀態:
beegfs-ctl --listtargets --nodetype={node_type} --state
注:{node_type}
為beegfs集群節點類型,可選meta
、storage
- 查看集群存儲池狀態:
beegfs-df
- 刪除集群角色:
beegfs-ctl --removenode --nodetype={node_type} {node_id}
注:{node_id}
可通過beegfs-net
查看ID值
刪除集群角色不會自動遷移對應數據到其他節點,需謹慎使用!!如需遷移數據后刪除,參考官方手冊:FAQ#migrate - 查看集群目錄屬性信息:
beegfs-ctl --getentryinfo {mount_path}
注:{mount-path}
為beegfs集群掛載路徑,當前有RAID0
和Buddy Mirror
兩種模式