十三章——GlusterFS分布式文件系统群集(应用——linux防护与群集)

三期总目录链接

目录

一、GlusterFS相关知识介绍

(一)简介

1、 GlusterFS介绍

二、glusterFs实例

(一)准备环境

1、分区

2、node1~node4 安装软件--yum方式(需要配置本地其他目录的yum仓库)

3、node1~node4 所有节点启动glusterfs

4、添加节点,只在node1 上执行操作即可

5、查看群集状态

(二)创建卷

1、创建分布式卷 

2、创建条带卷

3、创建复制卷

4、创建分布式条带卷

5、创建分布式复制卷

(三)部署glusterfs客户端:192.168.1.8

1、安装客户端软件

2、创建挂载目录

3、修改hosts文件

4、挂载glusterfs文件系统

5、设置为自动挂载

6、测试glusterfs文件系统

7、维护命令

复习题


一、GlusterFS相关知识介绍

(一)简介

1、 GlusterFS介绍

  Glusterfs是一个开源的分布式文件系统,是Scale存储的核心,能够处理千数量级的客户端.在传统的解决 方案中Glusterfs能够灵活的结合物理的,虚拟的和云资源去体现高可用和企业级的性能存储

  Glusterfs通过TCP/IP或InfiniBand RDMA网络链接将客户端的存储资块源聚集在一起,使用单一的全局命名空间来管理数据,磁盘和内存资源

  Glusterfs基于堆叠的用户空间设计,可以为不同的工作负载提供高优的性能。Glusterfs支持运行在任何标准IP网络上标准应用程序的标准客户端,用户可以在全局统一的命名空间中使用NFS/CIFS等标准协议来访问应用数据。

1.1、GlusterFS特点

GlusterFS特点:扩展性和高性能、高可用、全局统一命名空间、弹性HASH算法、弹性卷管理、基于标准协议

弹性HASH算法的优点: 保证数据平均分布在每个Brick中,解决了对元数据服务器的依赖,进而解决了单点故障及访问瓶颈

 1.2、GlusterFS术语

 1)、Brick(存储块):指可信主机池中由主机提供的用于物理存储的专用分区,是GlusterFS中的基本存储单元,同时也是可信存储池中服务器上对外提供的存储目录。存储目录的格式由服务器和目录的绝对路径构成
2)、Volume(逻辑卷): 是一组存储块的集合
3)、FUSE(Filesystem inUserspace):是一个内核模块,作用是允许用户创建自己的文件系统
4)、VFS: 内核空间对用户空间提供的访问磁盘的接口
5)、Glusterd(后台管理进程):存储群集中的每个节点都要运行

1.3、GlusterFS的工作模式

1)、客户端或应用程序通过GlusterFS的挂载点访问数据
2) 、Linux系统内核通过VFS API收到清求并处理
3)、 VFS 将数据递交给 FUSE 内核文件系统,并向系统注册一个实际的文件系统 FUSE,而 FUSE文件系统则是将数据通过/dev/fuse 设备文件递交给了 GlusterFS client 端。可以将 FUSE 文件系统理解为一个代理
4) 、GlusterFS client收到数据后,client根据配置文件对数据进行处理
5)、经过GlusterFS client处理后,通过网络将数据传递至远端的GlusterFS Server.并且将数据写入服务器存储设备

1.3、GlusterFS的卷类型

GlusterFS 支持七种卷:分布式卷、条带卷、复制卷、分布式条带卷、分布式复制卷、条带复制卷(stripe replica volume)分布式条带复制卷(distribute stripe replicavolume),这七种卷可以满足不同应用对高性能,高可用的需求

卷类型特点

简介

分布式卷

distribute volume

1、文件分布在不同的服务器,不具备冗余性
2、更容易且廉价地扩展卷的大小
3、单点故障会造成数据丢失
4、依赖底层的数据保护
GlusterFS的默认卷,在创建卷时,默认选项是创建分布式卷

条带卷

stripe volume

