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基金会开发.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群 ...
随机推荐
- 对SPI、IIC、IIS、UART、CAN、SDIO、GPIO的解释
SPI SPI(Serial Peripheral Interface:串行外设接口); SPI总线由三条信号线组成:串行时钟(SCLK).串行数据输出(SDO).串行数据输入(SDI).SPI总线可 ...
- 洛谷 P1479 宿舍里的故事之五子棋
P1479 宿舍里的故事之五子棋 题目描述 宿舍里好多好多有趣的事! 7890653今天看到不知何时流行的五子棋,在宿舍里拿个本子,画一些格子,一个棋盘就做好了! 当7890653把目光放到棋上,突发 ...
- linux系统读写缓存
1. 操作系统缓存 在linux世界里,一切可读写设备都可看作是文件.文件cache设计的好坏直接影响着文件系统和磁盘的性能.最直观的是使用free命令看到的cached列. 这里面的cached列 ...
- eclipse上导入import git项目
1.左上角File->import->git eclipse 可以从很多来源处import项目,项目来源可以使git/maven/general等. import来源可以看下面 2.点击g ...
- 查看编译器的默认include 路径
echo | gcc -v -x c++ -E - echo | g++ -v -x c++ -E - `gcc -print-prog-name=cc1plus` -v `g++ -print-pr ...
- volatile非原子性示例
volatile非原子性示例 学习了:<Java多线程编程核心技术>高洪岩 著 Page124 package com.stono.thread2.page124_2; public cl ...
- nyoj 1238 最少换乘 (河南省第八届acm程序设计大赛)
题目1238 题目信息 执行结果 本题排行 pid=1238" style="text-decoration:none; color:rgb(55,119,188)"&g ...
- UI层自动化测试框架(一)-简介和环境搭建
http://blog.csdn.net/ToBeTheEnder/article/details/52302777
- iOS 基础类解析 - NSString、NSMutableString
iOS 基础类解析 - NSString 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 ...
- 好记性不如烂笔头——DML/DDL/DCL/TCL,OLTP/OLAP
DML:数据操作语言,就是增删改之类的语句 DDL:数据定义语言,创建.修改.删除表等 ALTER 语句 (Transact-SQL) CREATE 语句 (Transact-SQL) DISABLE ...