GFS分布式文件系统

单服务器:单硬盘存储--独立的一块硬盘存储数据,没有冗余性

磁盘阵列存储--Raid 0 , Raid 1 , Raid 5等,多块磁盘协同工作

Raid 0:由两块以上硬盘构成,将数据分成多个块,分散存储在各个硬盘中,提供高速读写,缺点:当任意硬盘损坏时,整个阵列将损坏,没有冗余性

Raid 1:由两块硬盘构成,对数据进行镜像复制,有冗余性,缺点:空间使用率较低50%,读写效率较低

镜像:数据同步复制过程,如果在主盘中删除数据,则镜像盘中的数据也会被删除

备份:制作数据文件的副本,不会随着原始数据的改变而发生变化

Raid 5:由三块以上的硬盘构成,硬盘之间交替进行数据冗余,空间利用率为N-1

LVM:逻辑卷,将参与的硬盘空间累加在一起,再从重新划分逻辑卷

存储服务器:独立存储服务器,有独立的机柜,有嵌入式操作系统,可以安装n块硬盘

群集存储:多任务存储进程解决方案,提供高并发连接,高速读写,数据冗余

安装部署GFS

环境:

4台node节点服务器,1台客户端(关闭防火墙和沙盒)

node1:192.168.6.20

node2:192.168.6.50

node3:192.168.6.70

node4:192.168.6.1

node客户端:192.168.6.22

1、配置节点服务器ip地址

2、修改节点服务器的计算机名

3、配置hosts文件(4台节点相同)

[root@localhost ~]# hostname node1

[root@localhost ~]# bash

[root@node1 ~]# vim /etc/hosts

添加:

192.168.1.1 node1

192.168.1.2 node2

192.168.1.3 node3

192.168.1.4 node4

4、安装软件(在所有节点上安装)

配置本地yum源(将gfsrepo中的所有内容复制到本地/meida目录下)

