GFS分布式文件系统

GlusterFS概述

GlusterFS简介

  • 开源的分布式文件系统
  • 由存储服务器、客户端以及NFS/Samba存储网关组成
  • 无元数据服务器

GlusterFS特点

  • 扩展性和高性能
  • 高可用性
  • 全局统一命名空间
  • 弹性卷管理
  • 基于标准协议

GlusterFS术语

  • Brick
  • Volume
  • FUSE
  • VFS
  • Glusterd

模块化堆栈式架构

模块化、堆栈式的架构
通过对模块的组合,实现复杂的功能

  • GlusterFS工作原理
  • GlusterFS工作流程

GlusterFS工作原理

GlusterFS工作流程

在这里插入图片描述

弹性HASH算法

  • 通过HASH算法得到一个32位的整数
  • 划分为N个连续的子空间,每个空间对应一个Brick
  • 弹性HASH算法的优点
  1. 保证数据平均分布在每一个Brick中
  2. 解决了对元数据服务器的依赖,进而解决了单点故障以及访问瓶颈

GlusterFS的卷类型

  • 分布式卷
  • 条带卷
  • 复制卷
  • 分布式条带卷
  • 分布式复制卷
  • 条带复制卷
  • 分布式条带复制卷

分布式卷分布式卷

  • 没有对文件进行分块处理
  • 通过扩展文件属性保存HASH值
  • 支持的底层文件系统有EXT3、EXT4、ZFS、XFS等
    在这里插入图片描述

分布式卷的特点

  • 文件分布在不同的服务器,不具备冗余性
  • 更容易和廉价地扩展卷的大小
  • 单点故障会造成数据丢失
  • 依赖底层的数据保护

条带卷

  • 根据偏移量将文件分成N块(N个条带节点),轮询的
  • 存储在每个Brick Server节点
  • 存储大文件时,性能尤为突出
  • 不具备冗余性,类似Raid0
    在这里插入图片描述

条带卷特点

  • 数据被分割成更小块分布到块服务器群中的不同条带区
  • 分布减少了负载且更小的文件加速了存取的速度
  • 没有数据冗余

复制卷

  • 同一文件保存一份或多分副本
  • 因为要保存副本,所以磁盘利用率较低
  • 若多个节点上的存储空间不一致,将按照木桶效应取最低节点的容量作为该卷的总容量
    在这里插入图片描述

复制卷特点

  • 卷中所有的服务器均保存一个完整的副本
  • 卷的副本数量可由客户创建的时候决定
  • 至少有两个块服务器或更多服务器具备冗余性

分布式条带卷

  • 兼顾分布式卷和条带卷的功能
  • 主要用于大文件访问处理
  • 至少最少需要4台服务器
    在这里插入图片描述

分布式复制卷

  • 兼顾分布式卷和复制卷的功能
  • 用于需要冗余的情况
    在这里插入图片描述

部署群集环境

创建分布式卷

实验环境:
在这里插入图片描述
服务器1和2都进行如下设置:
1、设置修改主机名

[root@node1 ~]# hostnamectl set-hostname node1

2、添加俩快磁盘,并创建磁盘分区

[root@node1 ~]# fdisk /dev/sdb			#输入n为创建新的磁盘分区

3、格式化磁盘

[root@node1 ~]# mkfs.ext4 /dev/sdb1

4、创建挂载目录

[root@node1 ~]# mkdir /opt/a1-dis

5、挂载磁盘

[root@node1 ~]# mount /dev/sdb1 /opt/a1-dis

6、关闭防火墙和selinux

[root@node1 ~]# systemctl stop firewalld
[root@node1 ~]# setenforce 0

7、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2

8、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

9、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

10、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

11、启动glusterd

[root@node1 ~]# systemctl start glusterd

12、设置时间同步

[root@node1 ~]# ntpdate ntp1.aliyun.com

