GlusterFS是什么意思

44次阅读
没有评论

这篇文章主要介绍了 GlusterFS 是什么意思,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让丸趣 TV 小编带着大家一起了解一下。

一、GlusterFS 相关概念:

GlusterFS 是一个开源的分布式文件系统,同时也是 Scale-Out 存储解决方案 Gluster 的核心,在存储数据方面有强大的横向扩展能力。GlusterFS 主要由存储服务器、客户端及 NFS/Samba 存储网关(可选组件)组成。GlusterFS 架构中最大的设计特点是没有元数据服务器组件,也就是说没有主 / 从服务器之分,每一个节点都可以是主服务器。
.
1、Gluster 相关参考文档如下(我下面的配置是基于本地 yum 配置的,若需要搭建最新版本,可直接按照下面的文档链接进行配置):
.
Gluster 官网 :https://wiki.centos.org/SpecialInterestGroup/Storage/gluster-Quickstart
基于 centos7/Redhat 安装 Gluster 官方文档:https://blog.csdn.net/daydayup_gzm/article/details/52748812
.
2、GlusterFS 相关术语:
.

Brick(存储块):指可信主机池中由主机提供的用于物理存储的专用分区。
Volume(逻辑卷):一个逻辑卷是一组 Brick 的集合。卷是数据存储的逻辑设备。
FUSE:是一个内核模块,允许用户自己创建文件系统,无须修改内核代码。
Glusterd(后台管理进程):在存储群集中的每个节点上都要运行。
VFS:内核空间对用户空间提供的访问磁盘的接口。

3、GlusterFS 的卷类型:

分布式卷:相当于 Windows 中的跨区卷,只是扩大了磁盘空间,不具有容错能力;

条带卷:相当于 Windows 中的带区卷,属于 RAID 0 级别,一份文件会在多个磁盘上进行读写,文件越大,读写效率越高,但不具有容错能力;

复制卷:相当于 Windows 中的镜像卷,属于 RAID 1 级别,具有容错能力,读性能高,但写性能下降,因为要将同一份文件同步写入在多个 Brick 上。

分布式条带卷:brick server 数量是条带数(数据块分布的 brick 数量)的倍数,兼具分布式卷和条带卷的特点。

分布式复制卷:brick server 数量是镜像数(数据副本数量)的倍数,兼具分布式卷和复制卷的特点。

条带复制卷:类似于 RAID 10,同时具备条带卷和复制卷的特点。

分布式条带复制卷:三种基本卷的复合卷,通常用于 map reduce 应用。
在以上几种卷类型中,有些可能无法理解透彻,但是没关系,在生产环境中,大多数公司考虑到磁盘的利用率,会使用 RAID5,或者 RAID 10,关于 RAID 5 卷的配置可以参考:GlusterFS Dispersed Volume(纠错卷)总结。

4、下面介绍 GlusterFS 一些卷类型的特点(不包括 RAID5):

1、分布式卷(类似 Windows 中的跨区卷):
.
分布式卷是 GlusterFS 的默认卷,在创建卷时,默认选项是创建分布式卷。在该模式下,并没有对文件进行分块处理,文件直接存储在某个 server 节点上。
.
分布式卷具有如下特点:
.

1、文件分布在不同的服务器,不具备冗余性。
2、更容易且廉价地扩展卷的大小。
3、单点故障会造成数据丢失。
4、依赖底层的数据保护。

2、条带卷(类似 Windows 中的带区卷,也称为 RAID 0):
.
stripe 模式相当于 RAID 0,在该模式下,根据偏移量将文件分成 N 块(N 个条带节点),轮询地存储在每个 Brick Server 节点。节点把每个数据块都作为普通文件存入本地文件系统,通过扩展属性记录总块数和每块的序号。在配置时指定条带数必须等于卷中 Brick 所包含的存储服务器数,在存储大文件时,性能尤为突出,但是不具备冗余性。
.
条带卷具有如下特点:
.

1、数据被分割成更小块分布到块服务器群中的不同条带区。
2、分布减少了负载且更小的文件加速了存取的速度。
3、没有数据冗余。

3、复制卷(类似于 Windows 中的镜像卷,也称为 RAID 1)
.
复制模式,即同一文件保存一份或多份副本,每个节点上保存相同的内容和目录结构。复制模式因为要保存副本,所以磁盘利用率较低,如果多个节点上的存储空间不一致,那么将按照木桶效应取最低节点的容量作为该卷的总容量。复制卷具有冗余性,即使一个节点损坏,也不影响数据的正常使用。
.
复制卷具有如下特点:

1、卷中所有的服务器均保存一个完整的副本。
2、卷的副本数量可由客户创建的时候决定。
3、至少有两个块服务器或更多服务器。
4、具备冗余性。
4、分布式复制卷(也称为 RAID 10):

分布式复制卷兼顾分布式卷和复制卷的功能,主要用于需要冗余的情况下。
.
二、GlusterFS 各种卷类型的部署及客户端挂载使用:
.
环境如下:
GlusterFS 是什么意思
相关信息:
GlusterFS 是什么意思
磁盘挂载信息:
GlusterFS 是什么意思
.
准备工作:
1、在所有节点上进行操作:根据上表中添加磁盘,通过 fdisk 命令进行分区,mkfs 格式化,创建相应的挂载目录,并将格式化的磁盘挂载到相应的目录中,最后修改 /etc/fstab 配置文件,使其永久挂载。
可参考博文:https://blog.51cto.com/14154700/2350748
2、配置防火墙放行流量
3、本地 yum 仓库:https://pan.baidu.com/s/1ZzURDjGsue7cPnVPdKFCvA(提取码:309q)
开始部署:
.
node1 的配置:

配置 hosts 文件
[root@node1 /]# vim /etc/hosts #  添加四个节点的解析
............... //  省略部分内容
192.168.1.10 node1
192.168.1.20 node2
192.168.1.30 node3
192.168.1.40 node4
[root@node1 /]# mount /dev/sr0 /media/ #  挂在本地 yum 仓库
mount: /dev/sr0 is write-protected, mounting read-only
[root@node1 /]# rm -rf /etc/yum.repos.d/* # 删除原有 yum 配置文件(或者移走也行)[root@node1 /]# vim /etc/yum.repos.d/a.repo #  编写 yum 配置文件
[yum]
baseurl=file:///media
gpgcheck=0
[root@node1 /]# yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma # yum 安装  gluster,所有节点都需要做
[root@node1 /]# systemctl start glusterd #  启动服务
[root@node1 /]# systemctl enable glusterd

node2 的配置:
.
因为所有节点大部分配置都是相同的,所以我们可以使用 scp 命令来将配置好的节点文件复制来使用

[root@node2 /]# scp root@192.168.1.10:/etc/hosts /etc/ #  将 hosts 解析文件复制过来
The authenticity of host  192.168.1.10 (192.168.1.10)  can t be established.
ECDSA key fingerprint is 68:df:0f:ac:c7:75:df:02:88:7d:36:6a:1a:ae:27:23.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added  192.168.1.10  (ECDSA) to the list of known hosts.
root@192.168.1.10 s password: #  输入密码
hosts 100% 234 0.2KB/s 00:00 
[root@node2 /]# rm -rf /etc/yum.repos.d/*
[root@node2 /]# scp root@192.168.1.10:/etc/yum.repos.d/* /etc/yum.repos.d/
root@192.168.1.10 s password: 
a.repo 100% 39 0.0KB/s 00:00 
[root@node2 /]# mount /dev/sr0 /media #  挂载 yum 仓库
[root@node2 /]# yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma #  安装软件
[root@node2 /]# systemctl start glusterd #  启动服务
[root@node2 /]# systemctl enable glusterd

node3 和 node4 照着 node2 配置操作就可以
.
添加节点(接下来的所有配置,在任意一台节点上执行都可以,我这里在 node1 上执行):