1、数据被分割成更小块分布到块服务器群中的不同条带区
2、分布减少了负载且更小的文件加速了存取的速度
3、没有数据冗余
Stripe模式相当于RAIDO,在该模式下,根据偏移量将文件分成N块(N个条带节点),轮询地存储在每个Brick Server节点

复制卷

replica volume

1、卷中所有的服务器均保存一个完整的副本

2、卷的副本数量可由客户创建的时候决定

3、至少有两个块服务器或更多服务器
4、具备冗余性

也称为AFR (AutoFile Replication),相当于RAID1,即同一文件保存一份或多份副本每个节点上保存相同的内容和目录结构

分布式条带卷

distribute stripe volume

用于大文件访问处理,创建一个分布式条带卷最少需要4台服务器兼顾分布式卷和条带卷的功能

分布式复制卷

distribute replica volume

用于需要冗余的情况下兼顾分布式卷和复制卷的功能

二、glusterFs实例

主机名地址添加磁盘挂载目录

node1

192.168.1.42G、4G、6G、7G/bb、/cc、/dd、/ee
node2192.168.1.52G、4G、6G、7G/bb、/cc、/dd、/ee
node3192.168.1.62G、4G、6G/bb、/cc、/dd
node4192.168.1.72G、4G、6G/bb、/cc、/dd
客户端C-08192.168.1.8

                

(一)准备环境

1、分区

node1~node4步骤相同

[root@node1 ~]# fdisk /dev/sdb       #使用命令fdisk进行分区
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0xe8f363c2 创建新的 DOS 磁盘标签。

命令(输入 m 获取帮助):n                              #创建分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p):                             #默认为p主分区
Using default response p
分区号 (1-4,默认 1):                     ----回车
起始 扇区 (2048-4194303,默认为 2048):     ----回车
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-4194303,默认为 4194303):    ----回车
将使用默认值 4194303
分区 1 已设置为 Linux 类型,大小设为 2 GiB

命令(输入 m 获取帮助):w                          #保存退出
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。
相同方法略

[root@node1 ~]# fdisk /dev/sdc
[root@node1 ~]# fdisk /dev/sdd
[root@node1 ~]# fdisk /dev/sde

1.2、格式化

-t ext4 表示写入的是ext4文件系统
并且只能给主分区sdb1和扩展分区sdb5写入文件系统(不能给扩展分区sdb2写入文件系统)

[root@node1 ~]# mkfs -t ext4 /dev/sdb1
.....
[root@node1 ~]# mkfs -t ext4 /dev/sdc1
....
[root@node1 ~]# mkfs -t ext4 /dev/sdd1
....
[root@node1 ~]# mkfs -t ext4 /dev/sde1
.....

创建挂载点并挂载

[root@node1 ~]# mkdir /bb /cc /dd /ee
[root@node1 ~]# mount /dev/sdb1 /bb
[root@node1 ~]# mount /dev/sdc1 /cc
[root@node1 ~]# mount /dev/sdd1 /dd
[root@node1 ~]# mount /dev/sde1 /ee

创建自动挂载

[root@node1 ~]# vim /etc/fstab
.....
..
/dev/sdb1       /bb             ext4    defaults 1 2
/dev/sdc1       /cc             ext4    defaults 1 2
/dev/sdd1       /dd             ext4    defaults 1 2
/dev/sde1       /ee             ext4    defaults 1 2

退出保存
[root@node1 ~]# df -hT
文件系统                类型      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root xfs        18G  1.4G   17G    8% /
devtmpfs                devtmpfs  226M     0  226M    0% /dev
tmpfs                   tmpfs     237M     0  237M    0% /dev/shm
tmpfs                   tmpfs     237M  4.7M  232M    2% /run
tmpfs                   tmpfs     237M     0  237M    0% /sys/fs/cgroup
/dev/sr0                iso9660   4.3G  4.3G     0  100% /media/cdrom
/dev/sda1               xfs      1014M  125M  890M   13% /boot
tmpfs                   tmpfs      48M     0   48M    0% /run/user/0
/dev/sdb1               ext4      2.0G  6.0M  1.9G    1% /bb
/dev/sdc1               ext4      3.9G   16M  3.7G    1% /cc
/dev/sdd1               ext4      5.8G   24M  5.5G    1% /dd
/dev/sde1               ext4      6.8G   32M  6.4G    1% /ee

