GFS分布式文件系统(二)

简介: GFS分布式文件系统(二)

9.9 创建分布式条带卷

[root@node1 ~] # 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 ~] # gluster volume start dis-stripe
volume start: dis-stripe: success
[root@node1 ~] # gluster volume info dis-stripe
Volume Name: dis-stripe
Type: Distributed-Stripe
Volume ID: beb7aa78-78d1-435f-8d29-c163878c73f0
Status: Started
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/data/sdd1
Brick2: node2:/data/sdd1
Brick3: node3:/data/sdd1
Brick4: node4:/data/sdd1
Options Reconfigured:
transport.address-family: inet
nfs.disable: on


9.10 创建分布式复制卷

[root@node1 ~] # 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 ~] # gluster volume start dis-rep
volume start: dis-rep: success
[root@node1 ~] # gluster volume info dis-rep 
Volume Name: dis-rep
Type: Distributed-Replicate
Volume ID: 734e38e6-154c-4425-acca-2342577b14e7
Status: Started
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/data/sde1
Brick2: node2:/data/sde1
Brick3: node3:/data/sde1
Brick4: node4:/data/sde1
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
=======================
[root@node1 ~] # gluster volume list
dis-rep
dis-stripe
dis-volume
rep-volume
stripe-volume

9.11 部署gluster客户端

部署Gluster客户端(192.168.223.20)


[root@promote ~]#systemctl stop firewalld
[root@promote ~]#setenforce 0
[root@promote ~]#cd /opt
[root@promote opt]#ls
rh
[root@promote opt]#rz -E
rz waiting to receive.
[root@promote opt]#ls
gfsrepo.zip  rh
[root@promote opt]#unzip gfsrepo.zip 
[root@promote opt]#cd /etc/yum.repos.d/
[root@promote yum.repos.d]#ls
local.repo  repos.bak
[root@promote yum.repos.d]#mv *.repo repos.bak/
[root@promote yum.repos.d]#ls
repos.bak
[root@promote yum.repos.d]#vim glfs.repo
[glfs]
name=glfs
baseurl=file:///opt/gfsrepo
gpgcheck=0
enabled=1
========》wq
[root@promote yum.repos.d]#yum clean all && yum makecache
[root@promote yum.repos.d]#yum -y install glusterfs glusterfs-fuse
[root@promote yum.repos.d]#mkdir -p /test/{dis,stripe,rep,dis_stripe,dis_rep}
[root@promote yum.repos.d]#cd /test/
[root@promote test]#ls
dis  dis_rep  dis_stripe  rep  stripe
[root@promote test]#
[root@promote test]#echo "192.168.184.10 node1" >> /etc/hosts
[root@promote test]#echo "192.168.184.20 node2" >> /etc/hosts
[root@promote test]#echo "192.168.184.30 node3" >> /etc/hosts
[root@promote test]#echo "192.168.184.40 node4" >> /etc/hosts
[root@promote test]#
[root@promote test]#mount.glusterfs node1:dis-volume /test/dis
[root@promote test]#mount.glusterfs node1:stripe-volume /test/stripe
[root@promote test]#mount.glusterfs node1:rep-volume /test/rep
[root@promote test]#mount.glusterfs node1:dis-stripe /test/dis_stripe
[root@promote test]#mount.glusterfs node1:dis-rep /test/dis_rep
[root@promote test]#
[root@promote test]#df -h
文件系统             容量  已用  可用 已用% 挂载点
/dev/sda2             16G  3.5G   13G   22% /
devtmpfs             898M     0  898M    0% /dev
tmpfs                912M     0  912M    0% /dev/shm
tmpfs                912M   18M  894M    2% /run
tmpfs                912M     0  912M    0% /sys/fs/cgroup
/dev/sda5             10G   37M   10G    1% /home
/dev/sda1             10G  174M  9.9G    2% /boot
tmpfs                183M  4.0K  183M    1% /run/user/42
tmpfs                183M   40K  183M    1% /run/user/0
/dev/sr0             4.3G  4.3G     0  100% /mnt
node1:dis-volume     6.0G   65M  6.0G    2% /test/dis
node1:stripe-volume  8.0G   65M  8.0G    1% /test/stripe
node1:rep-volume     3.0G   33M  3.0G    2% /test/rep
node1:dis-stripe      21G  130M   21G    1% /test/dis_stripe
node1:dis-rep         11G   65M   11G    1% /test/dis_rep
[root@promote test]#cd /opt
[root@promote opt]#dd if=/dev/zero of=/opt/demo1.log bs=1M count=40
记录了40+0 的读入
记录了40+0 的写出
41943040字节(42 MB)已复制,0.0311576 秒,1.3 GB/秒
[root@promote opt]#dd if=/dev/zero of=/opt/demo2.log bs=1M count=40
记录了40+0 的读入
记录了40+0 的写出
41943040字节(42 MB)已复制,0.182058 秒,230 MB/秒
[root@promote opt]#dd if=/dev/zero of=/opt/demo3.log bs=1M count=40
记录了40+0 的读入
记录了40+0 的写出
41943040字节(42 MB)已复制,0.196193 秒,214 MB/秒
[root@promote opt]#dd if=/dev/zero of=/opt/demo4.log bs=1M count=40
记录了40+0 的读入
记录了40+0 的写出
41943040字节(42 MB)已复制,0.169933 秒,247 MB/秒
[root@promote opt]#dd if=/dev/zero of=/opt/demo5.log bs=1M count=40
记录了40+0 的读入
记录了40+0 的写出
41943040字节(42 MB)已复制,0.181712 秒,231 MB/秒
[root@promote opt]#
[root@promote opt]#ls -lh /opt
总用量 250M
-rw-r--r--. 1 root root  40M 3月   2 22:45 demo1.log
-rw-r--r--. 1 root root  40M 3月   2 22:45 demo2.log
-rw-r--r--. 1 root root  40M 3月   2 22:45 demo3.log
-rw-r--r--. 1 root root  40M 3月   2 22:45 demo4.log
-rw-r--r--. 1 root root  40M 3月   2 22:45 demo5.log
drwxr-xr-x. 3 root root 8.0K 3月  27 2018 gfsrepo
-rw-r--r--. 1 root root  50M 3月   2 10:30 gfsrepo.zip
drwxr-xr-x. 2 root root    6 3月  26 2015 rh
[root@promote opt]#
[root@promote opt]#cp demo* /test/dis
[root@promote opt]#cp demo* /test/stripe/
[root@promote opt]#cp demo* /test/rep/
[root@promote opt]#cp demo* /test/dis_stripe/
[root@promote opt]#cp demo* /test/dis_rep/
[root@promote opt]#cd /test/
[root@promote test]#tree
.
├── dis
│   ├── demo1.log
│   ├── demo2.log
│   ├── demo3.log
│   ├── demo4.log
│   └── demo5.log
├── dis_rep
│   ├── demo1.log
│   ├── demo2.log
│   ├── demo3.log
│   ├── demo4.log
│   └── demo5.log
├── dis_stripe
│   ├── demo1.log
│   ├── demo2.log
│   ├── demo3.log
│   ├── demo4.log
│   └── demo5.log
├── rep
│   ├── demo1.log
│   ├── demo2.log
│   ├── demo3.log
│   ├── demo4.log
│   └── demo5.log
└── stripe
    ├── demo1.log
    ├── demo2.log
    ├── demo3.log
    ├── demo4.log
    └── demo5.log