[root@node1 /]# gluster peer probe node1
peer probe: success. Probe on localhost not needed #  表示当前就在 node1 上,已经存在,不需要再添加了
[root@node1 /]# gluster peer probe node2
peer probe: success. 
[root@node1 /]# gluster peer probe node3
peer probe: success. 
[root@node1 /]# gluster peer probe node4
peer probe: success. 
[root@node1 /]# gluster peer status #  添加完毕后查看群集状态
Number of Peers: 3
Hostname: node2
Uuid: b25b967a-0ec6-4e2e-841f-b13368ec6d73
State: Peer in Cluster (Connected) # 如果某个节点显示 Disconnected,请检查 hosts 配置文件
Hostname: node3
Uuid: 3ce5c3aa-c1da-4112-825d-998e71220423
State: Peer in Cluster (Connected)
Hostname: node4
Uuid: 0c543cae-ec0c-4249-8600-605e0f552b11
State: Peer in Cluster (Connected)

创建卷:
1、创建分布式卷:

[root@node1 /]# gluster volume create dis-volume node1:/e6 node2:/e6 force # force:强制  ;  其中“dis-volume”为卷名,没有指定类型,默认创建的是分布式卷。volume create: dis-volume: success: please start the volume to access data
[root@node1 /]# gluster volume info dis-volume #  查看该卷相关信息,通过修改卷名也可以查看其它卷的信息
Volume Name: dis-volume
Type: Distribute
Volume ID: 09a6443c-a544-475d-9084-28892ce0093f
Status: Started
Snapshot Count: 0
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: node1:/e6
Brick2: node2:/e6
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
[root@node1 /]# gluster volume start dis-volume #  启用该卷
volume start: dis-volume: success

2、创建条带卷:

[root@node1 /]# gluster volume create stripe-volume stripe 2 node1:/d5 node2:/d5 force
volume create: stripe-volume: success: please start the volume to access data
#创建条带卷,指定条带卷的个数为 2 个。“stripe-volume”为卷名
#指定类型为 stripe,数值为 2,而且后面跟了 2 个 brick server,所以创建的是条带卷
[root@node1 /]# gluster volume start stripe-volume #  启用该卷
volume start: stripe-volume: success

3、创建复制卷:

[root@node1 /]# gluster volume create rep-volume replica 2 node3:/d5 node4:/d5 force
volume create: rep-volume: success: please start the volume to access data
#指定类型为“replica”,数值为“2”,而且后面跟了两个 brick server,所以创建的是复制卷
[root@node1 /]# gluster volume start rep-volume #  启用该卷
volume start: rep-volume: success

4、创建分布式条带卷:

[root@node1 /]# gluster volume create dis-stripe stripe 2 node1:/b3 node2:/b3 node3:/b3 node4:/b3 force
volume create: dis-stripe: success: please start the volume to access data
#指定类型为 stripe,数值为 2,而且后面跟了 4 个 brick server,所以创建的是分布式条带卷
[root@node1 /]# gluster volume start dis-stripe #  启用
volume start: dis-stripe: success

5、创建分布式复制卷:

[root@node1 /]# gluster volume create dis-rep replica 2 node1:/c4 node2:/c4 node3:/c4 node4:/c4 force
volume create: dis-rep: success: please start the volume to access data
#指定类型为 replica,数值为 2,而且后面跟了 4 个 brick server,是 2 的两倍,所以创建的是分布式复制卷
[root@node1 /]# gluster volume start dis-rep
volume start: dis-rep: success

至此需要的卷就创建完毕了。
.
部署 Gluster 客户端:
.
1、安装客户端软件

[root@client /]# rm -rf /etc/yum.repos.d/*
[root@client /]# scp root@192.168.1.10:/etc/yum.repos.d/* /etc/yum.repos.d/
root@192.168.1.10 s password: 
a.repo 100% 39 0.0KB/s 00:00 
#  挂载本地 yum 仓库
[root@client /]# yum -y install glusterfs glusterfs-fuse # yum 安装客户端

2、创建挂载目录:

[root@client /]# mkdir -p /test/{dis,stripe,rep,dis_and_stripe,dis_and_rep}
[root@client /]# ls /test/
dis dis_and_rep dis_and_stripe rep stripe

3、修改 hosts 文件:(直接 scp 复制也可以)