1.3、node1~node4配置hosts文件,使节点服务器能够互相解析访问。修改主机名为自己的主机名 

echo '192.168.1.4 node1
192.168.1.5 node2
192.168.1.6 node3
192.168.1.7 node4' >>/etc/hosts
cat /etc/hosts   

2、node1~node4 安装软件--yum方式(需要配置本地其他目录的yum仓库)

注意: 上传gfsrepo文件夹相关软件到/other目录中

[root@node1 ~]# yum -y install createrepo
.....
..
[root@node1 ~]# which createrepo
/usr/bin/createrepo
[root@node1 ~]# mkdir /other    
[root@node1 ~]# ll /other 
.......
...


[root@node1 ~]# vim /etc/yum.repos.d/aaa.repo 

#[aaa]
#name=安装包镜像
#baseurl=file:///media/cdrom
#enabled=1
#gpgcheck=0



[other]               #添加内容
name=glusterfs
baseurl=file:///other
enabled=1
gpgcheck=0

本次实验不使用缓存yum安装 

打开yum的缓存功能

 考虑到直接使用yum进行安装,可能会因为repo源的更新而导致服务器的软件环境不一致问题出现(包括以后新增的服务器也需要一致配置),所以通过开启yum的缓存功能,来在A服务器上进行配置,其它服务器上直接使用A服务器中yum缓存下来的软件包进行安装即可

[root@node1 ~]# vim /etc/yum.conf

[main]
cachedir=/var/cache/yum/$basearch/$releasever    #用来缓存安装包的具体目录
keepcache=1                                      #修改为1

 服务器完成所有配置后,将cachedir指定的目录直接拷贝到其它待安装的服务器上,然后使用  yum -C install [软件包名]  即可使用缓存安装。(-C参数表示使用系统缓存)

好处: 便于多台服务器的统一配置,以及后续新增的服务器的统一配置; 节省了公司带宽占用


2.1、创建软件数据库目录

[root@node1 ~]# createrepo /other
Spawning worker 0 with 115 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

[root@node1 ~]# yum makecache
已加载插件:fastestmirror
other                                                                                                   | 2.9 kB  00:00:00     
(1/3): other/filelists_db                                                                               |  62 kB  00:00:00     
(2/3): other/other_db                                                                                   |  46 kB  00:00:00     
(3/3): other/primary_db                                                                                 |  92 kB  00:00:00     
Loading mirror speeds from cached hostfile
元数据缓存已建立

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

完毕!

3、node1~node4 所有节点启动glusterfs

[root@node1 ~]# systemctl start glusterd
[root@node1 ~]# systemctl enable  glusterd
Created symlink from /etc/systemd/system/multi-user.target.wants/glusterd.service to /usr/lib/systemd/system/glusterd.service.

4、添加节点,只在node1 上执行操作即可

[root@node1 ~]# gluster peer probe node1
peer probe: success. Probe on localhost not needed
[root@node1 ~]# gluster peer probe node2
peer probe: success. 
[root@node1 ~]# gluster peer probe node3
peer probe: success. 
[root@node1 ~]# gluster peer probe node4
peer probe: success. 

5、查看群集状态

[root@node1 ~]# gluster peer status
Number of Peers: 3

Hostname: node2
Uuid: 4e9eae77-7e1e-42b9-8faa-3ff83357adb7
State: Peer in Cluster (Connected)

Hostname: node3
Uuid: 31e602fb-04f2-478c-a6a9-7ea9eb0158c2
State: Peer in Cluster (Connected)

Hostname: node4
Uuid: 54cfb172-156f-464d-afc2-5fc3a4e5c95b
State: Peer in Cluster (Connected)

正常状态:State: Peer in Cluster (Connected)
非正常状态:Disconnected 考虑检查hosts文件

