volume是brick的组合,并且大部分glusterfs文件系统的操作都在volume上。
glusterfs支持4种基本卷,并可以根据需求对4种基本卷进行组合形成多种扩展卷(得益于glusterfs的模块化堆栈架构设计)。
以下主要展示各类型逻辑卷的功能性,未对性能做测试验证。
1. 分布式卷
分布式卷(Distributed Glusterfs Volume,又称DHT),glusterfs创建volume不指定卷类型时,默认即分布式卷,特点如下:
- 根据hash算法,将多个文件分布到卷中的多个brick server上,类似(不是)raid0,但文件无分片;
- 方便扩展空间,但无冗余保护;
- 由于使用本地文件系统进行存储(brick server 的本地文件系统),存取效率不高;
- 受限于本地文件系统对单文件容量的限制,支持超大型文件系统有问题。
1)创建存储目录(optional)
# 在brick server节点创建存储目录,即brick所在; # 以glusterfs01节点为例,注意各brick server挂载磁盘的目录名的不同 [[email protected] ~]# mkdir -p /brick1/dis_volume
2)创建分布式卷
# 命令:gluster volume create NEW-VOLNAME [transport [tcp | rdma | tcp,rdma]] NEW-BRICK... # 以上命令在任意server节点操作均可,以glusterfs01节点为例; # 演示分布式卷的创建,两个server节点即可,创建名为”distributed-volume”的逻辑卷 [[email protected] ~]# gluster volume create distributed-volume glusterfs01:/brick1/dis_volume glusterfs02:/brick2/dis_volume
3)卷信息/状态
# 命令”gluster volume list”可列出已创建的卷; # 命令”gluster volume info”可不指定具体的卷,即列出所有卷信息; # info中给出除卷名外,还有卷类型,状态,brick组成等信息; # 其中状态为“Created”,需要通过命令启动后才可被挂载使用,在创建成功后的提示信息中有提到”please start the volume to access data” [[email protected] ~]# gluster volume info distributed-volume
# 查看卷状态; # 展示卷中每个brick的状态,以及每个brick服务的监听端口 [[email protected] ~]# gluster volume status distributed-volume
4)启动卷
[[email protected] ~]# gluster volume start distributed-volume
# 再次查看卷信息,状态变为"Started" [[email protected] ~]# gluster volume info distributed-volume
5)client挂载
# 在客户端创建挂载目录 [[email protected] ~]# mkdir /mnt/distributed # 挂载时,可使用任意1台已加入可信存储池并已创建对应卷类型的server节点; # brick以”SERVER:EXPORT”的形式标识 [[email protected] ~]# mount.glusterfs 172.30.200.51:distributed-volume /mnt/distributed/
6)查看挂载情况
# 通过“df -Th”命令可查看被挂载的volume,被挂载的文件系统,已经挂载卷的容量是2个brick容量之和 [[email protected] ~]# df -Th
7)查看brick的监听端口
# server节点上每启动1个brick,即启动1个brick服务,具备相应的服务监听端口,起始端口号是tcp49152 [[email protected] ~]# netstat -tunlp | grep gluster
# 另外,client连接的即brick服务的监听端口 [[email protected] ~]# netstat -nt
8)存储测试
# 在client的挂载目录下创建若干文件 [[email protected] ~]# cd /mnt/distributed/ [[email protected] distributed]# touch distributed{1..4}.txt # glusterfs01节点 [[email protected] ~]# tree /brick1/dis_volume/
# glusterfs02节点 [[email protected] ~]# tree /brick2/dis_volume/
结论:分布式卷将多个文件分布存储在多个brick server,但并无副本。