rm -rf /etc/yum.repos.d/*

vim /etc/yum.repos.d/yum.repo

[yum]

name=yum

baseurl=file:///media

enabled=1

gpgcheck=0

[root@node1 ~]# yum -y clean all

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

[root@node1 ~]# systemctl restart glusterd

[root@node1 ~]# systemctl enable glusterd

5、添加节点(只在node1上执行)

[root@node1 ~]# gluster peer probe node1

[root@node1 ~]# gluster peer probe node2

[root@node1 ~]# gluster peer probe node3

[root@node1 ~]# gluster peer probe node4

peer probe: success. Probe on localhost not needed

peer probe: success.

查看状态

[root@node1 ~]# gluster peer status

Number of Peers: 3

Hostname: node2

Uuid: cd887250-fb38-4428-9661-bd6f68df4e12

State: Peer in Cluster (Connected)

Hostname: node3

Uuid: e236db84-f605-445c-91ef-9637e7c2668e

State: Peer in Cluster (Connected)

Hostname: node4

Uuid: 8d2bed70-3efe-4f5f-b9a2-30accc66a2d6

State: Peer in Cluster (Connected)

6、安装客户端

[root@localhost /]# yum -y install glusterfs glusterfs-fuse

[root@localhost /]# mkdir -p /test/{dis,stripe,rep,dis-stripe,dis-rep}

[root@node1 ~]# vim /etc/hosts

添加:

192.168.6.20 node1

192.168.6.50 node2

192.168.6.70 node3

192.168.6.1 node4

7、在节点服务器上创建文件目录(所有节点上创建)

[root@node1 /]# mkdir data{1..5}

6、创建分布式卷(在node1操作)

使用node1和node2节点配置分布式卷:

[root@node1 /]# gluster volume create dis-volume node1:/data1 node2:/data1 force //dis-volume为分布式卷名

查看分布式卷信息:

[root@node1 /]# gluster volume info dis-volume

启用分布式卷:

[root@node1 /]# gluster volume start dis-volume

客户端操作:

挂载设备,并进行测试

[root@localhost /]# mount -t glusterfs node1:dis-volume /test/dis

[root@localhost /]# cd /test/dis

[root@localhost dis]# touch 1 2 3 4 5

[root@localhost dis]# touch 6 7 8 9 0

node1和node2节点上查看data1目录,进行验证就是分布式存储,并不会复制,存储位置随机

7、创建条带卷(在node1操作)

使用node1和node2节点配置条带卷:

[root@node1 /]# gluster volume create stripe-volume stripe 2 node1:/data2 node2:/data2 force

//stripe-volume为条带卷名称,stripe 2代表为两台服务器构建

查看条带卷信息:

[root@node1 /]# gluster volume info stripe-volume

启用条带卷:

[root@node1 /]# gluster volume start stripe-volume

客户端操作:

挂载设备,并进行测试

[root@localhost /]# mount -t glusterfs node1:stripe-volume /test/stripe

[root@localhost /]# cd /test/stripe

[root@localhost dis-stripe]# dd if=/dev/zero of=./aa bs=1M count=80

node1和node2节点上查看data2目录,进行验证

8、创建复制卷(在node1操作)

使用node1和node2节点配置复制卷:

[root@node1 /]# gluster volume create rep-volume replica 2 node1:/data3 node2:/data3 force

查看复制卷信息:

[root@node1 /]# gluster volume info rep-volume

启用复制卷:

[root@node1 /]# gluster volume start rep-volume

客户端操作:

挂载设备,并进行测试

[root@localhost /]# mount -t glusterfs node1:rep-volume /test/rep

[root@localhost /]# cd /test/rep

[root@localhost rep]# dd if=/dev/zero of=./bb bs=1M count=80

node1和node2节点上查看data3目录,进行验证

9、创建分布式条带卷(在node1操作)

使用node1、node2、node3、node4节点配置分布式条带卷(使用的节点服务器为偶数):

[root@node1 /]# gluster volume create dis-stripe stripe 4 node1:/data4 node2:/data4 node3:/data4 node4:/data4 force

查看分布式条带卷信息:

[root@node1 /]# gluster volume info dis-stripe

启用分布式条带卷:

[root@node1 /]# gluster volume start dis-stripe

客户端操作:

挂载设备,并进行测试

[root@localhost /]# mount -t glusterfs node1:dis-stripe /test/dis-stripe

[root@localhost /]# cd /test/dis-stripe

[root@localhost rep]# dd if=/dev/zero of=./cc bs=1M count=80

[root@localhost rep]# dd if=/dev/zero of=./dd bs=1M count=80

分别在4个节点上查看data4目录,进行验证

10、创建分布式复制卷(在node1操作)

使用node1、node2、node3、node4节点配置分布式复制卷:

[root@node1 /]# gluster volume create dis-rep replica 4 node1:/data5 node2:/data5 node3:/data5 node4:/data5 force

查看分布式复制卷信息:

[root@node1 /]# gluster volume info dis-rep

启用分布式复制卷卷:

[root@node1 /]# gluster volume start dis-rep

客户端操作:

挂载设备,并进行测试

[root@localhost /]# mount -t glusterfs node1:dis-rep /test/dis-rep

[root@localhost /]# cd /test/dis-rep

[root@localhost rep]# dd if=/dev/zero of=./ee bs=1M count=80

[root@localhost rep]# dd if=/dev/zero of=./ff bs=1M count=80

分别在4个节点上查看data5目录,进行验证

11、创建条带复制卷(在node1操作)  (在节点1-4里面继续创建data{6..100} 客户机创建目录)

使用node1、node2、node3、node4节点配置条带复制卷

[root@node1 /]# gluster volume create str-rep stripe 2 replica 2 node1:/data6 node2:/data6 node3:/data6 node4:/data6 force

查看条带复制卷信息:

[root@node1 /]# gluster volume info str-rep

启用条带复制卷卷:

[root@node1 /]# gluster volume start str-rep

客户端操作:

挂载设备,并进行测试

[root@localhost /]# mount -t glusterfs node1:str-rep /test/str-rep

[root@localhost /]# cd /test/str-rep

[root@localhost rep]# dd if=/dev/zero of=./gg bs=1M count=80

12、创建分布式条带复制卷(在node1操作)

使用node1、node2、node3、node4、node5、node6、node7、node8节点配置条带复制卷

[root@node1 /]# gluster volume create dis-str-rep stripe 2 replica 2 node1:/data6 node2:/data6 node3:/data6 node4:/data6 node5:/data6 node6:/data6 node7:/data6 node8:/data6force

查看条带复制卷信息:

[root@node1 /]# gluster volume info dis-str-rep

启用条带复制卷卷:

[root@node1 /]# gluster volume start dis-str-rep

客户端操作:

挂载设备,并进行测试

[root@localhost /]# mount -t glusterfs node1:dis-str-rep /test/dis-str-rep

[root@localhost /]# cd /test/dis-str-rep

[root@localhost rep]# dd if=/dev/zero of=./gg bs=1M count=80

13、客户端设置开机自动挂载

vim  /etc/fstab

添加:

node1:dis-volume  /test/dis  glusterfs   defaults,_netdev 0 0

node1:stripe-volume  /test/stripe  glusterfs   defaults,_netdev 0 0

node1:rep-volume  /test/rep  glusterfs   defaults,_netdev 0 0

node1:dis-stripe  /test/dis-stripe  glusterfs   defaults,_netdev 0 0

node1:dis-rep  /test/dis-rep  glusterfs   defaults,_netdev 0 0

14、破坏测试

断开node2节点,在客户端测试文件是否能够正常使用

客户端操作:

测试文件是否可以访问:

使用ll查看客户端目录中文件是否存在

分布式卷会丢失一部分数据

条带卷会丢失所有数据

复制卷没有丢失数据

分布式条带卷会丢失一部分数据

分布式复制卷没有丢失数据

条带复制卷没有丢失数据

15、查看glusterfs卷列表(任意节点上):

[root@node1 /]# gluster volume list

16、查看所有卷信息(任意节点上):

[root@node4 /]# gluster volume info

17、查看卷状态(任意节点上):

[root@node4 /]# gluster volume status

18、停止或删除卷

[root@node4 /]# gluster volume stop dis-volume

删除卷时,需要先停止卷,再删除。

[root@node4 /]# gluster volume delete dis-volume

19、设置卷访问控制

gluster volume set 卷名 auth.allow 192.168.10.10,192.168.20.*

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

数据库从删库到跑路

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

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

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

打赏作者

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

抵扣说明:

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

余额充值