13、添加入存储信任池只要在一台主机上添加其他节点即可

[root@node1 ~]# gluster peer probe node2

14、查看所有节点

[root@node1 ~]# gluster peer status

在俩台服务器的任意一台创建分布式卷
1、创建分布式卷

[root@server1 ~]# gluster   volume  create  a1-dis node1:/opt/a1-dis node2:/opt/a1-dis  force
a1-dis:分布式卷名称
node1:主机名
/opt/a1-dis:挂载磁盘目录

2、查看创建情况

[root@node1 ~]# gluster volume info a1-dis

3、启动分布式卷

[root@node1 ~]# gluster volume start a1-dist

4、查看状态

[root@node1 ~]# gluster volume status a1-dis

测试
客户机:
1、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2

2、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

3、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

4、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

5、启动glusterd

[root@node1 ~]# systemctl start glusterd

6、客户机上创建挂载目录

[root@client ~]# mkdir /opt/a1-dis

7、客户机挂载分布式卷

[root@client ~]# mount.glusterfs node1:a1-dis /opt/a1-dis/

8、创建多个文件查看文件是否出现在不同服务器上

[root@client ~]# dd if=/dev/zero of=/opt/a1-dis/a1 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a1-dis/a2 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a1-dis/a3 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a1-dis/a4 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a1-dis/a5 bs=1M count=40
[root@client ~]# cd /opt/a1-dis/
[root@client a1-dis]# ll
总用量 204804
-rw-r--r-- 1 root root 41943040 1116 23:48 a1
-rw-r--r-- 1 root root 41943040 1116 23:49 a2
-rw-r--r-- 1 root root 41943040 1116 23:49 a3
-rw-r--r-- 1 root root 41943040 1116 23:49 a4
-rw-r--r-- 1 root root 41943040 1116 23:49 a5
drwx------ 2 root root     4096 1116 22:58 lost+found

9、去俩台服务器上查看
服务器1:

[root@node1 a1-dis]# ll
总用量 163856
-rw-r--r-- 2 root root 41943040 1116 23:48 a1
-rw-r--r-- 2 root root 41943040 1116 23:49 a3
-rw-r--r-- 2 root root 41943040 1116 23:49 a4
-rw-r--r-- 2 root root 41943040 1116 23:49 a5
drwx------ 2 root root    16384 1116 22:58 lost+found

服务器2:

[root@node2 a1-dis]# ll
总用量 40976
-rw-r--r-- 2 root root 41943040 1116 23:49 a2
drwx------ 2 root root    16384 1116 22:58 lost+found

10、由于分布式卷不具备冗余性,单点故障容易丢失数据
服务器2关闭
11、在客户机上查看现象

[root@client a1-dis]# ll
总用量 163844
-rw-r--r-- 1 root root 41943040 1116 23:48 a1
-rw-r--r-- 1 root root 41943040 1116 23:49 a3
-rw-r--r-- 1 root root 41943040 1116 23:49 a4
-rw-r--r-- 1 root root 41943040 1116 23:49 a5
drwx------ 2 root root     4096 1116 22:58 lost+found

发现发现存放在服务器2上的数据消失了

创建条带卷

实验环境:
在这里插入图片描述
服务器1和2都进行如下设置:
1、设置修改主机名

[root@node1 ~]# hostnamectl set-hostname node1

2、添加俩快磁盘,并创建磁盘分区

[root@node1 ~]# fdisk /dev/sdc			#输入n为创建新的磁盘分区

3、格式化磁盘

[root@node1 ~]# mkfs.ext4 /dev/sdc1

4、创建挂载目录

[root@node1 ~]# mkdir /opt/a2-strip

5、挂载磁盘

[root@node1 ~]# mount /dev/sdc1 /opt/a2-strip

6、关闭防火墙和selinux

[root@node1 ~]# systemctl stop firewalld
[root@node1 ~]# setenforce 0

7、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2

8、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

