GlusterFS 存储应用简介

glusterFS 分布式文件系统简介

glusterFS 概述

glusterFS (gluster File System) 是一个开源的分布式文件系统,主要由 Z RESEARCH 公司负责开发。glusterFS 是 Scale-Out 存储解决方gluster 的核心,具有强大的横向扩展能力,通过扩展能够支持数PB存储容量和处理数千客户端。glusterFS 借助 TCP/IP 或 InfiniBand RDMA 网络将物理分布的存储资源聚集在一起,使用单一全局命名空间来管理数据。glusterFS 基于可堆叠的用户空间设计,可为各种不同的数据负载提供优异的性能

glusterFS 总体架构与组成部分如图1所示,它主要由存储服务器(Brick Server)、客户端以及 NFS/Samba 存储网关组成。不难发现,glusterFS 架构中没有元数据服务器组件,这是其最大的设计这点,对于提升整个系统的性能、可靠性和稳定性都有着决定性的意义。

  • glusterFS 支持 TCP/IP 和 InfiniBand RDMA 高速网络互联。

  • 客户端可通过原生 glusterFS 协议访问数据,其他没有运行 glusterFS 客户端的终端可通过 NFS/CIFS 标准协议通过存储网关访问数据(存储网关提供弹性卷管理和访问代理功能)。

  • 存储服务器主要提供基本的数据存储功能,客户端弥补了没有元数据服务器的问题,承担了更多的功能包括数据卷管理、I/O 调度、文件定位、数据缓存等功能,利用 FUSE(File system in User Space)模块将 glusterFS 挂载到本地文件系统之上,实现 POSIX 兼容的方式来访问系统数据。

图1. glusterFS 总体架构

wKiom1mCm-aiYkN0AAEEYDafnuM478.png-wh_50

如图 1 中 glusterFS 有非常多的术语,理解这些术语对理解 glusterFS 的动作机理是非常重要的,表1给出了 glusterFS 常见的名称及其解释。

表1. glusterFS 常见术语

glusterdPOSIX

glusterFS卷类型

为了满足不同应用对高性能、高可用的需求,glusterFS 支持 7 种卷,即 distribute 卷、stripe 卷、replica 卷、distribute stripe 卷、distribute replica 卷、stripe Replica 卷、distribute stripe replica 卷。其实不难看出,glusterFS 卷类型实际上可以分为 3 种基本卷和 4 种复合卷,每种类型的卷都有其自身的特点和适用场景。

基本卷:

(1) distribute volume 分布式卷

基于 Hash 算法将文件分布到所有 brick server,只是扩大了磁盘空间,不具备容错能力。由于distribute volume 使用本地文件系统,因此存取效率并没有提高,相反会因为网络通信的原因使用效率有所降低,另外本地存储设备的容量有限制,因此支持超大型文件会有一定难度。图2 是 distribute volume 示意图。

图2. distribute volume示意图

wKiom1mCm_-yoER-AACEm3AKmZ0083.jpg-wh_50

(2) stripe volume 条带卷

类似 RAID0,文件分成数据块以 Round Robin 方式分布到 brick server 上,并发粒度是数据块,支持超大文件,大文件的读写性能高。图3 是 stripe volume 示意图。

图3. Stripe volume示意图

wKiom1mCnBjhinPTAACCRuGW2Lw880.jpg-wh_50

(3) replica volume 复制卷

文件同步复制到多个 brick 上,文件级 RAID1,具有容错能力,写性能下降,读性能提升。Replicated 模式,也称作 AFR(Auto File Replication),相当于 RAID1,即同一文件在多个镜像存储节点上保存多份,每个 replicated 子节点有着相同的目录结构和文件,replica volume 也是在容器存储中较为推崇的一种。图4 是 replica volume 示意图。

图4 . Replica volume示意图

wKioL1mCnCiyz88vAACBos6izYs207.jpg-wh_50

复合卷:

(4) distribute stripe volume 分布式条带卷

Brick server 数量是条带数的倍数,兼具 distribute 和 stripe 卷的特点。分布式的条带卷,volume 中 brick 所包含的存储服务器数必须是 stripe 的倍数(>=2倍),兼顾分布式和条带式的功能。每个文件分布在四台共享服务器上,通常用于大文件访问处理,最少需要 4 台服务器才能创建分布条带卷。图5 是distribute stripe volume 示意图。

图5 . distribute stripe volume 示意图

wKiom1mCnDSSi0oPAACeMDClQzw796.jpg-wh_50

(5) distribute replica volume 分布式复制卷