5 directories, 25 files



6、查看文件分布

6.1 查看分布式文件分布(node1:/dev/sdb1、node2:/dev/sdb1)

[root@node1 ~] # ls -lh /data/sdb1
总用量 160M
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo1.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo2.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo3.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo4.log
[root@node2 ~]#ll -h /data/sdb1
总用量 40M
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo5.log

6.2 查看条带卷文件分布(node1:/dev/sdc1、node2:/dev/sdc1)

[root@node1 ~] # ls -lh /data/sdc1
总用量 100M
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo1.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo2.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo3.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo4.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo5.log
[root@node2 ~]#ll -h /data/sdc1
总用量 100M
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo1.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo2.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo3.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo4.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo5.log

6.3 查看复制卷文件分布(node3:/dev/sdb1、node4:/dev/sdb1)

[root@node3 ~]#ll -h /data/sdb1
总用量 200M
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo1.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo2.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo3.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo4.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo5.log
[root@node4 ~]#ll -h /data/sdb1
总用量 200M
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo1.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo2.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo3.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo4.log
-rw-r–r–. 2 root root 40M 3月 2 22:46 demo5.log

6.4 查看分布式条带卷分布(node1:/dev/sdd1、node2:/dev/sdd1、node3:/dev/sdd1、

node4:/dev/sdd1)
[root@node1 ~] # ll -h /data/sdd1
总用量 60M
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo1.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo2.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo3.log
[root@node2 ~]#ll -h /data/sdd1
总用量 60M
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo1.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo2.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo3.log
[root@node3 ~]#ll -h /data/sdd1
总用量 40M
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo4.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo5.log
[root@node4 ~]#ll -h /data/sdd1
总用量 40M
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo4.log
-rw-r–r–. 2 root root 20M 3月 2 22:46 demo5.log