9、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

10、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

11、启动glusterd

[root@node1 ~]# systemctl start glusterd

12、设置时间同步

[root@node1 ~]# ntpdate ntp1.aliyun.com

13、添加入存储信任池只要在一台主机上添加其他节点即可

[root@node1 ~]# gluster peer probe node2

14、查看所有节点

[root@node1 ~]# gluster peer status

在俩台服务器的任意一台创建条带卷
1、创建条带卷

[root@node1 ~]# gluster volume create a2-strip stripe 2  transport tcp node1:/opt/a2-strip node2:/opt/a2-strip  force
a2-strip:条带卷名称
transport tcp:TCP协议
strip 2 :使用俩快磁盘
node1:主机名称
/opt/a2-strip:挂载磁盘目录

2、查看创建情况

[root@node1 ~]# gluster volume info a2-strip

3、启动分布式卷

[root@node1 ~]# gluster volume start a2-strip

4、查看状态

[root@node1 ~]# gluster volume status a2-strip

测试
客户机:
1、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2

2、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

3、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

4、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

5、启动glusterd

[root@node1 ~]# systemctl start glusterd

6、客户机上创建挂载目录

[root@client ~]# mkdir /opt/a2-strip

7、客户机挂载分布式卷

[root@client ~]# mount.glusterfs node1:a1-dis /opt/a2-strip/
8、创建多个文件查看文件是否出现在不同服务器上
[root@client ~]# dd if=/dev/zero of=/opt/a2-strip/a1 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a2-strip/a2 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a2-strip/a3 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a2-strip/a4 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a2-strip/a5 bs=1M count=40
[root@client ~]# cd /opt/a1-dis/
[root@client a2-strip]# ll
总用量 204804
-rw-r--r-- 1 root root 41943040 1117 00:22 a1
-rw-r--r-- 1 root root 41943040 1117 00:22 a2
-rw-r--r-- 1 root root 41943040 1117 00:23 a3
-rw-r--r-- 1 root root 41943040 1117 00:23 a4
-rw-r--r-- 1 root root 41943040 1117 00:23 a5
drwx------ 2 root root     4096 1117 00:09 lost+found

9、去俩台服务器上查看
服务器1:

[root@node1 a2-strip]# ls -lh
总用量 101M
-rw-r--r-- 2 root root 20M 1117 00:22 a1
-rw-r--r-- 2 root root 20M 1117 00:22 a2
-rw-r--r-- 2 root root 20M 1117 00:23 a3
-rw-r--r-- 2 root root 20M 1117 00:23 a4
-rw-r--r-- 2 root root 20M 1117 00:23 a5
drwx------ 2 root root 16K 1117 00:09 lost+found

服务器2:

[root@node2 a2-strip]# ls -lh
总用量 101M
-rw-r--r-- 2 root root 20M 1117 00:22 a1
-rw-r--r-- 2 root root 20M 1117 00:22 a2
-rw-r--r-- 2 root root 20M 1117 00:23 a3
-rw-r--r-- 2 root root 20M 1117 00:23 a4
-rw-r--r-- 2 root root 20M 1117 00:23 a5
drwx------ 2 root root 16K 1117 00:09 lost+found

10、由于条带卷不具备冗余性,单点故障会丢失一半数据
服务器2关闭
11、在客户机上查看现象

[root@client a2-strip]# ll
总用量 0

客户机上所有数据消失
服务器1:

[root@node1 a2-strip]# ls -lh
总用量 101M
-rw-r--r-- 2 root root 20M 1117 00:22 a1
-rw-r--r-- 2 root root 20M 1117 00:22 a2
-rw-r--r-- 2 root root 20M 1117 00:23 a3
-rw-r--r-- 2 root root 20M 1117 00:23 a4
-rw-r--r-- 2 root root 20M 1117 00:23 a5
drwx------ 2 root root 16K 1117 00:09 lost+found