(二)创建卷

distribute分布
stripe条带
replaction复制

1、创建分布式卷 

[root@node1 ~]# gluster volume create dis-volume node1:/ee node2:/ee force    #创建名dis-volume的分布式卷
volume create: dis-volume: success: please start the volume to access data

[root@node1 ~]# gluster volume info dis-volume   #查看集群中的卷信息
 
Volume Name: dis-volume
Type: Distribute
Volume ID: 6410d428-cf51-49d1-ace0-7060a12f1005
Status: Created
Snapshot Count: 0
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: node1:/ee
Brick2: node2:/ee
Options Reconfigured:
transport.address-family: inet
nfs.disable: on

[root@node1 ~]# gluster volume start dis-volume   # 启动卷
volume start: dis-volume: success

      --------没有指定类型,默认创建分布式卷--------

2、创建条带卷

指定类型:stripe    数值:2  有2个brick server

[root@node1 ~]# gluster volume create stripe-volume stripe 2 node1:/dd node2:/dd force              #创建名称为stripe-volume的条带卷
volume create: stripe-volume: success: please start the volume to access data
[root@node1 ~]# gluster volume info stripe-volume
 
Volume Name: stripe-volume
Type: Stripe
Volume ID: 44f74bd4-5855-4117-a99e-a1dcd817fd18
Status: Created
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node1:/dd
Brick2: node2:/dd
Options Reconfigured:
transport.address-family: inet
nfs.disable: on

[root@node1 ~]# gluster volume start stripe-volume
volume start: stripe-volume: success

3、创建复制卷

[root@node1 ~]# gluster volume create rep-volume replica 2 node3:/dd node4:/dd force        
volume create: rep-volume: success: please start the volume to access data
[root@node1 ~]# gluster volume info rep-volume
 
Volume Name: rep-volume
Type: Replicate
Volume ID: f79641fc-d89d-46b4-83c6-c3865783bf11
Status: Created
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node3:/dd
Brick2: node4:/dd
Options Reconfigured:
transport.address-family: inet
nfs.disable: on

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

4、创建分布式条带卷

[root@node1 ~]# gluster volume create dis-stripe stripe  2 node1:/bb node2:/bb node3:/bb node4:/bb force           
volume create: dis-stripe: success: please start the volume to access data
[root@node1 ~]# gluster volume info dis-stripe
 
Volume Name: dis-stripe
Type: Distributed-Stripe
Volume ID: 1c123eee-7922-4b8f-9580-51c097b25812
Status: Created
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/bb
Brick2: node2:/bb
Brick3: node3:/bb
Brick4: node4:/bb
Options Reconfigured:
transport.address-family: inet
nfs.disable: on

[root@node1 ~]# gluster volume start dis-stripe
volume start: dis-stripe: success

5、创建分布式复制卷

[root@node1 ~]# gluster volume create dis-rep  replica  2 node1:/cc node2:/cc node3:/cc node4:/cc force           
volume create: dis-rep: success: please start the volume to access data
[root@node1 ~]# gluster volume info dis-rep
 
Volume Name: dis-rep
Type: Distributed-Replicate
Volume ID: dc84910e-4aa9-495c-b3ae-022458118e0b
Status: Created
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/cc
Brick2: node2:/cc
Brick3: node3:/cc
Brick4: node4:/cc
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
[root@node1 ~]# gluster volume start dis-rep
volume start: dis-rep: success

(三)部署glusterfs客户端:192.168.1.8

1、安装客户端软件

[root@C-08 ~]# yum -y install createrepo
.......
...
[root@C-08 ~]# which createrepo
/usr/bin/createrepo
[root@C-08 ~]# mkdir /other

上传gfsrepo文件夹相关软件到  /other  目录中

