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

 

posted @ 2020-02-28 17:26  梦徒  阅读(8676)  评论(1编辑  收藏  举报