还保留一半数据

创建复制卷

实验环境:
在这里插入图片描述
服务器1和2都进行如下设置:
1、设置修改主机名

[root@node1 ~]# hostnamectl set-hostname node1

2、添加俩快磁盘,并创建磁盘分区

[root@node1 ~]# fdisk /dev/sdd			#输入n为创建新的磁盘分区

3、格式化磁盘

[root@node1 ~]# mkfs.ext4 /dev/sdd1

4、创建挂载目录

[root@node1 ~]# mkdir /opt/a3-rep

5、挂载磁盘

[root@node1 ~]# mount /dev/sdd1 /opt/a3-rep

6、关闭防火墙和selinux

[root@node1 ~]# systemctl stop firewalld
[root@node1 ~]# setenforce 0

7、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2

8、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

9、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

10、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

11、启动glusterd

[root@node1 ~]# systemctl start glusterd

12、设置时间同步

[root@node1 ~]# ntpdate ntp1.aliyun.com

13、添加入存储信任池只要在一台主机上添加其他节点即可

[root@node1 ~]# gluster peer probe node2

14、查看所有节点

[root@node1 ~]# gluster peer status

在俩台服务器的任意一台创建分布式卷
1、创建分布式卷

[root@server1 ~]# gluster volume create a3-rep replica 2 transport tcp node1:/opt/a3-rep node2:/opt/a3-rep  force
a3-rep:复制卷名称
stripe 2:使用俩快磁盘
server1:主机名称
/opt/a3-rep :挂载磁盘(如:/dev/sda)

2、查看创建情况

[root@node1 ~]# gluster volume info a3-rep

3、启动分布式卷

[root@node1 ~]# gluster volume start a3-rep

4、查看状态

[root@node1 ~]# gluster volume status a3-rep

测试
客户机:
1、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2

2、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

3、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

4、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

5、启动glusterd

[root@node1 ~]# systemctl start glusterd

6、客户机上创建挂载目录

[root@client ~]# mkdir /opt/a1-dis

7、客户机挂载分布式卷

[root@client ~]# mount.glusterfs node1:a3-rep /opt/a3-rep/

8、创建多个文件查看文件是否出现在不同服务器上

[root@client ~]# dd if=/dev/zero of=/opt/a3-rep/a1 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a3-rep/a2 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a3-rep/a3 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a3-rep/a5 bs=1M count=40
[root@client ~]# cd /opt/a3-rep/
[root@client a3-rep]# ll
总用量 204804
-rw-r--r-- 1 root root 41943040 1117 00:43 a1
-rw-r--r-- 1 root root 41943040 1117 00:43 a2
-rw-r--r-- 1 root root 41943040 1117 00:43 a3
-rw-r--r-- 1 root root 41943040 1117 00:43 a4
-rw-r--r-- 1 root root 41943040 1117 00:43 a5
drwx------ 2 root root     4096 1117 00:40 lost+found
总用量 204804

9、去俩台服务器上查看
服务器1:

[root@node1 a3-rep]# ls -lh
总用量 201M
-rw-r--r-- 2 root root 40M 1117 00:43 a1
-rw-r--r-- 2 root root 40M 1117 00:43 a2
-rw-r--r-- 2 root root 40M 1117 00:43 a3
-rw-r--r-- 2 root root 40M 1117 00:43 a4
-rw-r--r-- 2 root root 40M 1117 00:43 a5
drwx------ 2 root root 16K 1117 00:40 lost+found
-rw-r--r-- 2 root root 41943040 1116 23:48 a1

服务器2:

[root@node2 a3-rep]# ll
总用量 204836
-rw-r--r-- 2 root root 41943040 1117 00:43 a1
-rw-r--r-- 2 root root 41943040 1117 00:43 a2
-rw-r--r-- 2 root root 41943040 1117 00:43 a3
-rw-r--r-- 2 root root 41943040 1117 00:43 a4
-rw-r--r-- 2 root root 41943040 1117 00:43 a5
drwx------ 2 root root    16384 1117 00:40 lost+found