[root@C-08 ~]# ll /other
总用量 53156
-rw-r--r-- 1 root root    67184 9月  18 00:01 attr-2.4.46-12.el7.x86_64.rpm
-rw-r--r-- 1 root root   247892 9月  18 00:01 audit-2.7.6-3.el7.x86_64.rpm
-rw-r--r-- 1 root root    98136 9月  18 00:01 audit-libs-2.7.6-3.el7.i686.rpm
-rw-r--r-- 1 root root    97960 9月  18 00:01 audit-libs-2.7.6-3.el7.x86_64.rpm
-rw-r--r-- 1 root root    40620 9月  18 00:01 bzip2-libs-1.0.6-13.el7.i686.rpm
-rw-r--r-- 1 root root    80952 9月  18 00:01 cracklib-2.9.0-11.el7.i686.rpm
-rw-r--r-- 1 root root   329032 9月  18 00:01 dracut-033-502.el7.x86_64.rpm
-rw-r--r-- 1 root root    56712 9月  18 00:01 dracut-config-rescue-033-502.el7.x86_64.rpm
-rw-r--r-- 1 root root    99772 9月  18 00:01 dracut-network-033-502.el7.x86_64.rpm
.............
.....
[root@C-08 ~]# vim /etc/yum.repos.d/aaa.repo 

#[aaa]
#nema=aaa
#baseurl=file:///media/cdrom
#enabled=1
#gpgcheck=0

[other]
name=glusterfs
baseurl=file:///other
enabled=1
gpgcheck=0

创建软件数据库目录

[root@C-08 ~]# createrepo /other
Spawning worker 0 with 115 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete

[root@C-08 ~]# yum makecache
已加载插件:fastestmirror
other                                                                                                   | 2.9 kB  00:00:00     
(1/3): other/filelists_db                                                                               |  62 kB  00:00:00     
(2/3): other/other_db                                                                                   |  46 kB  00:00:00     
(3/3): other/primary_db                                                                                 |  92 kB  00:00:00     
Loading mirror speeds from cached hostfile
元数据缓存已建立

2、创建挂载目录

[root@C-08 ~]# mkdir -p /aaa/{dis,stripe,rep,dis_and_stripe,dis_and_rep}
[root@C-08 ~]# ls /aaa
dis  dis_and_rep  dis_and_stripe  rep  stripe

3、修改hosts文件

echo '192.168.1.4 node1
192.168.1.5 node2
192.168.1.6 node3
192.168.1.7 node4' >>/etc/hosts
cat /etc/hosts
[root@C-08 ~]# ping node1 -c 3
PING node1 (192.168.1.4) 56(84) bytes of data.
64 bytes from node1 (192.168.1.4): icmp_seq=1 ttl=64 time=0.890 ms
64 bytes from node1 (192.168.1.4): icmp_seq=2 ttl=64 time=0.335 ms
64 bytes from node1 (192.168.1.4): icmp_seq=3 ttl=64 time=0.462 ms

4、挂载glusterfs文件系统

挂载时指定的node1只是为了获取必要的配置信息,挂载后,客户端也会直接和逻辑存储卷内其他brick所在的主机进行通信

[root@C-08 ~]# mount -t glusterfs node1:dis-volume /aaa/dis
[root@C-08 ~]# mount -t glusterfs node1:stripe-volume /aaa/stripe
[root@C-08 ~]# mount -t glusterfs node1:rep-volume /aaa/rep
[root@C-08 ~]# mount -t glusterfs node1:dis-stripe  /aaa/dis_and_stripe
[root@C-08 ~]# mount -t glusterfs node1:dis-rep  /aaa/dis_and_rep

[root@C-08 ~]# df -h
文件系统                       容量  已用  可用 已用% 挂载点
/dev/mapper/centos_c--08-root   17G  1.4G   16G    9% /
devtmpfs                       226M     0  226M    0% /dev
tmpfs                          237M     0  237M    0% /dev/shm
tmpfs                          237M  4.7M  232M    2% /run
tmpfs                          237M     0  237M    0% /sys/fs/cgroup
/dev/sr0                       4.3G  4.3G     0  100% /media/cdrom
/dev/sda1                     1014M  125M  890M   13% /boot
tmpfs                           48M     0   48M    0% /run/user/0
node1:dis-volume                14G   64M   13G    1% /aaa/dis
node1:stripe-volume             12G   49M   11G    1% /aaa/stripe
node1:rep-volume               5.8G   25M  5.5G    1% /aaa/rep
node1:dis-stripe               7.8G   25M  7.3G    1% /aaa/dis_and_stripe
node1:dis-rep                  7.8G   33M  7.3G    1% /aaa/dis_and_rep

