GlusterFS卷类型

gluster管理
1,glusterd:这个服务/进程必须在所有gluster上启动,充当弹性卷管理器,监督gluster进程并协调动态卷操作,比如添加,删除什么之类的。chkconfig glusterd on或echo ‘glusterd’ >> /etc/rc.local 设置开机自启动。

2,peer可信池TSP:默认端口24007,且必须启动glusterd守护进程。gluster peer help
在gluster中,有可信池TSP<通过对等探测服务器来为volume提供brick,各服务器彼此对等>的概念,这个概念其实就是用于定义gluster中的一组节点的术语,只是为了标注一组设备在一组资源池中,不具有任何约束效力。在没有被加入volume之前,peer都是*的,加入之后peer将仅属于由该服务器组成的存储池。同时peer也有集群的概念,即在一台设备上操作,会在其他服务器上自动同步执行相同的操作。像新建,添加啊,等等。

3,volume卷:卷是brick的逻辑集合,其中每个brick都是可信资源池中服务器上的导出目录,在创建卷之前,你需要设置将构成volume的brick。卷的类型:
gluster三种基本类型 分布式卷 复制卷 条带卷
1 distributed分布式:在volume中的brick之间分发文件,不提供冗余。

2 replicated复制:在volume中的brick之间复制文件,用于高可用环境。

3 不再使用的类型:striped条带,distributed striped分布式条带,distributed striped replicated分布式条带化复制,striped replicated条带化复制。

其他类型
distributed replicated分布式复制:通过volume中的复制brick分布文件,用于高可用,高性能<读取表现明显>。

dispersed分散:基于纠删码,为磁盘或服务器故障提供节省空间保护,将原始文件的编码片段存储到每个块中,只需要部分片段即可恢复原始文件,管理员在创建volume时配置可丢失的砖块数量,而不会丢失对数据的访问权限。

distributed dispersed分布式分散:在分散的子卷上分发文件,与分发复制具有相同的优点,但使用分散将数据存储到砖块中。

卷volume:brick的集合,文件系统操作发生在volume之上,gluster根据需求,支持不同类型的volume。

brick:
推荐的数据站点约定:/glufs/exp1 //brick

ACL:gluster支持自定义ACL,允许为不同的用户或组分配不同的权限,以实现安全性访问。

gluster native client:在用户空间中运行的基于FUSE的客户端,也是高并发的推荐模式

卷的介绍和创建
1 分布式卷:Distributed Glusterfs Volume ,默认的glusterfs卷,根据调度算法文件分布在volume中的brick上
GlusterFS卷类型
[[email protected] glufs]# gluster volume create blance_volume 192.168.56.7:/glufs/data1 192.168.56.8:/glufs/data2 force
volume create: blance_volume: success: please start the volume to access data
[[email protected] glufs]# gluster volume start blance_volume
volume start: blance_volume: success
[[email protected] tools]# gluster volume info

Volume Name: test-volume
Type: Distribute
Volume ID: 846d46b7-e2e2-4792-90d2-df7d15132dbd
Status: Started
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: 192.168.56.7:/glufs/data1
Brick2: 192.168.56.8:/glufs/data2

挂载写入文件测试
[[email protected] ~]# mount.glusterfs 192.168.56.7:/blance_volume /mnt
[[email protected] ~]# cd /mnt
[[email protected] mnt]# touch test{1…10}

在gluster服务端查看
[[email protected] glufs]# cd /glufs/data2/
[[email protected] data1]# ls
test1 test2 test4 test5 test8 test9

[[email protected] glufs]# cd /glufs/data2/
[[email protected] data2]# ls
test10 test3 test6 test7

file只能存储在brick1或brick2中,但不能同时存储在两者中
优点:可以轻松方便的缩放卷大小
缺点:不支持数据冗余,brick故障将导致数据完全丢失,并且必须依靠底层硬件来保护数据丢失

2 复制卷 replica 相当于raid1
复制卷:Replicated Glusterfs Volume,该卷文件通过指定的复制个数,分布在复制的多个brick上
GlusterFS卷类型
[[email protected] glufs]# gluster volume create repl-volume replica 2 transport tcp 192.168.56.7:/glufs/rep1/ 192.168.56.8:/glufs/rep2/ force
volume create: repl-volume: success: please start the volume to access data
命令注释:repl-volume 卷名 replica 复制卷类型 2 为复制几份 transport tcp 传输模式tcp 有几个节点复制几份