10、由于分布式卷不具备冗余性,单点故障容易丢失数据
服务器2关闭
11、在客户机上查看现象

[root@client a3-rep]# ll
总用量 204804
-rw-r--r-- 1 root root 41943040 1117 00:43 a1
-rw-r--r-- 1 root root 41943040 1117 00:43 a2
-rw-r--r-- 1 root root 41943040 1117 00:43 a3
-rw-r--r-- 1 root root 41943040 1117 00:43 a4
-rw-r--r-- 1 root root 41943040 1117 00:43 a5
drwx------ 2 root root     4096 1117 00:40 lost+found

客户机和服务器1上所有数据都在

创建分布式条带卷

实验环境:
在这里插入图片描述
4台服务器都进行如下设置:
1、设置修改主机名

[root@node1 ~]# hostnamectl set-hostname node1

2、添加俩快磁盘,并创建磁盘分区

[root@node1 ~]# fdisk /dev/sde			#输入n为创建新的磁盘分区

3、格式化磁盘

[root@node1 ~]# mkfs.ext4 /dev/sde1

4、创建挂载目录

[root@node1 ~]# mkdir /opt/a4-fb

5、挂载磁盘

[root@node1 ~]# mount /dev/sde1 /opt/a4-fb

6、关闭防火墙和selinux

[root@node1 ~]# systemctl stop firewalld
[root@node1 ~]# setenforce 0

7、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2
20.0.0.30   node3
20.0.0.40   node4

8、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

9、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

10、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

11、启动glusterd

[root@node1 ~]# systemctl start glusterd

12、设置时间同步

[root@node1 ~]# ntpdate ntp1.aliyun.com

13、添加入存储信任池只要在一台主机上添加其他节点即可

[root@node1 ~]# gluster peer probe node2
[root@node1 ~]# gluster peer probe node3
[root@node1 ~]# gluster peer probe node4

14、查看所有节点

[root@node1 ~]# gluster peer status

在四台服务器的任意一台创建分布式分布式卷
1、创建分布式分布式卷

[root@node1 ~]# gluster volume create a4-fb stripe 2 transport tcp node1:/opt/a4-fb node2:/opt/a4-fb  node3:/opt/a4-fb node4:/opt/a4-fb force
a4-fb:分布式条带卷名称
transport tcp:TCP协议
stripe 2:使用俩快磁盘
node1:主机名称
/opt/a4-fb:挂载磁盘

2、查看创建情况

[root@node1 ~]# gluster volume info a4-fb

3、启动分布式卷

[root@node1 ~]# gluster volume start a4-fb

4、查看状态

[root@node1 ~]# gluster volume status a4-fb

测试
客户机:
1、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2
20.0.0.30   node3
20.0.0.40   node4

2、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

3、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

4、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

5、启动glusterd

[root@node1 ~]# systemctl start glusterd

6、客户机上创建挂载目录

[root@client ~]# mkdir /opt/a4-fb

7、客户机挂载分布式卷

[root@client ~]# mount.glusterfs node1:a4-fb  /opt/a4-fb/

8、创建多个文件查看文件是否出现在不同服务器上

[root@client ~]# dd if=/dev/zero of=/opt/a4-fb/a1 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a4-fb/a2 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a4-fb/a3 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a4-fb/a5 bs=1M count=40
[root@client a4-fb]# ls -lh
总用量 201M
-rw-r--r-- 1 root root  40M 1117 09:05 a1
-rw-r--r-- 1 root root  40M 1117 09:06 a2
-rw-r--r-- 1 root root  40M 1117 09:06 a3
-rw-r--r-- 1 root root  40M 1117 09:06 a4
-rw-r--r-- 1 root root  40M 1117 09:06 a5
drwx------ 2 root root 4.0K 1117 09:00 lost+found