5、设置为自动挂载

echo 'node1:dis-volume        /aaa/dis       glusterfs defaults,_netdev 0 0
node1:stripe-volume     /aaa/stripe    glusterfs defaults,_netdev 0 0
node1:rep-volume        /aaa/rep       glusterfs defaults,_netdev 0 0
node1:dis-stripe        /aaa/dis_and_stripe    glusterfs defaults,_netdev 0 0
node1:dis-rep           /aaa/dis_and_rep       glusterfs defaults,_netdev 0 0' >>/etc/fstab
cat /etc/fstab

6、测试glusterfs文件系统

卷中写入文件

[root@C-08 ~]# du -sh /var/log/messages    #计算当前文件夹的总磁盘占用量, -s选项表示计算总和, -h选项表示以恰当的K/M/G单位展示
628K	/var/log/messages
[root@C-08 ~]# tail -3 /var/log/messages
Sep 18 00:14:53 C-08 kernel: fuse init (API version 7.22)
Sep 18 00:14:53 C-08 systemd: Mounting FUSE Control File System...
Sep 18 00:14:53 C-08 systemd: Mounted FUSE Control File System.

[root@C-08 ~]# cp /var/log/messages test1.log
[root@C-08 ~]# cp /var/log/messages test2.log
[root@C-08 ~]# cp /var/log/messages test3.log
[root@C-08 ~]# cp /var/log/messages test4.log
[root@C-08 ~]# cp /var/log/messages test5.log
[root@C-08 ~]# chmod 644 test*
[root@C-08 ~]# ll -h test*
-rw-r--r-- 1 root root 626K 9月  18 00:33 test1.log
-rw-r--r-- 1 root root 626K 9月  18 00:33 test2.log
-rw-r--r-- 1 root root 626K 9月  18 00:33 test3.log
-rw-r--r-- 1 root root 626K 9月  18 00:33 test4.log
-rw-r--r-- 1 root root 626K 9月  18 00:33 test5.log


[root@C-08 ~]# cp test* /aaa/dis/
[root@C-08 ~]# cp test* /aaa/stripe/
[root@C-08 ~]# cp test* /aaa/rep/
[root@C-08 ~]# cp test* /aaa/dis_and_stripe/
[root@C-08 ~]# cp test* /aaa/dis_and_rep/

6.1、在node服务器上查看文件

1)、 node1,node2---查看分布式卷;没有分片,原始大小

      

[root@node1 ~]# ll -h /ee
总用量 1.9M
drwx------ 2 root root  16K 9月  17 21:31 lost+found
-rw-r--r-- 2 root root 626K 9月  18 00:48 test1.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test2.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test4.log

      

[root@node2 ~]# ll -h /ee
总用量 1.3M
drwx------. 2 root root  16K 9月  17 21:58 lost+found
-rw-r--r--. 2 root root 626K 9月  18 00:48 test3.log
-rw-r--r--. 2 root root 626K 9月  18 00:48 test5.log

2)、node1, node2    ------查看条带卷分布;大小被分片 

      

[root@node1 ~]# ll -h /dd
总用量 1.9M
drwx------ 2 root root  16K 9月  17 21:31 lost+found
-rw-r--r-- 2 root root 370K 9月  18 00:48 test1.log
-rw-r--r-- 2 root root 370K 9月  18 00:48 test2.log
-rw-r--r-- 2 root root 370K 9月  18 00:48 test3.log
-rw-r--r-- 2 root root 370K 9月  18 00:48 test4.log
-rw-r--r-- 2 root root 370K 9月  18 00:48 test5.log


     

