分布式存储案例

分布式存储案例,第1张

gluster分布式存储总结与实践

1 理论知识

1.1 概念

1.1.1 全局统一命名空间的定义

全局统一命名空间将磁盘和内存资源集成一个单一的虚拟存储池,对上层用户屏蔽了底层的物理硬件。

1.1.2 GlusterFS的定义

GlusterFS是一套可扩展的开源群集文件系统,并能够轻松地为客户提供全局命名空间、分布式前端以及高达数百PB级别的扩展性。

1.1.3 元数据的定义

元数据,是用来描述一个给定的文件或是区块在分布式文件系统中所处的位置。

注:元数据时网络附加存储解决方案在规模化方面的致命弱点,因其所有节点都必须不断与服务器(或集群组)保持联系以延续真个群集的元数据,故增加了额外的开销,致使硬件在等待响应元数据请求过程中而效率低下。

1.2 数据定位技术

Gluster通过其自有的d性Hash算法可计算出文件在群集中每个节点的位置,而无需联系群集内的其他节点,从而降低了追踪元数据的变化而带来额外的开销。

1.2.1 数据访问流程

- 根据输入的文件路径和文件名计算hash值

- 根据hash值在群集中选择子卷(存储服务器),进行文件定位

- 对所选择的子卷进行数据访问

1.2.2 Davies-Meyer算法

Gluster使用Davies-Meyer算法计算文件名的hash值,获得一个32位整数,算法特点如下:

- 非常好的hash分布性

- 高效率的计算

1.3 Gluster的架构

1.3.1 存储服务器(Brick Server)

- 存储服务器主要提供基本的数据存储功能

- 最终通过统一调度策略分布在不同的存储服务器上(通过Glusterfsd来处理数据服务请求)

- 数据以原始格式直接存储于服务器本地文件系统(EXT3/EXT4/XFS/ZFS等)

1.3.2 客户端和存储网关(NFS/Samba)

- 客户端的Glusterfs进程负责数据卷管理、I/O调度、文件定位、数据缓存等功能

- 客户端利用FUSE(File System in User Space)模块将GlusterFS挂载到本地文件系统上

- GlusterFS存储网关提供d性卷管理和NFS/GIFS访问代理功能

1.3.3 节点间互联

GlusterFS支持一下网络互联

- TCP/IP

- InfiniBand RDMA

1.4 Gluster的优点

1.4.1 d性存储

Gluster群集可根据业务需求灵活地增加或缩减数据存储以及增删存储池中的资源,而不会中断系统的运行。

1.4.2 横向扩展

Gluster群集可通过增加存储节点来提升整个系统的容量或性能

1.4.3 高可靠性

Gluster群集通过自动复制与自动修复来保证数据的可靠性(利用EXT3/ZFS等磁盘文件系统日志)

1.5 Cluster的后端部署

1.5.1 兼容性

1)Cluster工作于Linux系统上层,其通过 *** 作系统去解决与硬件的兼容性问题

2)可被部署与任何品牌的Linux系统(主要是RHEL和CentOS)

注:以上使得用户可自由选择硬件

1.5.2 数据存储方式

- 只分布型,模拟了RAID0分布情况,文件只存储于Gluster群集的单个节点,但性能表现优良。

- 分布式副本型,类似于RAID10,文件通过两个节点(镜像节点)同步使得单点故障不影响数据存取。

- 分段模型,执行上接近于标准化区块层RAID0模式,该模式将文件拆分且分布于多个节点上。

1.5.3 跨站点备份

Cluster群集允许不同群集键的多线路跨地域备份。

注:该方案用于避免群集整体故障或数据迁移、异地备份。

1.5.4 跨站点延伸

Cluster群集允许内部节点跨物理站点。

注:跨站点的带宽或延迟可能会影响群集的性能表现

1.6 客户端部署

1.6.1 支持的客户端

Cluster可通过多种不同的协议实现客户端访问,如:

- Gluster客户端

- NFS

- CIFS

- WebDAV

- HTTP

- 其他

注:只有本地的Gluster客户端才正常支持高可用性、大规模的并行文件访问或使用循环域名服务、UCARP(虚拟路由冗余协议的简化版)、CTDB(用于群集存储的Samba项目)相结合的硬件负载群衡器。

1.6.2 客户端高可用原理

- 客户端主动联系群集中的所有节点

- 客户端使用Hash算法计算出自己位于拓扑结构中的位置

- 客户端从所需求的托管节点处接收数据

- 应用程序可通过Gluster分卷获知镜像节点单点故障

1.7 Gluster群集管理工具

- Web GUI

- 命令行工具(管理非常简单便捷)

1.8 卷的类型

卷是块的集合且更多的gluster文件系统的 *** 作发生在卷。Gluster文件系统基于需求支持不同类型的卷。某些擅长卷缩放存储大小,某些擅长提高性能和冗余。

1.8.1 Distributed Glusterfs Volume

分布式卷是Glusterfs的默认卷,当你创建一个卷如果没有指定卷的类型,将使用这个默认的选项去创建分布式卷。

1)特点