[root@client /]# scp root@192.168.1.10:/etc/hosts /etc/
The authenticity of host  192.168.1.10 (192.168.1.10)  can t be established.
ECDSA key fingerprint is 68:df:0f:ac:c7:75:df:02:88:7d:36:6a:1a:ae:27:23.
Are you sure you want to continue connecting (yes/no)? yesd
Warning: Permanently added  192.168.1.10  (ECDSA) to the list of known hosts.
root@192.168.1.10 s password: 
hosts 100% 234 0.2KB/s 00:00 
[root@client /]# cat /etc/hosts
.................. //  省略部分
192.168.1.10 node1
192.168.1.20 node2
192.168.1.30 node3
192.168.1.40 node4

4、挂载 Gluster 文件系统:

[root@client /]# mount -t glusterfs node1:dis-volume /test/dis
[root@client /]# mount -t glusterfs node1:stripe-volume /test/stripe
[root@client /]# mount -t glusterfs node1:rep-volume /test/rep/
[root@client /]# mount -t glusterfs node1:dis-stripe /test/dis_and_stripe/
[root@client /]# mount -t glusterfs node1:dis-rep /test/dis_and_rep/
[root@client /]# df -h #  查看挂载信息,如果挂载不成功,请检查 hosts 解析文件
文件系统   容量   已用   可用   已用 %  挂载点
................. //  省略部分
node1:dis-volume 12G 65M 12G 1% /test/dis
node1:stripe-volume 10G 65M 10G 1% /test/stripe
node1:rep-volume 5.0G 33M 5.0G 1% /test/rep
node1:dis-stripe 12G 130M 12G 2% /test/dis_and_stripe
node1:dis-rep 8.0G 65M 8.0G 1% /test/dis_and_rep

5、修改 fstab 文件,设置自动挂载:

[root@client /]# vim /etc/fstab 
.................. //  省略部分
node1:stripe-volume /test/stripe glusterfs defaults,_netdev 0 0
node1:rep-volume /test/rep glusterfs defaults,_netdev 0 0
node1:dis-stripe /test/dis_and_stripe glusterfs defaults,_netdev 0 0
node1:dis-rep /test/dis_and_rep glusterfs defaults,_netdev 0 0
node1:dis-volume /test/dis glusterfs defaults,_netdev 0 0

GlusterFS 维护命令:

[root@node1 /]# gluster volume list //  查看卷的列表
dis-rep
dis-stripe
dis-volume
rep-volume
stripe-volume
[root@node1 /]# gluster volume info //  查看所有卷的信息
Volume Name: dis-rep
Type: Distributed-Replicate
Volume ID: f57c0228-4a5f-4995-8fac-87f9bc034c33
Status: Started
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/c4
Brick2: node2:/c4
Brick3: node3:/c4
Brick4: node4:/c4
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
................ //  省略部分
[root@node1 /]# gluster volume status //  查看卷的状态
Status of volume: dis-rep
Gluster process TCP Port RDMA Port Online Pid
------------------------------------------------------------------------------
Brick node1:/c4 49155 0 Y 13656
Brick node2:/c4 49155 0 Y 13443
Brick node3:/c4 49154 0 Y 13480
Brick node4:/c4 49154 0 Y 13334
Self-heal Daemon on localhost N/A N/A Y 13676
Self-heal Daemon on node2 N/A N/A Y 13463
Self-heal Daemon on node4 N/A N/A Y 13354
Self-heal Daemon on node3 N/A N/A Y 13500
Task Status of Volume dis-rep
------------------------------------------------------------------------------
[root@node1 ~]# gluster volume stop dis-stripe # 停止一个卷
Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y
volume stop: dis-stripe: success
[root@node1 ~]# gluster volume delete dis-stripe # 删除一个卷
Deleting volume will erase all information abe. Do you want to continue? (y/n) y
volume delete: dis-stripe: success
[root@node1 ~]# gluster volume set dis-rep auth.allow 192.168.1.*,10.1.1.* 
#设置只允许特定网段的客户端访问卷 dis-rep
volume set: success

感谢你能够认真阅读完这篇文章,希望丸趣 TV 小编分享的“GlusterFS 是什么意思”这篇文章对大家有帮助,同时也希望大家多多支持丸趣 TV,关注丸趣 TV 行业资讯频道,更多相关知识等着你来学习!