[root@node2 ~]# ll -h /dd
总用量 1.3M
drwx------. 2 root root  16K 9月  17 21:58 lost+found
-rw-r--r--. 2 root root 256K 9月  18 00:48 test1.log
-rw-r--r--. 2 root root 256K 9月  18 00:48 test2.log
-rw-r--r--. 2 root root 256K 9月  18 00:48 test3.log
-rw-r--r--. 2 root root 256K 9月  18 00:48 test4.log
-rw-r--r--. 2 root root 256K 9月  18 00:48 test5.log

3)、node3,node4 -----查看复制卷分布;没有分片,原始大小

[root@node3 ~]# ll -h /dd/
总用量 3.2M
drwx------ 2 root root  16K 9月  17 22:05 lost+found
-rw-r--r-- 2 root root 626K 9月  18 00:48 test1.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test2.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test3.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test4.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test5.log


[root@node4 ~]# ll -h /dd/
总用量 3.2M
drwx------ 2 root root  16K 9月  17 22:09 lost+found
-rw-r--r-- 2 root root 626K 9月  18 00:48 test1.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test2.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test3.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test4.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test5.log

4)、node1~node4  查看分布式条带卷 -------大小被分片,同时又2份

[root@node1 ~]# ll -h /bb
总用量 1.2M
drwx------ 2 root root  16K 9月  17 21:30 lost+found
-rw-r--r-- 2 root root 370K 9月  18 00:48 test1.log
-rw-r--r-- 2 root root 370K 9月  18 00:48 test2.log
-rw-r--r-- 2 root root 370K 9月  18 00:48 test4.log

[root@node2 ~]# ll -h /bb
总用量 796K
drwx------. 2 root root  16K 9月  17 21:58 lost+found
-rw-r--r--. 2 root root 256K 9月  18 00:48 test1.log
-rw-r--r--. 2 root root 256K 9月  18 00:48 test2.log
-rw-r--r--. 2 root root 256K 9月  18 00:48 test4.log

[root@node3 ~]# ll -h /bb
总用量 768K
drwx------ 2 root root  16K 9月  17 22:05 lost+found
-rw-r--r-- 2 root root 370K 9月  18 00:48 test3.log
-rw-r--r-- 2 root root 370K 9月  18 00:48 test5.log

[root@node4 ~]# ll -h /bb
总用量 536K
drwx------ 2 root root  16K 9月  17 22:09 lost+found
-rw-r--r-- 2 root root 256K 9月  18 00:48 test3.log
-rw-r--r-- 2 root root 256K 9月  18 00:48 test5.log

5)、node1~node4  查看分布式复制卷文件分布---没有分片,原始大小,复制为2份

[root@node1 ~]# ll -h /cc
总用量 1.9M
drwx------ 2 root root  16K 9月  17 21:31 lost+found
-rw-r--r-- 2 root root 626K 9月  18 00:48 test1.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test2.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test4.log

[root@node2 ~]# ll -h /cc
总用量 1.9M
drwx------. 2 root root  16K 9月  17 21:58 lost+found
-rw-r--r--. 2 root root 626K 9月  18 00:48 test1.log
-rw-r--r--. 2 root root 626K 9月  18 00:48 test2.log
-rw-r--r--. 2 root root 626K 9月  18 00:48 test4.log

[root@node3 ~]# ll -h /cc
总用量 1.3M
drwx------ 2 root root  16K 9月  17 22:05 lost+found
-rw-r--r-- 2 root root 626K 9月  18 00:48 test3.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test5.log

[root@node4 ~]# ll -h /cc
总用量 1.3M
drwx------ 2 root root  16K 9月  17 22:09 lost+found
-rw-r--r-- 2 root root 626K 9月  18 00:48 test3.log
-rw-r--r-- 2 root root 626K 9月  18 00:48 test5.log

7、维护命令

 在node1上操作

7.1、查看glusterfs卷 

[root@node1 ~]# gluster volume list   #查看列表信息
dis-rep
dis-stripe
dis-volume
rep-volume
stripe-volume
[root@node1 ~]# gluster volume info   #查看所有卷信息
 