- 文件分布在不同的块服务器(文件1可分布在块服务器1或2,但不能两台同时分布,没有冗余)

- 更容易和廉价地扩展卷的大小

2)缺点

- 单点故障会造成数据丢失

- 依赖底层的数据保护

3)创建分布式卷

#gluster volume create test-volume server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4
Creation of test-volume has been successful
Please start the volume to access data

4)显示分布式卷信息

#gluster volume info
Volume Name: test-volumeType: DistributeStatus: Created
Number of Bricks: 4Transport-type: tcpBricks:Brick1: server1:/exp1Brick2: server2:/exp2Brick3: server3:/exp3Brick4: server4:/exp4

1.8.2 Replicated Glusterfs Volume

复制卷将克服分布式卷的数据丢失问题,其用于可靠的数据冗余

1)特点

- 该模式在所有的块服务器被保持一个精确的副本

- 卷的副本数量可由客户创建的时候决定

- 至少由两个块服务器或3个来创建一个卷

- 一个块服务故障仍然可从其他块服务器读取数据

2)创建复制卷

# gluster volume create test-volume replica 2 transport tcp server1:/exp1 server2:/exp2
Creation of test-volume has been successful
Please start the volume to access data

1.8.3 Distributed Replicated Glusterfs Volume

分布式复制卷文件分布在另外一个块的复制集合,该类型用于数据冗余的高可用和存储缩放

1)搭建条件

- 块服务器的数量必须是复制的倍数

- 将按块服务器的排列顺序指定相邻的块服务器成为彼此的复制

例如,8台服务器:

- 当复制副本为2时,按照服务器列表的顺序,服务器1和2作为一个复制,3和4作为一个复制,5和6作为一个复制,7和8作为一个复制

- 当复制副本为4时,按照服务器列表的顺序,服务器1/2/3/4作为一个复制,5/6/7/8作为一个复制

2)创建分布式复制卷

# gluster volume create test-volume replica 2 transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4
Creation of test-volume has been successful
Please start the volume to access data

1.8.4 Striped Glusterfs Volume

条带卷适用于解决大文件高并发下带来的高负载和低性能问题。

1)特点

- 数据被分割成更小块分布到块服务器群中的不同条带区

- 分布减少了负载且更小的文件加速了存取的速度

2)缺点

- 没有数据冗余

3)创建条带卷

格式:

gluster volume create NEW-VOLNAME [stripe COUNT] [transport [tcp | dma | tcp,rdma]] NEW-BRICK...

范例:

# gluster volume create test-volume stripe 2 transport tcp server1:/exp1 server2:/exp2
Creation of test-volume has been successful
Please start the volume to access data

1.8.5 Distributed Striped Glusterfs Volume

1)特点

- 相对于条带卷文件可被分割成更小的块分布到块服务器中的多个块中的不同条带区

2)创建

格式:

gluster volume create NEW-VOLNAME [stripe COUNT] [transport [tcp | rdma | tcp,rdma]] NEW-BRICK...

范例:

# gluster volume create test-volume replica 2 transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4
Creation of test-volume has been successful
Please start the volume to access data

2 实践部分

2.1 环境信息

2.1.1 主机信息

GlusterH0[1-4]:

hostname=GlusterH0[1-4].cmdschool.org

ipaddress=10.168.0.19[2-5]


GlusterGW:

hostname=GlusterGW.cmdschool.org

ipaddress=10.168.0.190

2.1.2 名称解析配置

In GlusterH0[1-3] & GlusterGW :

echo "10.168.0.190 GlusterGW.cmdschool.org" >> /etc/hosts
echo "10.168.0.192 GlusterH01.cmdschool.org" >> /etc/hosts
echo "10.168.0.193 GlusterH02.cmdschool.org" >> /etc/hosts
echo "10.168.0.194 GlusterH03.cmdschool.org" >> /etc/hosts
echo "10.168.0.195 GlusterH04.cmdschool.org" >> /etc/hosts

2.1.3 配置YUM源

In GlusterH0[1-3] & GlusterGW :

yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
curl http://download.gluster.org/pub/gluster/glusterfs/3.7/LATEST/CentOS/glusterfs-epel.repo > /etc/yum.repos.d/glusterfs-epel.repo

2.1.4 关闭防火墙

In GlusterH0[1-3] & GlusterGW :

/etc/init.d/iptables stop
chkconfig iptables off

2.2 配置数据存储根目录

In GlusterH0[1-3] :

2.2.1 新建分区

fdisk /dev/sdb

详细向导如下:

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x089fd1ab.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-26108, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-26108, default 26108): 
Using default value 26108

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

2.2.2 发现并校验

partx /dev/sdb
ls /dev/sdb*

2.2.3 创建文件系统

mkfs.xfs -i size=512 /dev/sdb1

2.2.4 配置挂载

mkdir -p /data/brick1
echo '/dev/sdb1 /data/brick1 xfs defaults 1 2' >> /etc/fstab
mount -a && mount

2.3 配置glusterfs服务端

In GlusterH0[1-3] :

2.3.1 安装yum源

yum install -y glusterfs-server

