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基金会开发.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群 ...
随机推荐
- [bzoj2743][HEOI2012]采花_树状数组
采花 bzoj-2743 HEOI-2012 题目大意:给定n朵花,每朵花有一个种类,m次询问:一段区间中至少出现两朵花的种类的个数. 注释:$1\le n,m\le10^6$. 想法:这个题超级像H ...
- 洛谷 P1120 小木棍 [数据加强版]
P1120 小木棍 [数据加强版] 题目描述 乔治有一些同样长的小木棍,他把这些木棍随意砍成几段,直到每段的长都不超过50. 现在,他想把小木棍拼接成原来的样子,但是却忘记了自己开始时有多少根木棍和它 ...
- gap lock/next-key lock浅析Basic-Paxos协议日志同步应用
http://www.cnblogs.com/renolei/p/4673842.html 当InnoDB在判断行锁是否冲突的时候, 除了最基本的IS/IX/S/X锁的冲突判断意外, InnoDB还将 ...
- jquery easyui datagrid实现数据改动
1.单击选中待改动行 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA= ...
- [Angular] Using ngTemplateOutlet to create dynamic template
I can use <tamplete> syntax and a entry component as a container to create a dynamic component ...
- [Android L or M ]解除SwitchPreference与Preference的绑定事件
需求描写叙述 默认情况,Android的两个控件SwitchPreference和CheckBoxPreference的事件处理是和Preference整个区域的事件绑定在一起的,然而,有时须要将其事 ...
- 蒟蒻的数位DP专题总结
BZOJ 1026: [SCOI2009]windy数: 题目链接: http://www.lydsy.com/JudgeOnline/problem.php?id=1026 d ...
- C# Interactive Walkthrough
C# Interactive Walkthrough
- KD树——k=1时就是BST,里面的数学原理还是有不明白的地方,为啥方差划分?
Kd-Tree,即K-dimensional tree,是一棵二叉树,树中存储的是一些K维数据.在一个K维数据集合上构建一棵Kd-Tree代表了对该K维数据集合构成的K维空间的一个划分,即树中的每个结 ...
- 【POJ 3074】 Sudoku
[题目链接] http://poj.org/problem?id=3074 [算法] 将数独问题转化为精确覆盖问题,用Dancing Links求解 转化方法如下 : 我们知道,在一个数独中 : 1. ...