GlusterFS简介
开源的分布文件系统
由存储服务器、客户端以及NFS/Samba存储网关组成
无元数据服务器
GFS分布式文件系统
1、NFS/Samba网关接口(存储)
2、存储服务器(工具、管理存储)
3、需要存储的文件(客户端)
模块化堆栈式架构
模块化、维栈式的架构
通过对模块的组合,实现复杂的功能
GLusterFS 模块化维栈式架构
模块化:
类似linux编译安装
很多功能都可以做定制的,通常都是通过软件开发的方式封装为模块,按需使用/不适用
InfiniBand
网络协议,与TCP/IP相比,TcP/IP具有转发丢失数据包的特性,基于此通讯协议可能导致通讯变慢,而rB使用基于信任的、流控制的机制来确保连接完整性,数据包丢失几率小。
RDN纽A:负责数据传输,有一种数据传输协议,功能:为了解决传输中客户端与服务器端数据处理的延迟
POSIX :可移植操作系统接口,主要解决不同操作系统间的移植性
然后再转换为逻辑存储(EXT4 +BRICK)
以上架构模式可以提高GFS的工作效率
Application:客户端或应用程序通过GlusterFSync的挂载点访问数据
VFS: linux系统内核通过
VFS API收到请求并处理
FUSE:VFS将数据递交给FUSE内核文件系统,fuse文件系统则是将数据通过/dev/fuse设备文件递交给了GlusterFS
GlusterFs client ;通过网络将数据传递至远端的GclusterFS Server,并且写入到服务器存储设备上
read ahead :内核文件预读
工作流程(写)
客户端在本地发出读写请求,然后交由vFs的API接受请求,接受请求后会交给FUSE(内核伪文件系统,FUSE可以模拟操作系统,所以可以对文件系统进行转存,转存的设备位置为:/dev/fuse (用于传输的设备-虚拟设备文件)
》交给GFs客户端,client会根据配置文件对数据进行处理,然后再通过TCP/ib/rdma
网络发送到GFs服务端,并且将数据写到服务器存储设备上
基本卷
(1)distribute volume:分布式卷
(2)stripe volume:条带卷
(3)replica volume:复制卷
复合卷
(4)distribute stripe volume:分布式条带卷
(5)distribute replica volume:分布式复制卷
(6)stripe replica volume:条带复制卷
(7) distribute stripe replicavolume:分布式条带复制卷
gige:千兆网/千兆接口
分布式卷(默认):文件通过HASH算法分布到所有 Brick Server 上,这种卷是Glusterf的基础;以文件为单位根据HASH算法散列到不同的 Brick,其实只是扩大了磁盘空间,如果有一块磁盘损坏,数据也将丢失,属于文件级的 RAID 0),不具有容错能力。
条带卷(默认):类似RAIDO,文件被分成数据块并以轮询的方式分布到多个Brick Server上,文件存储以数据块为单位,支持大文件存储,文件越大,读取效率越高。
复制卷(Replica volume):将文件同步到多个Brick 上,使其具备多个文件副本,属于文件级RAID1,具有容错能力。因为数据分散在多个Brick 中,所以读性能得到很大提升,但写性能下降。
分布式条带卷(Distribute stripe volume) : Brick server 数量是条带数(数据块分布的 Brick数量〉的倍数,兼具分布式卷和条带卷的特点。
分布式复制卷(Distribute Replica volume) : Brick server 数量是镜像数(数据副本数量)的倍数,兼具分布式卷和复制卷的特点。
条带复制卷(stripe Replica volume):类似RAID 10,同时具有条带卷和复制卷的特点
分布式条带复制卷(Distribute stripe Replicavolume):三种基本卷的复合卷,通常用于类Map Reduce. 应用
磁盘分区,并挂载
[root@node1 ~]# cd /opt
[root@node1 opt]# vim fdisk.sh
[root@node1 opt]# chmod +x fdisk.sh
[root@node1 opt]# sh -x fdisk.sh
#!/bin/bash
echo "the disks exist list:"
##grep出系统所带磁盘
fdisk -l |grep '磁盘 /dev/sd[a-z]'
echo "=================================================="
PS3="chose which disk you want to create:"
##选择需要创建的磁盘编号
select VAR in `ls /dev/sd*|grep -o 'sd[b-z]'|uniq` quit
do
case $VAR in
sda)
##本地磁盘就退出case语句
fdisk -l /dev/sda
break ;;
sd[b-z])
#create partitions
echo "n ##创建磁盘
p
w" | fdisk /dev/$VAR
#make filesystem
##格式化
mkfs.xfs -i size=512 /dev/${VAR}"1" &> /dev/null
#mount the system
mkdir -p /data/${VAR}"1" &> /dev/null
###永久挂载
echo -e "/dev/${VAR}"1" /data/${VAR}"1" xfs defaults 0 0\n" >> /etc/fstab
###使得挂载生效
mount -a &> /dev/null
break ;;
quit)
break;;
*)
echo "wrong disk,please check again";;
esac
done
所有服务器都做映射
[root@node4 opt]# vim /etc/hosts
上传gfsrepo.zip 至/opt
[root@node1 opt]# unzip gfsrepo.zip
将gfsrepo 软件上传到/opt目录
[root@node1 opt]# cd /etc/yum.repos.d/
[root@node1 yum.repos.d]# mkdir bak
[root@node1 yum.repos.d]# mv CentOS-* bak
[root@node1 yum.repos.d]# vim glfs.repo
[glfs]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1
[root@node1 yum.repos.d]# yum clean all
[root@node1 yum.repos.d]# yum makecache
yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma
systemctl start glusterd.service
systemctl enable glusterd.service
systemctl status glusterd.service
添加节点到存储信任池中(在 node1 节点上操作)
[root@node1 yum.repos.d]# gluster peer probe node1
peer probe: success. Probe on localhost not needed
[root@node1 yum.repos.d]# gluster peer probe node2
peer probe: success.
[root@node1 yum.repos.d]# gluster peer probe node3
peer probe: success.
[root@node1 yum.repos.d]# gluster peer probe node4
peer probe: success.
[root@node1 yum.repos.d]# gluster peer ststus
unrecognized word: ststus (position 1)
[root@node1 yum.repos.d]# gluster peer status
1创建分布式卷
[root@node1 yum.repos.d]# gluster volume create dis-volume node1:/data/sdb1 node2:/data/sdb1 force
volume create: dis-volume: success: please start the volume to access data
[root@node1 yum.repos.d]# gluster volume list
dis-volume
[root@node1 yum.repos.d]# gluster volume start dis-volume
volume start: dis-volume: success
[root@node1 yum.repos.d]# gluster volume info dis-volume
2创建条带卷
[root@node1 yum.repos.d]# gluster volume create stripe-volume stripe 2 node1:/data/sdc1 node2:/data/sdc1 force
volume create: stripe-volume: success: please start the volume to access data
[root@node1 yum.repos.d]# gluster volume start stripe-volume
volume start: stripe-volume: success
[root@node1 yum.repos.d]# gluster volume info stripe-volume
3创建复制卷
[root@node1 yum.repos.d]# gluster volume create rep-volume replica 2 node3:/data/sdb1 node4:/data/sdb1 force
volume create: rep-volume: success: please start the volume to access data
[root@node1 yum.repos.d]# gluster volume start rep-volume
volume start: rep-volume: success
[root@node1 yum.repos.d]# gluster volume info rep-volume
4创建分布式条带卷
[root@node1 yum.repos.d]# gluster volume create dis-stripe stripe 2 node1:/data/sdd1 node2:/data/sdd1 node3:/data/sdd1 node4:/data/sdd1 force
volume create: dis-stripe: success: please start the volume to access data
[root@node1 yum.repos.d]# gluster volume start dis-stripe
volume start: dis-stripe: success
[root@node1 yum.repos.d]# gluster volume info dis-stripe
5创建分布式复制卷
[root@node1 yum.repos.d]# gluster volume create dis-rep replica 2 node1:/data/sde1 node2:/data/sde1 node3:/data/sde1 node4:/data/sde1 force
volume create: dis-rep: success: please start the volume to access data
[root@node1 yum.repos.d]# gluster volume start dis-rep
volume start: dis-rep: success
[root@node1 yum.repos.d]# gluster volume info dis-rep
安装客户端软件
[root@client opt]# unzip gfsrepo.zip
[root@client opt]# cd /etc/yum.repos.d/
[root@client yum.repos.d]# ls
CentOS-Base.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo
CentOS-CR.repo CentOS-fasttrack.repo CentOS-Sources.repo
[root@client yum.repos.d]# mkdir bak
[root@client yum.repos.d]# mv CentOS-* bak
[root@client yum.repos.d]# vim glfs.repo
[glfs]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1
[root@client yum.repos.d]# yum clean all
[root@client yum.repos.d]# yum makecache
[root@client yum.repos.d]# yum -y install glusterfs glusterfs-fuse
创建挂载目录
[root@client yum.repos.d]# mkdir -p /test/{dis,stripe,rep,dis_stripe,dis_rep}
[root@client yum.repos.d]# ls /test
添加映射
[root@client yum.repos.d]# echo "192.168.235.144 node1" >> /etc/hosts
[root@client yum.repos.d]# echo "192.168.235.156 node2" >> /etc/hosts
[root@client yum.repos.d]# echo "192.168.235.166 node3" >> /etc/hosts
[root@client yum.repos.d]# echo "192.168.235.177 node4" >> /etc/hosts
[root@client yum.repos.d]# echo "192.168.235.179 client" >> /etc/hosts
挂载Gluster文件系统
[root@client yum.repos.d]# mount.glusterfs node1:dis-volume /test/dis
[root@client yum.repos.d]# mount.glusterfs node1:stripe-volume /test/stripe
[root@client yum.repos.d]# mount.glusterfs node1:rep-volume /test/rep
[root@client yum.repos.d]# mount.glusterfs node1:dis-stripe /test/dis_stripe
[root@client yum.repos.d]# mount.glusterfs node1:dis-rep /test/dis_rep
[root@client yum.repos.d]# df -hT
测试
1卷中写入文件,客户端操作
root@client test]# cd /opt
[root@client opt]# dd if=/dev/zero of=/opt/demo1.log bs=1M count=20
记录了20+0 的读入
记录了20+0 的写出
20971520字节(21 MB)已复制,0.00725318 秒,2.9 GB/秒
[root@client opt]# dd if=/dev/zero of=/opt/demo2.log bs=1M count=20
记录了20+0 的读入
记录了20+0 的写出
20971520字节(21 MB)已复制,0.0112017 秒,1.9 GB/秒
[root@client opt]# dd if=/dev/zero of=/opt/demo3.log bs=1M count=20
记录了20+0 的读入
记录了20+0 的写出
20971520字节(21 MB)已复制,0.0245634 秒,854 MB/秒
[root@client opt]# dd if=/dev/zero of=/opt/demo4.log bs=1M count=20
记录了20+0 的读入
记录了20+0 的写出
20971520字节(21 MB)已复制,0.0535315 秒,392 MB/秒
[root@client opt]# dd if=/dev/zero of=/opt/demo5.log bs=1M count=20
记录了20+0 的读入
记录了20+0 的写出
20971520字节(21 MB)已复制,0.0685257 秒,306 MB/秒
[root@client opt]# ls -lh
总用量 150M
-rw-r--r--. 1 root root 20M 8月 11 00:45 demo1.log
-rw-r--r--. 1 root root 20M 8月 11 00:45 demo2.log
-rw-r--r--. 1 root root 20M 8月 11 00:45 demo3.log
-rw-r--r--. 1 root root 20M 8月 11 00:45 demo4.log
-rw-r--r--. 1 root root 20M 8月 11 00:45 demo5.log
drwxr-xr-x. 3 root root 8.0K 11月 20 2020 gfsrepo
-rw-r--r--. 1 root root 50M 8月 10 16:57 gfsrepo.zip
drwxr-xr-x. 2 root root 6 10月 31 2018 rh
[root@client opt]# cp demo* /test/dis
[root@client opt]# cp demo* /test/stripe/
[root@client opt]# cp demo* /test/rep/
[root@client opt]# cp demo* /test/dis_stripe/
[root@client opt]# cp demo* /test/dis_rep/
2查看分布式文件
[root@node1 yum.repos.d]# ls -lh /data/sdb1
破坏性测试
挂起 node2 节点或者关闭glusterd服务来模拟故障
[root@client test]# ls dis
demo1.log demo2.log demo3.log demo4.log
[root@client test]# ls rep/
demo1.log demo2.log demo3.log demo4.log demo5.log
[root@client test]# ls -lh rep/