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基金会开发.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群 ...
随机推荐
- hibernate之一对多映射
目录 第一章 课程简介 第二章 Hibernate中的单向一对多关联 2-1 一对多映射简介 2-2 hibernate的基础配置 2-3 创建HibernateUtil工具类 2-4 在mysql数 ...
- 通过JS的事件处理取得radio的值
转自:http://blog.sina.com.cn/s/blog_50a1e17401017pik.html 提前知识准备: 在一个HTML文档中,每个元素都可以设置ID和NAME属性. 其中ID属 ...
- sum求和类题目
今天看到这道题目:http://www.cnblogs.com/charlesblc/p/5930311.html 题目地址:https://leetcode.com/problems/split-a ...
- Android给定坐标计算距离
给定两点的经纬度.计算两点之间的距离.这里要注意经纬度一定要依照顺序填写 1. 利用android中的工具获得,单位是米 float[] results=new float[1]; Location. ...
- luogu1993 小K的农场
题目大意 小K在MC里面建立很多很多的农场,总共n个,以至于他自己都忘记了每个农场中种植作物的具体数量了,他只记得一些含糊的信息(共m个),以下列三种形式描述: 农场a比农场b至少多种植了c个单位的作 ...
- B1295 [SCOI2009]最长距离 最短路
就是一道最短路的裸题,直接跑spfa就行了.(spfa死了) 最后在答案处判断是否障碍物太多,然后就直接找最大值就行. (数据特别水,我错误算法60) 题干: Description windy有一块 ...
- 复习--二叉树&&树
树是一种很常用的数据结构,日后的学习中会经常碰到运用树的知识. //构造二叉树#include<cstdio> #include<iostream> #include<a ...
- IJ:ALI OSS 配置
ylbtech-IJ:ALI OSS 配置 1. src/resources/返回顶部 1.src/resources/ 1.1.aliyunoss.properties # oss\u7684\u5 ...
- 利用存储过程插入50W+数据
转自:https://www.aliyun.com/jiaocheng/1396184.html 首先,建立部门表和员工表: 部门表: create table dept( id int un ...
- 用SQL实现统计报表中的“小计”和“合计”
问题: 开发一个关于各烟叶等级的二次验级的原发件数.原发重量及验收重量的统计报表.其中,原发件数.原发重量和验收重量等列要求计算出各等级组别的小计和所有记录的合计. 语句: SELECT DECODE ...