CentOS7 GlusterFS文件系統部署


一、GlusterFS簡介

GlusterFS(GNU ClusterFile System)是一種全對稱的開源分布式文件系統,所謂全對稱是指GlusterFS采用彈性哈希算法,沒有中心節點,所有節點全部平等。GlusterFS配置方便,穩定性好,可輕松達到PB級容量,數千個節點。

二、GlusterFS重要概念

birck:GlusterFS的基本元素,以節點服務器目錄形式展現;

volume:多個brick的邏輯集合;

metadata:元數據,用於描述文件、目錄等的信息;

self-heal:用於后台運行檢測副本卷中文件和目錄的不一致性並解決這些不一致;

FUSE:Filesystem Userspace是一個可加載的內核模塊,其支持非特權用戶創建自己的文件系統而不需要修改內核代碼通過在用戶空間運行文件系統的代碼通過FUSE代碼與內核進行橋接;

Gluster Server:數據存儲服務器,即組成GlusterFS存儲集群的節點;

Gluster Client:使用GlusterFS存儲服務的服務器,如KVM、OpenStack、LB RealServer、HA node。

三、GlusterFS部署

1、環境准備

操作系統:CentOS Linux release 7.6.1810 (Core)

內核版本:3.10.0-957.el7.x86_64

關閉防火牆、關閉selinux,hostname能互相解析

主機:192.168.242.128 node-128
主機:192.168.242.129 node-129

2、軟件包安裝(兩台都執行)

# yum -y install centos-release-gluster
# yum -y install glusterfs glusterfs-server glusterfs-fuse

如果是客戶端只需要 glusterfs glusterfs-fuse即可.

3、創建集群

分別啟動glusterd服務(並添加開機自啟動):

# systemctl start glusterd
# systemctl enable glusterd
# systemctl status glusterd

創建集群(任意節點上執行一下操作,向集群中添加節點):

我這是在node-128執行,將node-129加入到集群中

[root@node-128 ~]# gluster peer probe node-129
peer probe: success. 
[root@node-128 ~]#

如果想從集群中去除節點,可以執行如下命令,但該節點中不能存在卷中正在使用的brick。

gluster peer detach 節點名稱

查看集群狀態:

[root@node-128 ~]# gluster peer status
Number of Peers: 1

Hostname: node-129
Uuid: 092883d5-df69-42d0-b3d1-c7146469c76b
State: Peer in Cluster (Connected)

創建分布式卷,命令格式如下:

gluster volume create volume_name replica 2 node1:/data/br1 node2:/data/br1

volumn_name:卷名

node1:節點名

replica:文件保存的份數

/data/br1:可以理解為節點上的目錄,這個目錄最好是一個單獨的分區(分區類型最好為邏輯卷的方式,這樣易於操作系統級別的存儲空間擴展),默認不能使用root分區進行創建卷,如需要root分區創建卷添加force參數

此處,我們使用/opt/brick做為單獨分區的掛載目錄.

# mkdir /opt/brick

創建2副本的復制卷

[root@node-128 ~]# gluster volume create app-data replica 2 node-128:/opt/brick node-129:/opt/brick force
volume create: app-data: success: please start the volume to access data

#列出卷

[root@node-128 ~]# gluster volume list
app-data

啟動這個卷:

[root@node-128 ~]# gluster volume start app-data
volume start: app-data: success
[root@node-128 ~]# 

# 查看卷信息

[root@node-128 ~]# gluster volume info app-data
 
Volume Name: app-data
Type: Replicate
Volume ID: cced03e1-e40a-4f67-ac98-101c5bb00ee5
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node-128:/opt/brick
Brick2: node-129:/opt/brick
Options Reconfigured:
transport.address-family: inet
storage.fips-mode-rchecksum: on
nfs.disable: on
performance.client-io-threads: off
[root@node-128 ~]# 

 #打開GlusterFs磁盤限額,此處限制大小是10G,也可以不用設置.

[root@node-128 ~]# gluster volume quota app-data enable
volume quota : success

[root@node-128 ~]# gluster volume quota app-data limit-usage / 10GB
volume quota : success
[root@node-128 ~]# 

查看這個卷的信息:

[root@node-128 ~]# gluster volume status
Status of volume: app-data
Gluster process                             TCP Port  RDMA Port  Online  Pid
------------------------------------------------------------------------------
Brick node-128:/opt/brick                   49152     0          Y       7263 
Brick node-129:/opt/brick                   49152     0          Y       9463 
Self-heal Daemon on localhost               N/A       N/A        Y       7284 
Quota Daemon on localhost                   N/A       N/A        Y       7378 
Self-heal Daemon on node-129                N/A       N/A        Y       9484 
Quota Daemon on node-129                    N/A       N/A        Y       9950 
 

配置客戶端使用卷

Glusterfs client端有三種客戶端使用方式:Native mount,NFS,Samba

---此處使用Native mount掛載gluster volume 到node-128和node-129節點的本地目錄/gfs-share下:

客戶端安裝:yum install glusterfs glusterfs-fuse attr -y
#mount -t glusterfs node-128:app-data /gfs-share

查看掛載情況:

[root@node-128 ~]# df -h | grep gfs-share
node-128:app-data         10G     0   10G   0% /gfs-share

設置開機自動掛載

vim /etc/fstab

node-128:/app-data  /gfs-share glusterfs  defaults 0 0

使用mount -a檢測並掛載測試

[root@node-128 ~]#cd /gfs-share
[root@node-128 ~]#touch file{1..9}.txt

#分別在node-128 和node-129上驗證,發現在兩個節點的brick里面都存在9個測試文件:

[root@node-128 ~]# ls -l /gfs-share/ | grep -v total | wc -l
9
[root@node-128 ~]#

[root@node-129 ~]# ls -l /gfs-share/ | grep -v total | wc -l
9
[root@node-129 ~]#

至此,GFS復制卷創建完成,gfs有多種卷方式,以后使用在研究...

 

參考文檔:

    https://www.cnblogs.com/fansik/p/9868831.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM