GlusterFS分布式文件系统群集
GlusterFS概述
1.1:GlusterFS简介
GlusterFS是Scale-Out存储解决方案Gluster的核心,它是一个开源的分布式文件系统,具有强大的横向扩展能力,通过扩展能够支持数PB存储容量和处理数千客户端。GlusterFS借助TCP/IP或InfiniBandRDMA网络将物理分布的存储资源聚集在一起,使用单一全局命名空间来管理数据,GlusterFS 基于可堆叠的用户空间以及无元数据服务器的分布式存储设计,可为各种不同的数据负载提供优异的性能。
GlusterFS 主要由存储服务器(Brick Server)、客户端及 NFS/Samba 存储网关(可选,根据需要选择使用)组成
GlusterFS 架构中最大的设计特点是没有元数据服务器组件,这有助于提升整个系统的性能、可靠性和稳定性。传统的分布式文件系统大多通过元服务器来存储元数据,元数据包含存储节点上的目录信息、目录结构等。这样的设计在浏览目录时效率非常高,但是也存在一些缺陷,例如单点故障。一旦元数据服务器出现故障,即使节点具备再高的冗余性,整个存储系统也将崩溃。而 GlusterFS 分布式文件系统是基于无元服务器的设计,数据横向扩展能力强,具备较高的可靠性及存储效率。GlusterFS 支持 TCP/IP 和 InfiniBandRDMA 高速网络互联,客户端可通过原生 GlusterFS 协议访问数据,其他没有运行 GlusterFS 客户端的终端可利用 NFS/CIFS 标准协议通过存储网关访问数据。
1.2:Glusterfs特点
1:扩展性和高性能
GlusterFS利用双重特性来提供几TB至数PB的高扩展存储解决方案。
Scale-Out架构允许通过简单地增加资源来提高存储容量和性能,磁盘、计算和I/O资源都可以独立增加,支持10GbE和InfiniBand等高速网络互联。
Gluster弹性哈希(ElasticHash)解决了GlusterFS对元数据服务器的依赖,GlusterFS 采用弹性哈希算法在存储池中定位数据,放弃了传统的通过元数据服务器定位数据。GlusterFS 中可以智能地定位任意数据分片(将数据分片存储在不同节点上),不需要查看索引或者向元数据服务器查询。这种设计机制实现了存储的横向扩展,消除了单点故障和性能瓶颈,真正实现了并行化数据访问。
2:高可用性
GlusterFS可以对文件进行自动复制,如镜像或多次复制,从而确保数据总是可以访问,甚至是在硬件故障的情况下也能正常访问。自我修复功能能够把数据恢复到正确的状态,而且修复是以增量的方式在后台执行,几乎不会产生性能负载。GlusterFS没有设计自己的私有数据文件格式,而是采用操作系统中主流标准的磁盘文件系统(如EXT3、ZFS)来存储文件,因此数据可以使用各种标准工具进行复制和访问。
3:弹性卷管理
数据储存在逻辑卷中,逻辑卷可以从虚拟化的物理存储池进行独立逻辑划分而得到。存储服务器可以在线进行增加和移除,不会导致应用中断。逻辑卷可以在所有配置服务器中增长和缩减,可以在不同服务器迁移进行容量均衡,或者增加和移除系统,这些操作都可在线进行。文件系统配置更改也可以实时在线进行并应用,从而可以适应工作负载条件变化或在线性能调优。
4:基于标准协议。Gluster 存储服务支持 NFS、CIFS、HTTP、FTP、SMB 及 Gluster原生协议,完全与 POSIX 标准兼容。现有应用程序不需要做任何修改就可以对Gluster 中的数据进行访问,也可以使用专用 API 进行访问(效率更高),这在公有云环境中部署 Gluster 时非常有用,Gluster 对云服务提供商专用 API 进行抽象,然后提供标准 POSIX 接口。
5:全局统一命名空间
全局统一命名空间将所有的存储资源聚集成一个单一的虚拟存储池,对用户和应用屏蔽了物理存储信息。存储可以根据生产环境中的需要进行弹性扩展或收缩,在多节点场景中,全局同意明明还可以给予不同节点做负载均衡,大大提高存取效率。
1.3:术语简介
GlusterFS:是一个开源的分布式文件系统。
Brick(存储块):指可信主机池中由主机提供的用于物理存储的专用分区,是GlusterFS 中的基本存储单元,同时也是可信存储池中服务器上对外提供的存储目录。存储目录的格式由服务器和目录的绝对路径构成,表示方法为 SERVER:EXPORT,如 192.168.1.4:/ data/mydir/。
Volume(逻辑卷):一个逻辑卷是一组 Brick 的集合。卷是数据存储的逻辑设备,类似于 LVM 中的逻辑卷。大部分 Gluster 管理操作是在卷上进行的。
FUSE(Filesystem inUserspace):是一个内核模块,允许用户创建自己的文件系统,无须修改内核代码。
VFS:内核空间对用户空间提供的访问磁盘的接口。
Glusterd(后台管理进程):在存储群集中的每个节点上都要运行。
二:GFS的工作原理
(1)客户端或应用程序通过GFS的挂载点访问数据
(2)Linux系统内核通过VFS API收到请求并处理
(3)VFS将数据递交给FUSE内核文件系统,并向系统注册一个实际的文件系统FUSE,而FUSE文件系统则是将数据通过/dev。Fuse设备文件递交给了GFS的client段。可以将FUSE文件系统理解为一个代理。
(4)GFS client收到数据后,client根据配置文件对数据进行处理
(5)经过GFS client处理后,通过网络将数据传递至远端的GFS Server,并且将数据写入服务器存储设备。
2.2:弹性HASH算法
GlusterFS目前使用Davies-Meyer算法计算文件名hash值,获得一个32位整数。Davies-Meyer算法具有非常好的hash分布性,计算效率很高,假设逻辑卷中的存储单元Brick有N个,则32位整数空间被平均划分为N个连续子空间,每个空间分别映射到一个存储单元Brick,计算得到的32位hash值就会被投射到一个存储单元Brick。
弹性 HASH 算法的优点表现如下:
保证数据平均分布在每个 Brick 中。
解决了对元数据服务器的依赖,进而解决了单点故障及访问瓶颈。
现在假设创建了一个包含四个 Brick 节点的 GlusterFS 卷,在服务端的 Brick 挂载目录会给四个 Brick 平均分配 232的区间的范围空间,GlusterFS hash 分布区间是保存在目录上而不是根据机器去分布区间。
在卷中创建四个文件,分别是 test-file1、test-file2、test-file3、test-file4。在访问文件时,通过快速Hash函数计算出对应的HASH值(232范围的数值),然后根据计算出来的HASH值所对应的子空间散列到服务器的 Brick 上
三:GlusterFS的卷类型
3.1:卷的类型
1:基本卷:
(1) distribute volume:分布式卷
文件通过hash算法分布到所有brick server上,这种卷是glusterfs的基础和最大特点;实只是扩大的磁盘空间,如果有一个磁盘坏了,对应的数据也丢失,文件级RAID 0,不具有容错能力。
(2) stripe volume:条带卷
类似RAID0,文件分成数据块以Round Robin方式分布到brick server上,文件储存以数据块为单位,支持超大文件,文件越大读取效率越高;
(3) replica volume:复制卷文件同步复制到多个brick上,使其具备多个文件副本,属于文件级RAID 1,具有容错能力,因为数据分散在多个 Brick 中,写性能下降,读性能提升。
2:复合卷:
(4) distribute stripe volume:分布式条带卷brickserver数量是条带数条带数(数据块分布的 Brick 数量)的倍数,兼具distribute和stripe卷的特点;
(5) distribute replica volume:分布式复制卷
brick server数量是镜像数(数据副本数量)的倍数,兼具distribute和replica卷的特点,可以在2个或多个节点之间复制数据。
(6) stripe replica volume:条带复制卷类似RAID 10同时具有条带卷和复制卷的特点
(7) distribute stripe replicavolume:分布式条带复制卷三种基本卷的复合卷通常用于类Map Reduce应用
实验部分
实验top
client(客户端)192.168.10.105
node(节点)1 192.168.10.101
node(节点)2 192.168.10.102
node(节点)3 192.168.10.103
node(节点)4 192.168.10.104
操作系统 系统 IP 主机名 挂载磁盘 挂载目录
CentOS 7.3 192.168.10.101 node1 /dev/sdb(3GB) /b3
/dev/sdc(4GB) /c4
/dev/sdd(5GB) /d5
/dev/sde(6GB) /e6
/dev/sdf(7G) /f7
CentOS 7.3 192.168.10.102 node2 /dev/sdb(3GB) /b3
/dev/sdc(4GB) /c4
/dev/sdd(5GB) /d5
/dev/sde(6GB) /e6
/dev/sdf(7G) /f7
CentOS 7.3 192.168.10.103 node3 /dev/sdb(3GB) /b3
/dev/sdc(4GB) /c4
/dev/sdd(5GB) /d5
/dev/sde(6GB) /e6
/dev/sdf(7G) /f7
CentOS 7.3 192.168.10.104 node4 /dev/sdb(3GB) /b3
/dev/sdc(4GB) /c4
/dev/sdd(5GB) /d5
/dev/sde(6GB) /e6
/dev/sdf(7G) /f7
卷名称 卷类型 空间大小/GB Brick
dis-volume 分布式卷 12 node1(/e6)、node2(/e6)
stripe-volume 分散卷 10 node1(/d5)、node2(/d5)、node3(/d5)、node4(/d5)
rep-volume 复制卷 5 node3(/c4)、node4(/c4)
dis-stripe 分布式分散卷 12 node1(/b3)、node2(/b3)、node3(/b3)、node4(/b3)
dis-rep 分布式复制卷 28 node1(/f7)、node2(/f7)、node3(/f7)、node4(/f7)
下面是部署群集的步骤。
1.准备环境(以node1为例,其他节点步骤相同,请自行配置)
在所有节点上执行以下操作。
一、、开启 4 台虚拟机,根据表 2-1为node节点添加相应数量和大小的磁盘,并重启系统,
二、先使用 fdisk 命令创建分区,再使用 mkfs 命令对分区进行格式化,创建相应的挂载目录,并将格式化的磁盘挂载到相应的目录中,最后修改/etc/fstab 配置文件,使其永久生效,还要修改/etc/hosts文件。
1、修改主机名
[root@localhost ~]# hostname node1 //修改主机名为node1-4
[root@localhost ~]# bash //使修改的主机名生效
2、查看所有节点添加的磁盘
[root@localhost ~]# fdisk -l //查看添加的网卡
磁盘 /dev/sda:42.9 GB, 42949672960 字节,83886080 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000abf3d
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 83886079 40893440 8e Linux LVM
磁盘 /dev/sdb:3221 MB, 3221225472 字节,6291456 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/sdc:4294 MB, 4294967296 字节,8388608 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/sde:6442 MB, 6442450944 字节,12582912 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/sdf:7516 MB, 7516192768 字节,14680064 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
3、为所有节点的新磁盘分区用fdisk命令为每个磁盘分区
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x677b9c9b 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):p
磁盘 /dev/sdb:3221 MB, 3221225472 字节,6291456 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x677b9c9b
设备 Boot Start End Blocks Id System
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-6291455,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-6291455,默认为 6291455):
将使用默认值 6291455
分区 1 已设置为 Linux 类型,大小设为 3 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# fdisk /dev/sdc
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x8efb8e2e 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):p
磁盘 /dev/sdc:4294 MB, 4294967296 字节,8388608 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x8efb8e2e
设备 Boot Start End Blocks Id System
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-8388607,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-8388607,默认为 8388607):
将使用默认值 8388607
分区 1 已设置为 Linux 类型,大小设为 4 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# fdisk /dev/sdd
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0xda314715 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):p
磁盘 /dev/sdd:5368 MB, 5368709120 字节,10485760 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xda314715
设备 Boot Start End Blocks Id System
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-10485759,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-10485759,默认为 10485759):
将使用默认值 10485759
分区 1 已设置为 Linux 类型,大小设为 5 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@localhost ~]# fdisk /dev/sde
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x14718474 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):p
磁盘 /dev/sde:6442 MB, 6442450944 字节,12582912 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x14718474
设备 Boot Start End Blocks Id System
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-12582911,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-12582911,默认为 12582911):
将使用默认值 12582911
分区 1 已设置为 Linux 类型,大小设为 6 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
[root@node1 ~]# fdisk /dev/sdf
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x505a24e2 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-14680063,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-14680063,默认为 14680063):
将使用默认值 14680063
分区 1 已设置为 Linux 类型,大小设为 7 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。
4、为每个节点的每个磁盘格式化
[root@localhost ~]# mkfs -t ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 786176 blocks
39308 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@localhost ~]# mkfs -t ext4 /dev/sdc1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048320 blocks
52416 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (16384 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@localhost ~]# mkfs -t ext4 /dev/sdd1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310464 blocks
65523 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@localhost ~]# mkfs -t ext4 /dev/sde1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
393216 inodes, 1572608 blocks
78630 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1610612736
48 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
[root@node1 ~]# mkfs -t ext4 /dev/sdf1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
458752 inodes, 1834752 blocks
91737 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=1879048192
56 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
5、为每个节点创建挂载点
[root@localhost ~]# mkdir /b3
[root@localhost ~]# mkdir /c4
[root@localhost ~]# mkdir /d5
[root@localhost ~]# mkdir /e6
[root@localhost ~]# mkdir /f7
6、为每个节点挂载磁盘
[root@localhost ~]# mount /dev/sdb1 /b3
[root@localhost ~]# mount /dev/sdc1 /c4
[root@localhost ~]# mount /dev/sdd1 /d5
[root@localhost ~]# mount /dev/sde1 /e6
[root@localhost ~]# mount /dev/sdf1 /f7
7、为每个节点修改fstab文件,使挂载永久生效
[root@localhost ~]# vim /etc/fstab
在末尾添加
/dev/sdb1 /b3 ext4 defaults 0 0
/dev/sdc1 /c4 ext4 defaults 0 0
/dev/sdd1 /d5 ext4 defaults 0 0
/dev/sde1 /e6 ext4 defaults 0 0
/dev/sdf1 /f7 ext4 defaults 0 0
8、在所有节点上关闭防火墙和selinux
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
9、在所有节点上修改hosts文件
[root@localhost ~]# vim /etc/hosts
192.168.10.101 node1
192.168.10.102 node2
192.168.10.103 node3
192.168.10.104 node4
三、为所有节点配置yum仓库
这里说明一下,gluster分为6.0之前版本和6.0之后版本也分为两种不同的安装方式
1、安装6.0之前的版本使用的是下载的gluster源码包上传到虚拟机上面并解压的然后重新配置的yum源的rpm仓库文件。
安装方法为:
将GFS所需的rpm仓库的gfsrepo目录拷贝到任意目录下,并修改rpm仓库文件中gluster文件的位置
[root@localhost ~]# vi /etc/yum.repos.d/CentOS-Media.repo //编辑gluster的rpm仓库文件,并把镜像的rpm文件复制到这里来并注释掉
[gfsrepo]
name=GFS
baseurl=file:///opt/gfsrepo //这里gluster的rpm文件位置为/opt/gfsrepo
gpgcheck=0
enabled=1
#[c7-media]
#name=CentOS-$releasever - Media
#baseurl=file:///media/cdrom/
#gpgcheck=1
#enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@localhost ~]# yum -y remove glusterfs* //先删除glusterfs的系统自带的较高版本的依赖包
然后删除或移动镜像的rpm仓库文件
[root@localhost ~]# yum clean all //清除旧的yum缓存
[root@localhost ~]# yum makecache //生成新的yum源
在所有节点上安装gfs
[root@localhost ~]# yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma
2、安装6.0版本或之后的版本,这里使用的是阿里云的源直接下载到/etc/yum.repos.d/里面。
[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]#wget -O epel.repo http://mirrors.aliyun.com/repo/epel-7.repo //使用阿里云源下载红帽的C7的源
[root@localhost yum.repos.d]#wget -O CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo //使用阿里云的源下载的C7的源
然后移除或删除镜像的rpm仓库文件
[root@localhost ~]# yum clean all //清除旧的yum缓存
[root@localhost ~]# yum makecache //生成新的yum源
[root@localhost yum.repos.d]# yum -y install centos-release-gluster //安装centos-release-gluster依赖包因为要安装的glusterfs软件必须要这个依赖 不然glusterfs就安装不上
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 centos-release-gluster9.noarch.0.1.0-1.el7 将被 安装
--> 正在处理依赖关系 centos-release-storage-common,它被软件包 centos-release-gluster9-1.0-1.el7.noarch 需要
--> 正在检查事务
---> 软件包 centos-release-storage-common.noarch.0.2-2.el7.centos 将被 安装
--> 解决依赖关系完成
依赖关系解决
========================================================================================
Package 架构 版本 源 大小
========================================================================================
正在安装:
centos-release-gluster9 noarch 1.0-1.el7 extras 4.1 k
为依赖而安装:
centos-release-storage-common noarch 2-2.el7.centos extras 5.1 k
事务概要
========================================================================================
安装 1 软件包 (+1 依赖软件包)
总下载量:9.2 k
安装大小:2.0 k
Downloading packages:
(1/2): centos-release-storage-common-2-2.el7.centos.noarch.rpm | 5.1 kB 00:00:00
(2/2): centos-release-gluster9-1.0-1.el7.noarch.rpm | 4.1 kB 00:00:00
----------------------------------------------------------------------------------------
总计 18 kB/s | 9.2 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : centos-release-storage-common-2-2.el7.centos.noarch 1/2
正在安装 : centos-release-gluster9-1.0-1.el7.noarch 2/2
验证中 : centos-release-gluster9-1.0-1.el7.noarch 1/2
验证中 : centos-release-storage-common-2-2.el7.centos.noarch 2/2
已安装:
centos-release-gluster9.noarch 0:1.0-1.el7
作为依赖被安装:
centos-release-storage-common.noarch 0:2-2.el7.centos
完毕!
[root@localhost yum.repos.d]# yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma //安装glusterfs所需的依赖包
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* centos-gluster9: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
centos-gluster9 | 3.0 kB 00:00:00
centos-gluster9/7/x86_64/primary_db | 24 kB 00:00:00
软件包 glusterfs-rdma 已经被 glusterfs 取代,改为尝试安装 glusterfs-9.0-1.el7.x86_64
正在解决依赖关系
--> 正在检查事务
---> 软件包 glusterfs.x86_64.0.9.0-1.el7 将被 安装
--> 正在处理依赖关系 libgfrpc0(x86-64) = 9.0-1.el7,它被软件包 glusterfs-9.0-1.el7.x86_64 需要
--> 正在处理依赖关系 libgfxdr0(x86-64) = 9.0-1.el7,它被软件包 glusterfs-9.0-1.el7.x86_64 需要
--> 正在处理依赖关系 libglusterfs0(x86-64) = 9.0-1.el7,它被软件包 glusterfs-9.0-1.el7.x86_64 需要
.............................................................................................................................................省略部分内容
已安装:
glusterfs.x86_64 0:9.0-1.el7 glusterfs-fuse.x86_64 0:9.0-1.el7
glusterfs-server.x86_64 0:9.0-1.el7
作为依赖被安装:
attr.x86_64 0:2.4.46-13.el7 glusterfs-cli.x86_64 0:9.0-1.el7
glusterfs-client-xlators.x86_64 0:9.0-1.el7 libgfapi0.x86_64 0:9.0-1.el7
libgfchangelog0.x86_64 0:9.0-1.el7 libgfrpc0.x86_64 0:9.0-1.el7
libgfxdr0.x86_64 0:9.0-1.el7 libglusterd0.x86_64 0:9.0-1.el7
libglusterfs0.x86_64 0:9.0-1.el7 libtirpc.x86_64 0:0.2.4-0.16.el7
psmisc.x86_64 0:22.20-17.el7 rpcbind.x86_64 0:0.2.0-49.el7
userspace-rcu.x86_64 0:0.10.0-3.el7
完毕!
3、在所有节点上启动GFS
[root@localhost yum.repos.d]# systemctl start glusterd //启动glusterd
[root@localhost yum.repos.d]# systemctl enable glusterd //添加为开机自启
Created symlink from /etc/systemd/system/multi-user.target.wants/glusterd.service to /usr/lib/systemd/system/glusterd.service.
注释:
glusterfs:gluster客户端主程序
glusterfs-server:gluster服务端主程序
glusterfs-fuse:Filesystem Userspace是一个可加载的内核模块,其支持非特权用户创建自己的文件系统而不需要修改内核代码。通过在用户空间运行文件系统的代码通过FUSE代码与内核进行桥接。
glusterfs-rdma:为gluster提供远程直接内存访问,支持不通过双方的OS进行直接内存访问。
四、添加节点(只在node1上操作)并查看节点状态
1、添加节点
[root@localhost ~]# gluster peer probe node1
peer probe: success. Probe on localhost not needed
[root@localhost ~]# gluster peer probe node2
peer probe: success.
[root@localhost ~]# gluster peer probe node3
peer probe: success.
[root@localhost ~]# gluster peer probe node4
peer probe: success.
2、在每个节点上查看状态
[root@localhost ~]# gluster peer status //这个命令查看状态时是不显示自己节点状态的
Number of Peers: 3
Hostname: node2
Uuid: 0543d472-bcdb-4613-968c-20b82143fb3f
State: Peer in Cluster (Connected)
Hostname: node3
Uuid: 90358bde-69ce-422e-bee5-cd2c2027742b
State: Peer in Cluster (Connected)
Hostname: node4
Uuid: 838fb73e-5e24-4742-81c5-420ad240cade
State: Peer in Cluster (Connected)
五、创建卷
1、创建分布式卷(在node1上操作)
注释:默认创建的就是分布式卷
[root@localhost ~]#gluster volume(卷) create(创建) dis-volume(分布式卷) node1(节点1):/e6 node2(节点2):/e6 force(强制)
//创建卷为分布式卷在node1上的挂载点/e6上面和node2的/e6上面。
volume create: dis-volume: success: please start the volume to access data
[root@localhost ~]# gluster volume info dis-volume //查看创建的分布式卷的信息
Volume Name: dis-volume
Type: Distribute
Volume ID: b959a0c7-9679-49be-9b04-74f4e94b9568
Status: Created //状态信息为创建
Snapshot Count: 0
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: node1:/e6
Brick2: node2:/e6
Options Reconfigured:
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
[root@localhost ~]# gluster volume start dis-volume //启动卷分布式卷
volume start: dis-volume: success
[root@localhost ~]# gluster volume info dis-volume //再查看状态信息为Started
Volume Name: dis-volume
Type: Distribute
Volume ID: b959a0c7-9679-49be-9b04-74f4e94b9568
Status: Started //状态信息为Started
Snapshot Count: 0
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: node1:/e6
Brick2: node2:/e6
Options Reconfigured:
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
2、创建条带卷(分散卷)(在node1上操作)
这里还要说明一下在6.0版本和之后的新版本中条带卷已经改名为分散卷了命令也有变化
注释:条带卷要求条带数和Brick Server的数量(node数量)是相同的
6.0版本之前创建条带卷的命令: gluster volume create stripe-volume stripe 2 node1:/d5 node2:/d5 force
6.0版本或6.0之后的版本创建分散卷的命令:gluster volume create disperse-volume disperse 4 node1:/d5 node2:/d5 node3:/d5 node4/d5 force
创建分散卷
注释:分散卷要求分散卷数和Brick Server的数量是(>2)的
[root@localhost ~]# gluster volume create disperse-volume disperse 4 node1:/d5 node2:/d5 node3:/d5 node4:/d5 force //创建分散卷
There isn't an optimal redundancy value for this configuration. Do you want to create the volume with redundancy 1 ? (y/n) y
volume create: disperse-volume: success: please start the volume to access data
[root@localhost ~]# gluster volume info disperse-volume //查看分散卷的的状态
Volume Name: disperse-volume
Type: Disperse
Volume ID: 4edbbb08-686c-45aa-b599-f637f6be600d
Status: Created //状态为创建
Snapshot Count: 0
Number of Bricks: 1 x (3 + 1) = 4
Transport-type: tcp
Bricks:
Brick1: node1:/d5
Brick2: node2:/d5
Brick3: node3:/d5
Brick4: node4:/d5
Options Reconfigured:
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
[root@localhost ~]# gluster volume start disperse-volume //启动分散卷
volume start: disperse-volume: success
[root@localhost ~]# gluster volume info disperse-volume
Volume Name: disperse-volume
Type: Disperse
Volume ID: 4edbbb08-686c-45aa-b599-f637f6be600d
Status: Started //状态为启动
Snapshot Count: 0
Number of Bricks: 1 x (3 + 1) = 4
Transport-type: tcp
Bricks:
Brick1: node1:/d5
Brick2: node2:/d5
Brick3: node3:/d5
Brick4: node4:/d5
Options Reconfigured:
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
3、创建复制卷(在node1上操作)
注释:复制卷要求复制的数量和Brick Server的数量(node的数量)相同
[root@localhost ~]# gluster volume create rep-volume replica 2 node3:/c4 node4:/c4 force
volume create: rep-volume: success: please start the volume to access data
[root@localhost ~]# gluster volume start rep-volume
volume start: rep-volume: success
[root@localhost ~]# gluster volume info rep-volume
Volume Name: rep-volume
Type: Replicate
Volume ID: 8e89d06f-bea6-41bb-b6c6-6c30d87d00cc
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node3:/c4
Brick2: node4:/c4
Options Reconfigured:
cluster.granular-entry-heal: on
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
performance.client-io-threads: off
4、创建分布式分散卷(在node1上操作)
注释:分布式分散卷要求Brick Server的数量必须是分散数的倍数(>两倍或更高的倍数)
[root@localhost ~]# gluster volume create dis-disperse disperse 4 node1:/b3 node2:/b3 node3:/b3 node4:/b3 force
There isn't an optimal redundancy value for this configuration. Do you want to create the volume with redundancy 1 ? (y/n) y
volume create: dis-disperse: success: please start the volume to access data
[root@localhost ~]# gluster volume info dis-disperse
Volume Name: dis-disperse
Type: Disperse
Volume ID: c2c79a63-f239-44b5-931a-fedbbce406bf
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x (3 + 1) = 4
Transport-type: tcp
Bricks:
Brick1: node1:/b3
Brick2: node2:/b3
Brick3: node3:/b3
Brick4: node4:/b3
Options Reconfigured:
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
5、创建分布式复制卷(在node1上操作)
注释:分布式复制卷要求Brick Server的数量必须是复制数的倍数(两倍或更高的倍数)
[root@localhost ~]# gluster volume create dis-rep replica 2 node1:/f7 node2:/f7 node3:/f7 node4:/f7 force
volume create: dis-rep: success: please start the volume to access data
[root@localhost ~]# gluster volume start dis-rep
volume start: dis-rep: success
[root@localhost ~]# gluster volume info dis-rep
Volume Name: dis-rep
Type: Distributed-Replicate
Volume ID: 8fd1aa3c-35a5-44c0-83f9-51c2f2658959
Status: Started
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/f7
Brick2: node2:/f7
Brick3: node3:/f7
Brick4: node4:/f7
Options Reconfigured:
cluster.granular-entry-heal: on
storage.fips-mode-rchecksum: on
transport.address-family: inet
nfs.disable: on
performance.client-io-threads: off
六、部署GFS客户端
1、安装客户端软件
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# setenforce 0
[root@localhost ~]# yum -y install centos-release-gluster //想安装gluster相关必须安装centos-release-gluster这个依赖
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(2/2): epel/x86_64/primary_db | 6.9 MB 00:00:00
正在解决依赖关系
........................................................................................................省略部分内容
总计 44 kB/s | 9.2 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : centos-release-storage-common-2-2.el7.centos.noarch 1/2
正在安装 : centos-release-gluster9-1.0-1.el7.noarch 2/2
验证中 : centos-release-gluster9-1.0-1.el7.noarch 1/2
验证中 : centos-release-storage-common-2-2.el7.centos.noarch 2/2
已安装:
centos-release-gluster9.noarch 0:1.0-1.el7
作为依赖被安装:
centos-release-storage-common.noarch 0:2-2.el7.centos
完毕!
[root@localhost ~]# yum -y install glusterfs glusterfs-fuse //安装客户端工具
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* centos-gluster9: mirrors.ustc.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
centos-gluster9 | 3.0 kB 00:00:00
centos-gluster9/7/x86_64/primary_db | 24 kB 00:00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 glusterfs.x86_64.0.9.0-1.el7 将被 安装
--> 正在处理依赖关系 libgfrpc0(x86-64) = 9.0-1.el7,它被软件包 glusterfs-9.0-1.el7.x86_64 需要
--> 正在处理依赖关系 libgfxdr0(x86-64) = 9.0-1.el7,它被软件包 glusterfs-9.0-1.el7.x86_64 需要
.....................................................................................................................省略部分内容
验证中 : glusterfs-fuse-9.0-1.el7.x86_64 8/9
验证中 : glusterfs-9.0-1.el7.x86_64 9/9
已安装:
glusterfs.x86_64 0:9.0-1.el7 glusterfs-fuse.x86_64 0:9.0-1.el7
作为依赖被安装:
attr.x86_64 0:2.4.46-13.el7 glusterfs-client-xlators.x86_64 0:9.0-1.el7
libgfrpc0.x86_64 0:9.0-1.el7 libgfxdr0.x86_64 0:9.0-1.el7
libglusterfs0.x86_64 0:9.0-1.el7 psmisc.x86_64 0:22.20-17.el7
userspace-rcu.x86_64 0:0.10.0-3.el7
完毕!
2、创建挂载目录
[root@localhost ~]# mkdir -p /test/{dis,disperse,rep,dis_and_disperse,dis_and_rep}
[root@localhost ~]# ls /test
dis dis_and_rep dis_and_disperse disperse rep
3、修改hosts文件
[root@localhost ~]# vim /etc/hosts
192.168.10.101 node1
192.168.10.102 node2
192.168.10.103 node3
192.168.10.104 node4
4、挂载Gluster文件系统
[root@localhost ~]# mount -t glusterfs node1:dis-volume /test/dis //挂载节点1的dis-volume卷到本机的/test/dis
[root@localhost ~]# mount -t glusterfs node1:disperse-volume /test/disperse //挂载节点1的disperse-volume卷到本机的/test/disperse
[root@localhost ~]# mount -t glusterfs node1:rep-volume /test/rep //挂载节点1的rep-volume卷到本机的/test/rep
[root@localhost ~]# mount -t glusterfs node1:dis-disperse /test/dis_and_disperse //挂载节点1的dis-disperse卷到本机的/test/dis_and_disperse
[root@localhost ~]# mount -t glusterfs node1:dis-rep /test/dis_and_rep //挂载节点1的dis-rep卷到本机的/test/dis_and_rep
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 475M 0 475M 0% /dev
tmpfs 487M 0 487M 0% /dev/shm
tmpfs 487M 7.7M 479M 2% /run
tmpfs 487M 0 487M 0% /sys/fs/cgroup
/dev/mapper/centos-root 37G 3.6G 34G 10% /
/dev/sda1 1014M 137M 878M 14% /boot
tmpfs 98M 0 98M 0% /run/user/0
node1:dis-volume 12G 169M 11G 2% /test/dis
node1:disperse-volume 15G 211M 14G 2% /test/disperse
node1:rep-volume 3.9G 57M 3.7G 2% /test/rep
node1:dis-disperse 8.7G 119M 8.2G 2% /test/dis_and_disperse
node1:dis-rep 14G 204M 13G 2% /test/dis_and_rep
5、修改fstab配置文件
[root@localhost ~]# vim /etc/fstab //修改/etc/fstab文件让挂载永久生效
在末尾添加:
node1:dis-volume /test/dis glusterfs defaules,_netdev 0 0
node1:disperse-volume /test/disperse glusterfs defaules,_netdev 0 0
node1:rep-volume /test/rep glusterfs defaules,_netdev 0 0
node1:dis-disperse /test/dis_and_disperse glusterfs defaules,_netdev 0 0
node1:dis-rep /test/dis_and_rep glusterfs defaules,_netdev 0 0
七、在客户端测试Gluster文件系统
1、在卷中写入文件
(1)创建测试文件
[root@localhost ~]# dd if=/dev/zero of=/root/demo1.log bs=1M count=43
记录了43+0 的读入
记录了43+0 的写出
45088768字节(45 MB)已复制,0.0153793 秒,2.9 GB/秒
[root@localhost ~]# dd if=/dev/zero of=/root/demo2.log bs=1M count=43
记录了43+0 的读入
记录了43+0 的写出
45088768字节(45 MB)已复制,0.219521 秒,205 MB/秒
[root@localhost ~]# dd if=/dev/zero of=/root/demo3.log bs=1M count=43
记录了43+0 的读入
记录了43+0 的写出
45088768字节(45 MB)已复制,0.299094 秒,151 MB/秒
[root@localhost ~]# dd if=/dev/zero of=/root/demo4.log bs=1M count=43
记录了43+0 的读入
记录了43+0 的写出
45088768字节(45 MB)已复制,0.360057 秒,125 MB/秒
[root@localhost ~]# dd if=/dev/zero of=/root/demo5.log bs=1M count=43
记录了43+0 的读入
记录了43+0 的写出
45088768字节(45 MB)已复制,0.399802 秒,113 MB/秒
(2)卷中写入文件
[root@localhost ~]# cp demo* /test/dis/
[root@localhost ~]# cp demo* /test/disperse/
[root@localhost ~]# cp demo* /test/rep/
[root@localhost ~]# cp demo* /test/dis_and_disperse/
[root@localhost ~]# cp demo* /test/dis_and_rep/
2、查看文件分布
(1)在node1和node2中查看分布式卷文件分布
node1:
[root@node1 ~]# ll -h /e6
总用量 173M
-rw-r--r--. 2 root root 43M 3月 27 20:20 demo1.log
-rw-r--r--. 2 root root 43M 3月 27 20:20 demo2.log
-rw-r--r--. 2 root root 43M 3月 27 20:20 demo3.log
-rw-r--r--. 2 root root 43M 3月 27 20:20 demo4.log
drwx------. 2 root root 16K 3月 27 15:22 lost+found
node2:
[root@node2 ~]# ll -h /e6
总用量 44M
-rw-r--r--. 2 root root 43M 3月 27 20:20 demo5.log
drwx------. 2 root root 16K 3月 27 15:24 lost+found
(2)在node1和node2中查看分散卷文件分布
node1:
[root@node1 ~]# ll -h /d5
总用量 72M
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo1.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo2.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo3.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo4.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo5.log
drwx------. 2 root root 16K 3月 27 15:24 lost+found
node2:
[root@node2 ~]# ll -h /d5
总用量 72M
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo1.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo2.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo3.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo4.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo5.log
drwx------. 2 root root 16K 3月 27 15:22 lost+found
(3)在node3和node4中查看复制卷文件分布
node3:
[root@node3 ~]# ll -h /c4
总用量 216M
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo1.log
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo2.log
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo3.log
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo4.log
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo5.log
drwx------. 2 root root 16K 3月 27 15:24 lost+found
node4:
[root@node4 ~]# ll -h /c4
总用量 216M
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo1.log
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo2.log
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo3.log
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo4.log
-rw-r--r--. 2 root root 43M 3月 27 20:21 demo5.log
drwx------. 2 root root 16K 3月 27 15:25 lost+found
(4)在node1、node2、node3、node4中查看分布式分散文件分布
node1:
[root@node1 ~]# ll -h /b3
总用量 72M
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo1.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo2.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo3.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo4.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo5.log
drwx------. 2 root root 16K 3月 27 15:21 lost+found
node2:
[root@node2 ~]# ll -h /b3
总用量 72M
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo1.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo2.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo3.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo4.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo5.log
drwx------. 2 root root 16K 3月 27 15:24 lost+found
node3:
[root@node3 ~]# ll -h /b3
总用量 72M
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo1.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo2.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo3.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo4.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo5.log
drwx------. 2 root root 16K 3月 27 15:24 lost+found
node4:
[root@node4 ~]# ll -h /b3
总用量 72M
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo1.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo2.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo3.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo4.log
-rw-r--r--. 2 root root 15M 3月 27 20:21 demo5.log
drwx------. 2 root root 16K 3月 27 15:25 lost+found
(5)在node1、node2、node3、node4中查看分布式复制卷文件分布
node1:
[root@node1 ~]# ll -h /f7
总用量 173M
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo1.log
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo2.log
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo3.log
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo4.log
drwx------. 2 root root 16K 3月 27 19:28 lost+found
node2:
[root@node2 ~]# ll -h /f7
总用量 173M
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo1.log
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo2.log
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo3.log
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo4.log
drwx------. 2 root root 16K 3月 27 19:28 lost+found
node3:
[root@node3 ~]# ll -h /f7
总用量 44M
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo5.log
drwx------. 2 root root 16K 3月 27 19:28 lost+found
node4:
[root@node4 ~]# ll -h /f7
总用量 44M
-rw-r--r--. 2 root root 43M 3月 27 20:22 demo5.log
drwx------. 2 root root 16K 3月 27 19:28 lost+found
八、破坏性测试
(1)挂起node2节点,在客户端上测试各个文件是否可以正常使用
(2)再挂起node4,在客户端继续测试各个文件的读取
九、其他维护命令
1、查看所有GFS卷
[root@localhost ~]# gluster volume list
2、查看所有卷的状态
[root@localhost ~]# gluster volume info
[root@localhost ~]# gluster volume info 卷名 //查看卷状态
[root@localhost ~]# gluster volume status
[root@localhost ~]# gluster volume status 卷名 //查看卷状态
3、停止删除卷, 要删除某个卷首先要停止卷,然后才能删除卷
[root@localhost ~]# gluster volume stop dis-volume
Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y
volume stop: dis-stripe: success
[root@localhost ~]# gluster volume delete dis-volume
Deleting volume will erase all information about the volume. Do you want to continue? (y/n) y
volume delete: dis-stripe: failed: Some of the peers are down
3:设置卷的访问控制
[root@localhost ~]# gluster volume set dis-rep auth.allow 192.168.1.*,10.1.1.* //设置授予192.168.1.0网段的和10.1.1.0网段的用户对dis-rep卷授予允许的权限
volume set: success
扩展:
创建条带复制卷
[root@localhost ~]# gluster volume create stripe-rep stripe 2 replica 2 node1:/b3 node2:/b3 node3:/b3 node4:/b3 force
创建分散复制卷
[root@localhost ~]# gluster volume create disperse-rep disperse 2 replica 2 node1:/b3 node2:/b3 node3:/b3 node4:/b3 force
创建分布式条带复制卷
[root@localhost ~]# gluster volume create dis-stripe-rep stripe 2 replica 2 node1:/e6 node2:/e6 node3:/e6 node4:/e6 node1:/d5 node2:/d5 node3:/d5 node4:/d5 force
创建分布式分散复制卷
[root@localhost ~]# gluster volume create dis-disperse-rep disperse 2 replica 2 node1:/e6 node2:/e6 node3:/e6 node4:/e6 node1:/d5 node2:/d5 node3:/d5 node4:/d5 force
浙公网安备 33010602011771号