9、去四台服务器上查看
服务器1:

[root@node1 a4-fb]# ls -lh
总用量 81M
-rw-r--r-- 2 root root 20M 1117 09:05 a1
-rw-r--r-- 2 root root 20M 1117 09:06 a3
-rw-r--r-- 2 root root 20M 1117 09:06 a4
-rw-r--r-- 2 root root 20M 1117 09:06 a5
drwx------ 2 root root 16K 1117 09:00 lost+found

服务器2:

[root@node2 a4-fb]# ls -lh
总用量 81M
-rw-r--r-- 2 root root 20M 1117 09:05 a1
-rw-r--r-- 2 root root 20M 1117 09:06 a3
-rw-r--r-- 2 root root 20M 1117 09:06 a4
-rw-r--r-- 2 root root 20M 1117 09:06 a5
drwx------ 2 root root 16K 1117 09:00 lost+found

服务器3:

[root@node3 a4-fb]# ls -lh
总用量 21M
-rw-r--r-- 2 root root 20M 1117 09:06 a2
drwx------ 2 root root 16K 1117 09:00 lost+found

服务器4:

[root@node4 a4-fb]# ls -lh
总用量 21M
-rw-r--r-- 2 root root 20M 1117 09:06 a2
drwx------ 2 root root 16K 1117 09:00 lost+found

10、由于分布式条带卷不具备冗余性,单点故障容易丢失数据
服务器2关闭
11、在客户机上查看现象

[root@client a4-fb]# ls -lh
总用量 41M
-rw-r--r-- 1 root root  40M 1117 09:06 a2
drwx------ 2 root root 4.0K 1117 09:00 lost+found

12、在服务器上查看
服务器1:

[root@node1 a4-fb]# ls -lh
总用量 81M
-rw-r--r-- 2 root root 20M 1117 09:05 a1
-rw-r--r-- 2 root root 20M 1117 09:06 a3
-rw-r--r-- 2 root root 20M 1117 09:06 a4
-rw-r--r-- 2 root root 20M 1117 09:06 a5
drwx------ 2 root root 16K 1117 09:00 lost+found

服务器3:

[root@node3 a4-fb]# ls -lh
总用量 21M
-rw-r--r-- 2 root root 20M 1117 09:06 a2
drwx------ 2 root root 16K 1117 09:00 lost+found

服务器4:

[root@node4 a4-fb]# ls -lh
总用量 21M
-rw-r--r-- 2 root root 20M 1117 09:06 a2
drwx------ 2 root root 16K 1117 09:00 lost+found

单点故障对数据没有影响

创建分布式复制卷

实验环境:
在这里插入图片描述四台服务器都进行如下设置:
1、设置修改主机名

[root@node1 ~]# hostnamectl set-hostname node1

2、添加俩快磁盘,并创建磁盘分区

[root@node1 ~]# fdisk /dev/sdf   #输入n为创建新的磁盘分区

3、格式化磁盘

[root@node1 ~]# mkfs.ext4 /def/sdf1

4、创建挂载目录

[root@node1 ~]# mkdir /opt/a5-fx

5、挂载磁盘

[root@node1 ~]# mount /dev/sdf1 /opt/a5-fx

6、关闭防火墙和selinux

[root@node1 ~]# systemctl stop firewalld
[root@node1 ~]# setenforce 0

7、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2
20.0.0.30   node4
20.0.0.40   node4

8、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

9、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

10、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

11、启动glusterd

[root@node1 ~]# systemctl start glusterd

12、设置时间同步

[root@node1 ~]# ntpdate ntp1.aliyun.com

13、添加入存储信任池只要在一台主机上添加其他节点即可

[root@node1 ~]# gluster peer probe node2
[root@node1 ~]# gluster peer probe node3
[root@node1 ~]# gluster peer probe node4

14、查看所有节点