[[email protected] glufs]# gluster volume start repl-volume
volume start: repl-volume: success

[[email protected] glufs]# gluster volume info

Volume Name: repl-volume
Type: Replicate
Volume ID: 2a7c289d-25ad-4767-abd5-f6e98075b6ab
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: 192.168.56.7:/glufs/rep1
Brick2: 192.168.56.8:/glufs/rep2

挂载写入数据测试
[[email protected] ~]# mount.glusterfs 192.168.56.7:/repl-volume /mnt
[[email protected] ~]# cd /mnt/
[[email protected] mnt]# touch test{1…10}

在gluster服务端查看
[[email protected] glufs]# ls rep1/
test1 test10 test2 test3 test4 test5 test6 test7 test8 test9

[[email protected] glufs]# ls rep2/
test1 test10 test2 test3 test4 test5 test6 test7 test8 test9

优点:数据副本可以根据需求保留在对应的brick中,即使一个brick故障,也可以从其复制的brick访问数据,提升了可靠性和数据冗余

3 条带卷 stripe 相当于raid0
条带卷:Striped Glusterfs Volume,该卷中数据在划分为不同的条带后,存储在brick中。所以大文件将被分为更小的块(相当于卷中的块数)每个块都被存储在一个块中
GlusterFS卷类型
[[email protected] glufs]# gluster volume create raid-volume stripe 2 transport tcp 192.168.56.7:/glufs/raid1/ 192.168.56.8:/glufs/raid2 force
volume create: raid-volume: success: please start the volume to access data

[[email protected] glufs]# gluster volume start raid-volume
volume start: raid-volume: success

[[email protected] glufs]# gluster volume info

Volume Name: raid-volume
Type: Stripe
Volume ID: f410c290-bc96-40d4-af6f-3e2a4b6d3cf4
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: 192.168.56.7:/glufs/raid1
Brick2: 192.168.56.8:/glufs/raid2

挂载写入数据测试
[[email protected] ~]# mount.glusterfs 192.168.56.7:/raid-volume /mnt
[[email protected] ~]# cd /mnt/
[[email protected] mnt]# touch test{1…10}

在gluster服务端查看
[[email protected] glufs]# ls raid1/
test1 test10 test2 test3 test4 test5 test6 test7 test8 test9

[[email protected] glufs]# ls raid2/
test1 test10 test2 test3 test4 test5 test6 test7 test8 test9

4布式卷+复制卷
分布式复制卷:Distributed Replicated Glusterfs Volume ,该卷文件分布在复制的brick集合中。brick的数量必须是副本数的倍数。且按照相邻的brick的顺序,作为彼此的副本
GlusterFS卷类型
两台主机上同时创建目录
[[email protected] glufs]# mkdir exp6 exp7
[[email protected] glufs]# gluster volume create blk-volume replica 2 transport tcp 192.168.56.7:/glufs/exp6 192.168.56.7:/glufs/exp7 192.168.56.8:/glufs/exp6 192.168.56.8:/glufs/exp7 force

Multiple bricks of a replicate volume are present on the same server. This setup is not optimal.
Do you still want to continue creating the volume? (y/n) y
volume create: blk-volume: success: please start the volume to access data

[[email protected] glufs]# gluster volume start blk-volume
volume start: blk-volume: success

[[email protected] glufs]# gluster volume info

Volume Name: blk-volume
Type: Distributed-Replicate
Volume ID: eb2644df-0c5e-4b52-aef3-8c037f282749
Status: Started
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: 192.168.56.7:/glufs/exp6
Brick2: 192.168.56.7:/glufs/exp7
Brick3: 192.168.56.8:/glufs/exp6
Brick4: 192.168.56.8:/glufs/exp7

挂载写入数据测试
[[email protected] ~]# mount -t glusterfs 192.168.56.7:/blk-volume /mnt
[[email protected] mnt]# cd /mnt/
[[email protected] mnt]# touch test{1…10}

在gluster服务端查看
[[email protected] glufs]# ls exp6/
test1 test2 test4 test5 test8 test9
[[email protected] glufs]# ls exp7/
test1 test2 test4 test5 test8 test9

[[email protected] glufs]# ls exp6
test10 test3 test6 test7
[[email protected] glufs]# ls exp7
test10 test3 test6 test7

优点:该卷用于需要由冗余和缩放引起的高可用性数据