GFS分布式文件系统环境部署与管理
Gluster分布式文件系统
准备环境五台虚拟机
创建/gfs目录,把软件包全部拷贝目录
把yum仓库的源放进bak下才能执行以下脚本
并指定主机名这四台机器都要执行脚本
[root@localhost ~]# mkdir /gfs
[root@localhost ~]# cd /gfs
把包放进/gfs下
Vim gfs.sh
#!/bin/bash
for i in $(fdisk -l | grep -wo "/dev/sd[b-z]" | sort)
do
dd if=/dev/zero of=$i bs=1024 count=1024
fdisk $i << EOF
n
p
w
EOF
partprobe $i
mkfs.ext4 ${i}1
done
mkdir /b3 /c4 /d5 /e6
fdisk -l | grep -w "/dev/sd[b-z]" | sed -r 's/.*(\/d.{8}).*/\1/g' | sed -r 's/(.*)(.):(.*)/mount \1\21 \/\2\3/' | bash
fdisk -l | grep -w "/dev/sd[b-z]" | sed -r 's/.*(\/d.{8}).*/\1/g' | sed -r 's/(.*)(.):(.*)/\1\21 \/\2\3 xf default 0 0/' >> /etc/fstab
iptables -F
systemctl stop firewalld
setenforce 0
cat << EOF >> /etc/hosts
192.168.30.21 node1
192.168.30.22 node2
192.168.30.23 node3
192.168.30.24 node4
EOF
cat << EOF >> /etc/yum.repos.d/gfs.repo
[gfs]
name=gfs
baseurl=file:///gfs
gpgcheck=0
enabled=1
EOF
yum clean all && yum makecache
yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma
systemctl start glusterd
systemctl enable glusterd
read -p "请输入主机名" hn
hostname $hn
bash
[root@node1 ~]# df -h
启动GlusterFS在所有节点执行
[root@node1 ~]# systemctl start glusterd
[root@node1 ~]# systemctl enable glusterd
添加节点,只在node1上执行操作,添加node1-node4节点
[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.
查看集群状态
[root@node1 ~]# gluster peer status
Number of Peers: 3
Hostname: node2
Uuid: b2c6fb38-6d87-4f0e-8ec2-cac17abdb51a
State: Peer in Cluster (Connected)
Hostname: node3
Uuid: d8ca1764-5370-49bb-9c6e-02028fbb2c3a
State: Peer in Cluster (Connected)
Hostname: node4
Uuid: 7f480c33-7b11-4785-a718-b54ea10bc82c
State: Peer in Cluster (Connected)
创建卷
1,创建分布式卷
[root@node1 ~]# gluster volume create dis-volume node1:/e6 node2:/e6 force
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: 07b832ed-d8ee-4982-a6fc-8ee646739fa0
Status: Created
Snapshot Count: 0
Number of Bricks: 2
Transport-type: tcp
Bricks:
Brick1: node1:/e6
Brick2: node2:/e6
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
[root@node1 ~]# gluster volume start dis-volume
volume start: dis-volume: success
没有执行类型,默认创建的是分布式卷
2,创建条带卷
[root@node1 ~]# gluster volume create stripe-volume stripe 2 node1:/d5 node2:/d5 force
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: 9eea0fc5-6809-4910-b996-c4c70a32e7e9
Status: Created
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node1:/d5
Brick2: node2:/d5
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
[root@node1 ~]# gluster volume start stripe-volume
指定类型为stripe,数值为2,而且后面跟了2个Brick serer 所有创建的是条带卷
3,创建复制卷
[root@node1 ~]# gluster volume create rep-volume replica 2 node3:/d5 node4:/d5 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: 923fb5ea-edf1-4cf3-8154-1e85328ff605
Status: Created
Snapshot Count: 0
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: node3:/d5
Brick2: node4:/d5
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
[root@node1 ~]# gluster volume start rep-volume
volume start: rep-volume: success
指定类型为replica,数值为2,而且后面跟了2个Brick server 所有创建的是复制卷
4,创建分布式条带卷
[root@node1 ~]# gluster volume create dis-stripe stripe 2 node1:/b3 node2:/b3 node3:/b3 node4:/b3 force
volume create: dis-stripe: success: please start the volume to access data
[root@node1 ~]# gluster volume info rep-stripe
Volume rep-stripe does not exist
[root@node1 ~]# gluster volume info dis-stripe
Volume Name: dis-stripe
Type: Distributed-Stripe
Volume ID: 616c1a3a-3e95-42e6-820a-36e61af92776
Status: Created
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/b3
Brick2: node2:/b3
Brick3: node3:/b3
Brick4: node4:/b3
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:/c4 node2:/c4 node3:/c4 node4:/c4 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: f0a97902-8c26-4d91-8478-cd7d9d11c7b5
Status: Created
Snapshot Count: 0
Number of Bricks: 2 x 2 = 4
Transport-type: tcp
Bricks:
Brick1: node1:/c4
Brick2: node2:/c4
Brick3: node3:/c4
Brick4: node4:/c4
Options Reconfigured:
transport.address-family: inet
nfs.disable: on
[root@node1 ~]# gluster volume start dis-rep
volume start: dis-rep: success
部署Gluster客户端
把软件包都放进去,然后把yum源藏一下
[root@zhao ~]# vim gfs.sh
#!/bin/bash
iptables -F
systemctl stop firewalld
setenforce 0
cat << EOF >> /etc/hosts
192.168.30.21 node1
192.168.30.22 node2
192.168.30.23 node3
192.168.30.24 node4
EOF
cat << EOF >> /etc/yum.repos.d/gfs.repo
[gfs]
name=gfs
baseurl=file:///gfs
gpgcheck=0
enabled=1
EOF
yum clean all && yum makecache
yum -y install glusterfs glusterfs-fuse
systemctl start glusterd
systemctl enable glusterd
read -p "请输入主机名: " hn
hostname $hn
bash
创建挂载目录
[root@zhao ~]# mkdir -p /test/{dis,stripe,rep,dis_and_stripe,dis_and_rep}
[root@zhao ~]# ls /test
dis dis_and_rep dis_and_stripe rep stripe
修改hosts文件
[root@zhao ~]# tail -4 /etc/hosts
192.168.30.21 node1
192.168.30.22 node2
192.168.30.23 node3
192.168.30.24 node4
挂载Gluster文件系统
[root@zhao ~]# mount -t glusterfs node1:dis-volume /test/dis
[root@zhao ~]# mount -t glusterfs node1:stripe-volume /test/stripe
[root@zhao ~]# mount -t glusterfs node1:rep-volume /test/rep/
[root@zhao ~]# mount -t glusterfs node1:dis-stripe /test/dis_and_stripe/
[root@zhao ~]# mount -t glusterfs node1:dis-rep /test/dis_and_rep
修改fstab配置文件
node1:dis-volume /test/dis glusterfs defaults,_netdev 0 0
node1:stripe-volume /test/stripe glusterfs defaults,_netdev 00
node1:rep-volume /test/rep glusterfs defaults,_netdev 0 0
node1:dis-rep /test/dis_and_rep glusterfs defaults,_netdev 0 0
node1:dis-stripe /test/dis_and_stripe glusterfs defaults,_netdev 0 0
[root@zhao ~]# for i in {1..5};do dd if=/dev/zero of=/root/demon$i.log bs=1M count=43;done
测试Gluster文件系统
1、卷中写入文件
[root@zhao ~]# ls -lh demo*
-rw-r--r--. 1 root root 43M 4月 25 15:27 demon1.log
-rw-r--r--. 1 root root 43M 4月 25 15:27 demon2.log
-rw-r--r--. 1 root root 43M 4月 25 15:27 demon3.log
-rw-r--r--. 1 root root 43M 4月 25 15:27 demon4.log
-rw-r--r--. 1 root root 43M 4月 25 15:27 demon5.log
[root@zhao ~]# cp demon* /test/dis
[root@zhao ~]# cp demon* /test/stripe/
[root@zhao ~]# cp demon* /test/rep
[root@zhao ~]# cp demon* /test/dis_and_stripe
[root@zhao ~]# cp demon* /test/dis_and_rep
查看文件分布
下面查看分布式卷文件分布
在node1上去操作
[root@node1 ~]# ll -h /e6
总用量 130M
-rw-r--r--. 2 root root 43M 4月 25 15:28 demon1.log
-rw-r--r--. 2 root root 43M 4月 25 15:28 demon3.log
-rw-r--r--. 2 root root 43M 4月 25 15:28 demon4.log
[root@node2 ~]# ll -h /e6
总用量 87M
-rw-r--r--. 2 root root 43M 4月 25 15:28 demon2.log
-rw-r--r--. 2 root root 43M 4月 25 15:28 demon5.log
下面查看条带卷文件分布:
[root@node1 ~]# ll -h /d5
总用量 108M
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon1.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon2.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon3.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon4.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon5.log
[root@node2 ~]# ll -h /d5
总用量 108M
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon1.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon2.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon3.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon4.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon5.log
下面查看复制卷文件分布
[root@node3 ~]# ll -h /d5
总用量 216M
-rw-r--r--. 2 root root 43M 4月 25 23:29 demon1.log
-rw-r--r--. 2 root root 43M 4月 25 23:29 demon2.log
-rw-r--r--. 2 root root 43M 4月 25 23:29 demon3.log
-rw-r--r--. 2 root root 43M 4月 25 23:29 demon4.log
-rw-r--r--. 2 root root 43M 4月 25 23:29 demon5.log
[root@node4 ~]# ll -h /d5
总用量 216M
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon1.log
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon2.log
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon3.log
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon4.log
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon5.log
下面查看分布式条带卷文件分布
[root@node1 ~]# ll -h /b3
总用量 65M
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon1.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon3.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon4.log
[root@node2 ~]# ll -h /b3
总用量 65M
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon1.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon3.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon4.log
[root@node3 ~]# ll -h /b3
总用量 44M
-rw-r--r--. 2 root root 22M 4月 25 23:29 demon2.log
-rw-r--r--. 2 root root 22M 4月 25 23:29 demon5.log
[root@node4 ~]# ll -h /b3
总用量 44M
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon2.log
-rw-r--r--. 2 root root 22M 4月 25 15:29 demon5.log
下面查看分布式复制卷文件分布:
[root@node1 ~]# ll -h /c4
总用量 130M
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon1.log
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon3.log
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon4.log
[root@node2 ~]# ll -h /c4
总用量 130M
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon1.log
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon3.log
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon4.log
[root@node3 ~]# ll -h /c4
总用量 87M
-rw-r--r--. 2 root root 43M 4月 25 23:29 demon2.log
-rw-r--r--. 2 root root 43M 4月 25 23:29 demon5.log
[root@node4 ~]# ll -h /c4
总用量 87M
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon2.log
-rw-r--r--. 2 root root 43M 4月 25 15:29 demon5.log
破坏性测试
挂起node2节点,在客户端上测试文件是否可以正常使用
[root@zhao ~]# head -1 /test/dis/demon2.log
head: 无法打开"/test/dis/demon2.log" 读取数据: 没有那个文件或目录
[root@zhao ~]# head -1 /test/dis/demon3.log
^C
[root@zhao ~]# head -1 /test/dis/demon4.log
^C[root@zhao ~]# head -1 /test/dis/demon5.log
head: 无法打开"/test/dis/demon5.log" 读取数据: 没有那个文件或目录
分布在node2节点上的demon2.log和demon5.log 无法访问,分布式卷不具备冗余性
测试条带卷数据是否可以正常访问
[root@zhao ~]# head -1 /test/stripe/demon1.log
head: 读取"/test/stripe/demon1.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/stripe/demon2.log
head: 读取"/test/stripe/demon2.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/stripe/demon3.log
head: 读取"/test/stripe/demon3.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/stripe/demon4.log
head: 读取"/test/stripe/demon4.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/stripe/demon5.log
head: 读取"/test/stripe/demon5.log" 时出错: 没有那个文件或目录
node2节点挂起后,所有数据全部丢失
测试分布式条带卷数据是否可以访问
[root@zhao ~]# head -1 /test/dis_and_stripe/demon1.log
head: 读取"/test/dis_and_stripe/demon1.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/dis_and_stripe/demon2.log
^C
[root@zhao ~]# head -1 /test/dis_and_stripe/demon3.log
head: 读取"/test/dis_and_stripe/demon3.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/dis_and_stripe/demon4.log
head: 读取"/test/dis_and_stripe/demon4.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/dis_and_stripe/demon5.log
node2节点挂起后,分布在node1和node2节点的数据丢失,而分布在node3和node4节点
的数据不丢失
测试分布式复制卷数据是否可以访问:
[root@zhao ~]# head -1 /test/dis_and_rep/demon5.log
^C
[root@zhao ~]# head -1 /test/dis_and_rep/demon4.log
^C
[root@zhao ~]# head -1 /test/dis_and_rep/demon3.log
^C
[root@zhao ~]# head -1 /test/dis_and_rep/demon2.log
^C
[root@zhao ~]# head -1 /test/dis_and_rep/demon1.log
node2节点挂起后,数据不丢失
继续挂起node4节点,在客户端上测试文件是否可以正常使用。
测试复制卷数据
[root@zhao ~]# head -1 /test/rep/demon1.log
[root@zhao ~]# head -1 /test/rep/demon2.log
[root@zhao ~]# head -1 /test/rep/demon3.log
[root@zhao ~]# head -1 /test/rep/demon4.log
[root@zhao ~]# head -1 /test/rep/demon5.log
是否可以访问:
node2和node4节点挂起后,数据不丢失
测试分布式条带卷数据是否可以访问:
[root@zhao ~]# head -1 /test/dis_and_stripe/demon1.log
head: 读取"/test/dis_and_stripe/demon1.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/dis_and_stripe/demon2.log
head: 读取"/test/dis_and_stripe/demon2.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/dis_and_stripe/demon3.log
head: 读取"/test/dis_and_stripe/demon3.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/dis_and_stripe/demon4.log
head: 读取"/test/dis_and_stripe/demon4.log" 时出错: 没有那个文件或目录
[root@zhao ~]# head -1 /test/dis_and_stripe/demon5.log
head: 读取"/test/dis_and_stripe/demon5.log" 时出错: 没有那个文件或目录
测试分布式复制卷数据是否可以访问:
[root@zhao ~]# tail -1 /test/dis_and_rep/demon1.log
^C
[root@zhao ~]# tail -1 /test/dis_and_rep/demon2.log
^C
[root@zhao ~]# tail -1 /test/dis_and_rep/demon3.log
^C
[root@zhao ~]# tail -1 /test/dis_and_rep/demon4.log
^C
[root@zhao ~]# tail -1 /test/dis_and_rep/demon5.log
node2和node4节点挂起后,数据不丢失
GFS分布式文件系统环境部署与管理的更多相关文章
- GFS分布式文件系统理论个人总结
GlusterFS 两种模式 可以通过TCP/IP和RDMA高速网络互连,客户端可通过原生Gluster协议访问数据 没有GlusterFS客户端的可以通过NFS/CIFS标准协议通过存储网关访问数据 ...
- Centos7下GlusterFS 分布式文件系统环境搭建
Centos7下 GlusterFS 环境搭建准备工作glusterfs-3.6.9.tar.gzuserspace-rcu-master.zip三台服务器:192.168.133.53.192.16 ...
- 一文搞定FastDFS分布式文件系统配置与部署
Ubuntu下FastDFS分布式文件系统配置与部署 白宁超 2017年4月15日09:11:52 摘要: FastDFS是一个开源的轻量级分布式文件系统,功能包括:文件存储.文件同步.文件访问(文件 ...
- 【精华】部署与管理ZooKeeper(转)
部署与管理ZooKeeper(转) 本文以ZooKeeper3.4.3版本的官方指南为基础:http://zookeeper.apache.org/doc/r3.4.3/zookeeperAdmin. ...
- GFS 分布式文件系统
GFS 分布式文件系统 1.GlusterFS概述 : GlusterFS简介 a) GlusterFS是一-个开源的分布式文件系统. 由存储服务器.客户端以及NFS/Samba存储网关(可选,根据 ...
- 淘宝分布式文件存储系统:TFS
TFS ——分布式文件存储系统 TFS(Taobao File System)是淘宝针对海量非结构化数据存储设计的分布式系统,构筑在普通的Linux机器集群上,可为外部提供高可靠和高并发的存储访问. ...
- .Net平台下,分布式文件存储的实现
遇到的问题 对于Web程序,使用一台服务器的时候,客户端上传的文件一般也都是存储在这台服务器上.但在集群环境中就行不通了,如果每个服务器都存储自己接受到的文件,就乱套了,数据库中明明有这个附件的记录, ...
- Memcached 分布式缓存系统部署与调试
Memcache 分布式缓存系统部署与调试 工作机制:通过在内存中开辟一块区域来维持一个大的hash表来加快页面访问速度,和数据库是独立的;目前主要用来缓存数据库的数据;存放在内存的数据通过LRU算法 ...
- Hadoop HDFS分布式文件系统设计要点与架构
Hadoop HDFS分布式文件系统设计要点与架构 Hadoop简介:一个分布式系统基础架构,由Apache基金会开发.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群 ...
随机推荐
- nyoj_655_光棍的yy_201311281539
光棍的yy 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 yy经常遇见一个奇怪的事情,每当他看时间的时候总会看见11:11,这个很纠结啊. 现在给 ...
- nyoj_111_分数加减法_201311281341
分数加减法 时间限制:3000 ms | 内存限制:65535 KB 难度:2 描述 编写一个C程序,实现两个分数的加减法 输入 输入包含多行数据 每行数据是一个字符串, ...
- Cookie && Session && Token
Cookies Cookie的由来: HTTP 本身是一个无状态的 request/response 协议. server接收一个来自client的request, 处理完以后返回一个response ...
- Project Euler:Problem 33 Digit cancelling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...
- 卸载完百度影音以后天气助手还在,而且总是自己主动打开ie浏览器,解决方式
今天暴风影音不好用了.我就安装了百度影音,还有意外发现.相同的视频,用百度影音看不清楚,然后我就直接卸载了.结果卸掉以天气小助手还是在,而且总弹白色小框框,各种广告.最忍不了的是还自己主动打开ie浏览 ...
- hdu 4932 Miaomiao's Geometry(暴力枚举)
pid=4932">Miaomiao's Geometry ...
- 新随笔(三)什么时候使用button,什么时候使用文字链接
新随笔(三)什么时候使用button.什么时候使用文字链接 你为什么在这个地方用button而不用文字链接呢? 这是刚才我问一个设计师的问题. 她抬头看我,眼神迷茫.说:"没什么为什么呀,我 ...
- luogu1006 传纸条
题目大意 小渊坐在矩阵的左上角,坐标 (1,1 ),小轩坐在矩阵的右下角,坐标 (m,n) .从小渊传到小轩的纸条只可以向下或者向右传递,从小轩传给小渊的纸条只可以向上或者向左传递. 在活动进行中,小 ...
- B1922 [Sdoi2010]大陆争霸 最短路
我一直都不会dij的堆优化,今天搞了一下...就是先弄一个优先队列,存每个点的数据,然后这个题就加了一点不一样的东西,每次的最短路算两次,一次是自己的最短路,另一次是机关的最短路,两者取最大值才是该点 ...
- 82.角色管理Extjs 页面
1. <%@ page language="java" import="java.util.*" pageEncoding="UTF-8&quo ...