[root@node1 ~]# gluster peer status

在四台服务器的任意一台创建分布式卷
1、创建分布式卷

[root@server1 ~]# gluster volume create a5-fx replica 2 transport tcp node1:/opt/a5-fx       node2:/opt/a5-fx  node3:/opt/a5-fx node4:/opt/a5-fx force
a4-fx :条带卷名称
transport tcp:TCP协议
replica 2:使用俩快磁盘
node1:主机名称
/opt/a5-fx:挂载磁盘

2、查看创建情况

[root@node1 ~]# gluster volume info a5-fx

3、启动分布式卷

[root@node1 ~]# gluster volume start a5-fx

4、查看状态

[root@node1 ~]# gluster volume status a5-fx

测试
客户机:
1、设置映射

[root@node1 ~]# vim /etc/hosts
20.0.0.10   node1
20.0.0.20   node2
20.0.0.30   node3
20.0.0.40   node4

2、上传GLFS源到opt目录

[root@node1 opt]# ll
drwxr-xr-x  3 root root  gfsrepo

3、创建GLFS源文件

[root@node1 ~]# vim /etc/yum.repos.d/GLFS.repo
[GLFS]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1

4、安装工具包

[root@node1 ~]# yum -y install glusterfs glusterfs-server gluster-fuse glusterfs-rdma

5、启动glusterd

[root@node1 ~]# systemctl start glusterd

6、客户机上创建挂载目录

[root@client ~]# mkdir /opt/a5-fx

7、客户机挂载分布式卷

[root@client ~]# mount.glusterfs node1:a5-fx /opt/a5-fx/

8、创建多个文件查看文件是否出现在不同服务器上

[root@client ~]# dd if=/dev/zero of=/opt/a5-fx/a1 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a5-fx/a2 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a5-fx/a3 bs=1M count=40
[root@client ~]# dd if=/dev/zero of=/opt/a5-fx/a5 bs=1M count=40

[root@client a5-fx]# ls -lh
总用量 161M
-rw-r--r-- 1 root root  40M 1117 09:42 a1
-rw-r--r-- 1 root root  40M 1117 09:42 a2
-rw-r--r-- 1 root root  40M 1117 09:42 a3
-rw-r--r-- 1 root root  40M 1117 09:42 a4
drwx------ 2 root root 4.0K 1117 09:25 lost+found

9、去四台服务器上查看
服务器1:

[root@node1 a5-fx]# ls -lh
总用量 121M
-rw-r--r-- 2 root root 40M 1117 09:42 a1
-rw-r--r-- 2 root root 40M 1117 09:42 a3
-rw-r--r-- 2 root root 40M 1117 09:42 a4
drwx------ 2 root root 16K 1117 09:25 lost+found

服务器2:

[root@node2 a5-fx]# ls -lh
总用量 121M
-rw-r--r-- 2 root root 40M 1117 09:42 a1
-rw-r--r-- 2 root root 40M 1117 09:42 a3
-rw-r--r-- 2 root root 40M 1117 09:42 a4
drwx------ 2 root root 16K 1117 09:25 lost+found

服务器3:

[root@node3 a5-fx]# ls -lh
总用量 41M
-rw-r--r-- 2 root root 40M 1117 09:42 a2
drwx------ 2 root root 16K 1117 09:25 lost+found

服务器4:

[root@node4 a5-fx]# ls -lh
总用量 41M
-rw-r--r-- 2 root root 40M 1117 09:42 a2
drwx------ 2 root root 16K 1117 09:25 lost+found
分布式复制卷具有备冗余性。所以单点故障不会影响数据丢失

设置访问控制

设置拒绝20.0.0.50访问

[root@server1 ~]# gluster volume set a5-fx  auth.reject 20.0.0.50
设置允许20.0.0.50访问
[root@server1 ~]# gluster volume set a5-fx  auth.allow 20.0.0.50
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值