2.3.2 启动服务

/etc/init.d/glusterd start
chkconfig glusterd on

2.4 配置信任池

In GlusterH01:

gluster peer probe GlusterH02.cmdschool.org
gluster peer probe GlusterH03.cmdschool.org
gluster peer probe GlusterH04.cmdschool.org

显示如成功信息:

peer probe: success.

2.5 配置GlusterFS卷

2.5.1 配置存储位置

In GlusterH0[1-3] :

mkdir /data/brick1/gv0

2.5.2 创建Gluster卷

In GlusterH01 :

gluster volume create gv0 replica 2 transport tcp GlusterH01.cmdschool.org:/data/brick1/gv0 GlusterH02.cmdschool.org:/data/brick1/gv0 GlusterH03.cmdschool.org:/data/brick1/gv0 GlusterH04.cmdschool.org:/data/brick1/gv0

显示如成功信息:

volume create: gv0: success: please start the volume to access data

2.5.3 启动GlusterFS卷

In GlusterH01 :

gluster volume start gv0

显示如成功信息:

volume start: gv0: success

2.5.4 验证卷的信息

In GlusterH01 :

gluster volume info

显示如下:

Type: Distributed-Replicate
Volume ID: 96b06e32-deb5-487a-aa00-afd6624dcb97
Status: Started
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: GlusterH01.cmdschool.org:/data/brick1/gv0
Brick2: GlusterH02.cmdschool.org:/data/brick1/gv0
Brick3: GlusterH03.cmdschool.org:/data/brick1/gv0
Brick4: GlusterH04.cmdschool.org:/data/brick1/gv0
Options Reconfigured:
features.quota-deem-statfs: on
features.inode-quota: on
features.quota: on
performance.readdir-ahead: on

2.6 配置Gluster客户端

In GlusterGW :

2.6.1 安装客户端相关包

yum install -y glusterfs-fuse

2.6.2 手动挂载卷gv0到本地

mount -t glusterfs GlusterH01.cmdschool.org:/gv0 /mnt

2.6.3 自动挂载卷gvo到本地

echo 'GlusterH01.cmdschool.org:/gv0 /mnt glusterfs defaults 0 0' >> /etc/fstab

2.7 测试Gluster卷

2.7.1 写入测试

In GlusterGW :

for i in `seq -w 1 100`; do cp -rp /var/log/messages /mnt/copy-test-$i; done

2.7.2 写入确认

In GlusterGW :

ls -lA /mnt/ | wc -l

In GlusterH0[1-3] :

ls -lA /data/brick1/gv0/

---------------------------------------------------------

官方的参阅文档

--------------

官方主页:

http://www.gluster.org

官方快速安装文档:

http://gluster.readthedocs.io/en/latest/Quick-Start-Guide/Quickstart/

官方安装指南:

http://gluster.readthedocs.io/en/latest/Install-Guide/Overview/

管理员手册:

http://gluster.readthedocs.io/en/latest/Administrator%20Guide/

YUM源地址:

http://download.gluster.org/pub/gluster/

架构:

http://gluster.readthedocs.io/en/latest/Quick-Start-Guide/Architecture/#architecture


非官方参阅文档

--------------

CentOS的配置文档:

https://wiki.centos.org/SpecialInterestGroup/Storage/gluster-Quickstart

系统架构:

http://wenku.baidu.com/link?url=TFOa9AaI4Rw9saYwCk6I3MlB3ynHl7Orb0i7VajyGLGeHgHQI-DXM1wQPH206B8F1syXSB1UVMqR3P3lKWGXGfFDqFsZqDJaIVLoqCD6K23

架构解读:

http://os.51cto.com/art/201110/299072.htm

http://blog.csdn.net/zonelan/article/details/8468383

http://jingyan.baidu.com/article/046a7b3ef65250f9c27fa9d9.html

http://wenku.baidu.com/link?url=ZfKvYzTrs4bc08h_aQOHJpI6w0452rZqLXeySDMee9g1_uyhoVOkq5Jdgo5S0GkilarXm9YC3UOpYzFnQ9eQRDNQdE2G0bfLZKGakGJBErm

实践文章:
http://www.jb51.net/os/RedHat/347181.html

NFS挂载

http://unix.stackexchange.com/questions/102617/having-trouble-exporting-fuse-via-nfs

Windows挂载NFS

http://wenku.baidu.com/link?url=HBPmuCUc--ySFXctE4sybCAt7kLGjc6ilqBs0i6oG6Q0GEW8Hdwlchms6ZqW6arrZ2f3YRCdd6nyC-zI6QHHiGx931Fk6ZgidkzSpq-1mXO

解决Windows挂载Linux NFS只读的方法

https://help.joyent.com/entries/22180102-Mounting-Windows-to-NFS-servers

马哥的博客

http://mp.weixin.qq.com/s?__biz=MzA3OTgyMDcwNg==&mid=2650625872&idx=1&sn=d1953b96d93c0baf4d4a0beabbc2aa8f&scene=1&srcid=0817AReukVf9WsMxeMXacP7N#rd



欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zz/778586.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存