Glusterfs分布复制卷的配置

1. 分布式复制卷

分布式复制卷(Distributed Replicated Glusterfs Volume),是分布式卷与复制卷的组合,兼具两者的功能,特点如下:

  1. 若干brick组成1个复制卷,另外若干brick组成其他复制卷;单个文件在复制卷内数据保持副本,不同文件在不同复制卷之间进行哈希分布;即分布式卷跨复制卷集(replicated sets );
  2. brick server数量是副本数量的倍数,且>=2倍,即最少需要4台brick server,同时组建复制卷集的brick容量相等。

Glusterfs分布复制卷的配置

1)创建分布式复制卷

# 命令:gluster volume create NEW-VOLNAME [replica COUNT] [transport [tcp | rdma | tcp,rdma]] NEW-BRICK...
# 以上命令在任意server节点操作均可,以glusterfs01节点为例;
# 创建名为”distributed-replica-volume”的逻辑卷;
# 必须指定卷类型(默认为分布式卷)与对应的副本数量,brick server数量是副本数量的倍数,且>=2倍;
# 不需要指出分布式卷类型,只要副本数量与brick server数量不等且符合倍数关系,即是分布式复制卷;
# “transport tcp”指定集群通信方式;
# 副本数为2时,有脑裂风险提示,提示采用3副本或仲裁机制,验证环境略过即可
[[email protected] ~]# gluster volume create distributed-replica-volume replica 2 transport tcp \
 glusterfs01:/brick1/dis_repl_volume \
 glusterfs02:/brick2/dis_repl_volume \
 glusterfs03:/brick3/dis_repl_volume \
 glusterfs04:/brick4/dis_repl_volume 

Glusterfs分布复制卷的配置

2)启动卷

# 卷类型:分布式复制卷
# “Number of Bricks”:2副本,2个副本集(replicated sets ),4个brick server
[[email protected] ~]# gluster volume start distributed-replica-volume
[[email protected] ~]# gluster volume info distributed-replica-volume

Glusterfs分布复制卷的配置

3)client挂载

[[email protected] ~]# mkdir /mnt/distributed-replica
[[email protected] ~]# mount.glusterfs 172.30.200.51:distributed-replica-volume /mnt/distributed-replica/

4)查看挂载情况

# 已挂载卷的容量是2个副本集(replicated sets )容量之和
[[email protected] ~]# df -Th

Glusterfs分布复制卷的配置

5)存储测试

# 在client的挂载目录下创建若干文件
[[email protected] ~]# cd /mnt/distributed-replica/
[[email protected] distributed-replica]# touch distributed-replica{1..6}.txt

# 向distributed-replica1.txt文件写入内容
[[email protected] distributed-replica]# echo "this is distributed-replica1.txt" >> distributed-replica1.txt

# glusterfs01节点
[[email protected] ~]# tree /brick1/dis_repl_volume/

Glusterfs分布复制卷的配置

# glusterfs02节点
[[email protected] ~]# tree /brick2/dis_repl_volume/

Glusterfs分布复制卷的配置

# glusterfs03节点
[[email protected] ~]# tree /brick3/dis_repl_volume/
[[email protected] ~]# cat /brick3/dis_repl_volume/distributed-replica1.txt

Glusterfs分布复制卷的配置

# glusterfs04节点
[[email protected] ~]# tree /brick4/dis_repl_volume/
[[email protected] ~]# cat /brick4/dis_repl_volume/distributed-replica1.txt

Glusterfs分布复制卷的配置

结论:分布式复制卷将数据文件分布在多个复制集(replicated sets )中,每个复制集中数据有镜像冗余。