Brick server 数量是镜像数的倍数,兼具 distribute 和 replica 卷的特点,可以在 2 个或多个节点之间复制数据。分布式的复制卷,volume 中 brick 所包含的存储服务器数必须是 replica 的倍数(>=2倍),兼顾分布式和复制式的功能。图6 是 distribute replica volume 示意图。

图6 . distribute replica volume 示意图

wKiom1mCnEKQl9EXAACc5B34xlg376.jpg-wh_50

(6) stripe replica volume 条带复制卷

类似 RAID 10,同时具有条带卷和复制卷的特点。图7 是 distribute replica volume 示意图。

图7 . Stripe replica volume 示意图

wKiom1mCnE_C6oTUAADyowt1FiA499.png-wh_50

(7) distribute stripe replica volume:分布式条带复制卷

三种基本卷的复合卷,通常用于类 Map Reduce 应用。图8 是 distribute stripe replica volume 示意图。

图8 . distribute stripe replica volume 示意图

wKiom1mCnGDiP6B6AAEMBq77dL0594.png-wh_50

glusterFS 常用命令

glusterFS 客户端提供了非常丰富的命令用来操作节点、卷,表2给出了常用的一些命令。在与容器对接过程中,通过我们需要创建卷、删除卷,以及设定卷的配额等功能,并且后续这些功能也需要 REST API 化,方便通过HTTP请求的方式来操作卷。

表2. glusterFS 客户端常用命令

gluster peer detachgluster volume creategluster volume startgluster volume stopgluster volume deletegluster volume quota enable关闭卷配额gluster volume quota limit-usage


glusterFS 分布式文件系统安装与配置

glusterFS 集群搭建

Server:192.168.1.10  gfs01
Client1:192.168.1.20 gfs02
Client2:192.168.1.30 gfs03


系统环境centos6.5

glusterfs 版本3.10

更新yum源

下载 CentOS-Gluster-3.10.repo 放在/etc/yum.repos.d/目录下

下载RPM-GPG-KEY-CentOS-SIG-Storage放在/etc/pki/rpm-gpg/目录下

yumcleanall
yummakecache

集群安装、配置

yum-yinstallglusterfs-serverglusterfsglusterfs-fuse
serviceglusterdrestar

#在服务端将gfs02、gfs03节点加入gluster集群中,并创建存储卷:
[root@gfs01~]#glusterpeerprobegfs02
[root@gfs01~]#glusterpeerprobegfs03

#创建条带复制卷
[root@gfs01~]#glustervolumecreateMainstripe2replica2transporttcpgfs02:/gluster_storage/storage01gfs03:/gluster_storage/storage01gfs02:/gluster_storage/storage02gfs03:/gluster_storage/storage02force

#启动
[root@gfs01~]#glustervolumestartMain

#查看状态
[root@gfs01~]#glustervolumestatus
Statusofvolume:Main
glusterprocesstCPPortRDMAPortOnlinePid
------------------------------------------------------------------------------
Brickgfs02:/gluster_storage/storage01491520Y9233
Brickgfs03:/gluster_storage/storage01491520Y9158
Brickgfs02:/gluster_storage/storage02491530Y9252
Brickgfs03:/gluster_storage/storage02491530Y9177
Self-healDaemononlocalhostN/AN/AY10239
Self-healDaemonongfs02N/AN/AY9272
Self-healDaemonongfs03N/AN/AY9197

TaskStatusofVolumeMain
------------------------------------------------------------------------------
TherearenoactivevoluMetasks


[root@gfs01~]#glusterpeerstatus
NumberofPeers:2

Hostname:gfs03
Uuid:d7ab04f2-4358-4d1c-8aed-489aeae14a62
State:PeerinCluster(Connected)

Hostname:gfs02
Uuid:ba07e12d-da70-4b6d-bcd1-5e340a97631b
State:PeerinCluster(Connected)

挂载:

[root@gfs01~]#mkdir-p/gluster_storage/storage
[root@gfs01~]#mount-tglusterfsgfs01:/Main/gluster_storage/storage

#修改挂载文件:/etc/fstab,在文件末尾加入以下内容

gfs01:/Main/gluster_storage/storageglusterfsdefaults,_netdev00

测试:

[root@gfs01~]#cd/gluster_storage/storage/
[root@gfs01storage]#timeddif=/dev/zeroof=hellobs=1000Mcount=1
1+0recordsin
1+0recordsout
1048576000bytes(1.0GB)copied,31.1961s,33.6MB/s

real	0m31.211s
user	0m0.001s
sys	0m1.139s

客户端查看:

[root@gfs03~]#tree/gluster_storage/
/gluster_storage/
├──lost+found
├──storage01
│└──hello
└──storage02
└──hello

3directories,2files

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native