Volume Name: dis-rep
Type: Distributed-Replicate
Volume ID: dc84910e-4aa9-495c-b3ae-022458118e0b
Status: Started
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/cc
Brick2: node2:/cc
Brick3: node3:/cc
Brick4: node4:/cc
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
 
Volume Name: dis-stripe
Type: Distributed-Stripe
Volume ID: 1c123eee-7922-4b8f-9580-51c097b25812
Status: Started
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/bb
Brick2: node2:/bb
Brick3: node3:/bb
Brick4: node4:/bb
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
 
Volume Name: dis-volume
Type: Distribute
Volume ID: 6410d428-cf51-49d1-ace0-7060a12f1005
Status: Started
Snapshot Count: 0
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: node1:/ee
Brick2: node2:/ee
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
 
Volume Name: rep-volume
Type: Replicate
Volume ID: f79641fc-d89d-46b4-83c6-c3865783bf11
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node3:/dd
Brick2: node4:/dd
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
 
Volume Name: stripe-volume
Type: Stripe
Volume ID: 44f74bd4-5855-4117-a99e-a1dcd817fd18
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node1:/dd
Brick2: node2:/dd
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
[root@node1 ~]# gluster volume status       #查看卷的状态
Status of volume: dis-rep
Gluster process                             TCP Port  RDMA Port  Online  Pid
------------------------------------------------------------------------------
Brick node1:/cc                             49155     0          Y       2098 
Brick node2:/cc                             49155     0          Y       15382
Brick node3:/cc                             49154     0          Y       15307
Brick node4:/cc                             49154     0          Y       1927 
Self-heal Daemon on localhost               N/A       N/A        Y       2118 
Self-heal Daemon on node4                   N/A       N/A        Y       1947 
Self-heal Daemon on node3                   N/A       N/A        Y       15327
Self-heal Daemon on node2                   N/A       N/A        Y       15402
 
....................
.........

7.2、停止、删除卷

[root@node1 ~]# gluster volume stop dis-stripe      #停止  分布式条带卷
Stopping volume will make its data inaccessible. Do you want to continue? (y/n) n
[root@node1 ~]# gluster volume delete  dis-stripe      #删除    分布式条带卷
Deleting volume will erase all information about the volume. Do you want to continue? (y/n) n

7.3设置卷的访问控制

只允许192.168.1.0 和 10.1.1.0网段的客户端访问dis-rep卷

[root@node1 ~]# gluster volume set dis-rep auth.allow 192.168.1.*,10.1.1.*
volume set: success

复习题

1. GlusterFS的特点有哪些?

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

2. 什么是Brick?

Brick:指可信主机池中由主机提供的用于物理存储的专用分区,是GlusterFS中的基本存储单元,同时也是可信存储池中服务器上对外提供的存储目录

3. 弹性HASH算法的优点有哪些?

优点:保证数据平均分布在每个Brick中,解决了对元数据服务器的依赖,进而解决了单点故障及访问瓶颈

4. 写出GlusterFS七种卷的类型

类型:分布式卷、条带卷、复制卷、分布式条带卷、分布式复制卷、条带复制卷、分布式条带复制卷

5. GlusterFS七种卷中,具备冗余性的有哪些卷?

具备冗余性的有:复制卷、分布式复制卷

6. 写出条带卷的工作机制?

条带卷的工作机制:根据偏移量将文件分成N块(N个条带节点),轮询地存储在每个Brick Server节点

7. 写出启动GlusterFS的命令

systemctl start glusterd

8. 如何查看集群的状态?

查看状态:gluster peer status

9. 查看集群状态时显示Disconnected,可能的原因有哪些?

可能的原因:hosts文件配置错误

10. 创建复制卷和分布式复制卷在命令上的区别有哪些?

区别:在命令上的区别是多增加两个分区,在分布式复制卷中BRick所包含的存储服务器数必须是复制卷数的倍数(≥2倍)

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

乘浪初心

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值