9.12 查看分布式复制卷分布(node1:/dev/sde1、node2:/dev/sde1、node3:/dev/sde1、

node4:/dev/sde1)
[root@node1 ~] # ll -h /data/sde1
总用量 160M
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo1.log
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo2.log
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo3.log
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo4.log
[root@node2 ~]#ll -h /data/sde1
总用量 160M
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo1.log
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo2.log
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo3.log
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo4.log
[root@node3 ~]#ll -h /data/sde1
总用量 40M
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo5.log
[root@node4 ~]#ll -h /data/sde1
总用量 40M
-rw-r--r--. 2 root root 40M 3月   2 22:46 demo5.log


十、冗余测试

在客户端(192.168.223.20)上查看文件是否正常


10.1分布式卷数据查看,缺少demo5,这是在node2上的,不具备冗余,挂起 node2 节点或者关闭

glusterd服务来模拟故障
[root@node2 ~]# init 0
[root@zabbix test]#ll /test/dis
总用量 163840
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo1.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo2.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo3.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo4.log
[root@promote test]#

10.2条带卷,无法访问,不具备冗余

[root@zabbix test]#ll /test/stripe/
总用量 0
[root@promote test]#

10.3复制卷,在node3和node4上的,关闭node4(192.168.184.40)进行测试,具有冗余

[root@node4 ~]#init 0
客户端,仍然存在
[root@zabbix test]#ll /test/rep/
总用量 204800
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo1.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo2.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo3.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo4.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo5.log
[root@promote test]#

10.4分布式条带卷,不具备冗余

[root@zabbix test]#ll /test/dis_stripe/
总用量 0

10.5分布式复制卷,具有冗余

[root@zabbix test]#ll /test/dis_rep/
总用量 204800
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo1.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo2.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo3.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo4.log
-rw-r--r--. 1 root root 41943040 3月   2 23:36 demo5.log
==以上,带有复制数据的,数据都比较安全 ==

十一、其他维护命令

1.查看GlusterFS卷

gluster volume list


2.查看所有卷的信息

gluster volume info


3.查看所有卷的状态

gluster volume status


4.停止一个卷

gluster volume stop dis-stripe


5.删除一个卷,注意:删除卷时,需要先停止卷,且信任池中不能有主机处于宕机状态,否则删除不成功

gluster volume delete dis-stripe


6.设置卷的访问控制

#仅拒绝

gluster volume set dis-rep auth.allow 192.168.184.100


#仅允许

gluster volume set dis-rep auth.allow 192.168.184.* #设置192.168.184.0网段的所有IP地址都能访问dis-rep卷(分布式复制卷)


十一、总结

①mysql服务器——>存储数据到挂载目录中/data


②mysql数据会优先交给内核的文件系统处理——>GFS客户端处理(本地)


③GFS客户端会和GFS服务端进行交互,GFS服务端接收到数据,然后再通过挂载的卷的类型,对应保存在后端block块节点服务器上


分布式条带复制卷(Distribute Stripe Replicavolume)三种基本卷的复合卷,通常用于类 Map Reduce 应用器——>存储数据到挂载目录中/data


相关文章
|
9月前
|
存储 运维 算法
GFS分布式文件系统
GFS分布式文件系统
108 0
|
17天前
|
存储 大数据 Linux
【大数据】GFS,大数据技术的基石,分布式文件系统的鼻祖
【大数据】GFS,大数据技术的基石,分布式文件系统的鼻祖
27 0
|
30天前
|
存储 分布式计算 算法
GFS 分布式文件系统
GFS 分布式文件系统
|
10月前
|
网络协议 Linux 网络安全
搭建GFS分布式文件系统
搭建GFS分布式文件系统
|
存储 分布式计算 负载均衡
GFS 分布式文件系统(上)
GlusterFS简介 a) GlusterFS是一-个开源的分布式文件系统。 由存储服务器、客户端以及NFS/Samba存储网关(可选,根据需要选择使用)组成。 无元数据服务器组件,这有助于提升整个系统的性能、可靠性和稳定性。
GFS 分布式文件系统(上)
|
存储 缓存 负载均衡
|
存储 网络安全
GFS分布式文件系统(光是遇见已经很美好了)(三)
GFS分布式文件系统(光是遇见已经很美好了)(三)
79 0
GFS分布式文件系统(光是遇见已经很美好了)(三)
|
存储 分布式计算 算法
GFS分布式文件系统(光是遇见已经很美好了)(二)
GFS分布式文件系统(光是遇见已经很美好了)(二)
212 0
GFS分布式文件系统(光是遇见已经很美好了)(二)
|
存储 算法 网络协议
GFS分布式文件系统(光是遇见已经很美好了)(一)
GFS分布式文件系统(光是遇见已经很美好了)(一)
271 0
GFS分布式文件系统(光是遇见已经很美好了)(一)
|
存储
GFS 分布式文件系统(下)
GlusterFS利用双重特性来提供高容量存储解决方案。
GFS 分布式文件系统(下)