最小化安装的centos7.5
内存大于1GB
关闭selinux,防火墙端口放行(port:24007,111)(测试建议关闭firewalld)

一、环境部署

所有软件包离线安装,原因是yum安装的不能很好的控制版,用到的软件包统一放到/gfs目录,包已整理好

链接:https://pan.baidu.com/s/1Xm-NJBEGEYnwYMMIIZaWFA

提取码:o0xp

  • 测试用的磁盘分配以及服务器架构图

  • basic代表服务器本来使用的磁盘,基础上再添加上图相应的磁盘,由于是测试用,为方便直观理解,磁盘大小就是后面的数字:如sdb3,该磁盘大小为3GB。

  • 卷的分布方案

卷名称 卷类型 空间大小/GB 存储块
dis-volume 分布式卷 12 node1(/sde6),node2(/sde6)
stripe-volume 条带卷 10 node1(/sdd5),node2(/sdd5)
rep-volume 复制卷 5 node3(/sdd5),node4(/sdd5)
dis-stripe 分布式条带卷 12 node1(/sdb3),node2(/sdb3),node3(/sdb3),node4(/sdb3)
dis-rep 分布式复制卷 8 node1(/sdc4),node2(/sdc4),node3(sdc4),node4(sdc4)
  • 全部主机修改主机名
  • 全部主机配置hosts文件,一样的
  • 全部node主机创建挂载文件夹,依实际挂载点创建
  • 全部主机创建/gfs文件夹,将所需软件包放入

mkdir /{gfs,sdb3,sdc4,sdd5}

cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.64.11 node1
192.168.64.12 node2
192.168.64.13 node3
192.168.64.14 node4
192.168.64.15 client
  • 完毕之后进行ping测试
  • 通过传输方式将软件包上传到/gfs文件(里面有一个repo文件夹也要上传)
  • 以上一切完成之后,全部node主机执行以下脚本
vim install.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/(.*)(.{3}):(.*)/mount \1\21 \/\2\3/' | bash
fdisk -l | grep -w "/dev/sd[b-z]" | sed -r 's/.*(\/d.{8}).*/\1/g' | sed -r 's/(.*)(.{3}):(.*)/\1\21 \/\2\3 xfs default 0 0/' >> /etc/fstab
#-w 只显示全字符合的列。
iptables -F
systemctl stop firewalld
setenforce 0 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
EOF

sh install.sh //执行脚本

netstat -lnpt //查看gluster服务端口是否开启

脚本简单理解

  • 再node1上执行如下命令构建gluster集群
[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 //在每个节点上执行查看集群状态;正常时为(Connected)

二、创建卷

1.创建分布式卷(扩大磁盘空间,读写速度快,没有容错能力)

[root@node1 ~]# gluster volume create dis-volume node1:/sde6 node2:/sde6 force //dis-volume为卷名称,未指定创建卷类型,默认为分布式卷

volume create: dis-volume: success: please start the volume to access data

[root@node1 ~]# gluster volume start dis-volume

volume start: dis-volume: success

[root@node1 ~]# gluster volume info dis-volume //查看该卷的相关信息

2.创建条带卷(以数据块为单位存储,没有容错性)

[root@node1 ~]# gluster volume create stripe-volume stripe 2 node1:/sdd5 node2:/sdd5 force

[root@node1 ~]# gluster volume start stripe-volume

volume start: stripe-volume: success

//stripe表示卷类型条带卷,后面的数量表示条带数

3.创建复制卷(磁盘空间为总空间一半,具备容错性,读快,写慢)

[root@node1 ~]# gluster volume create rep-volume replica 2 node3:/sdd5 node4:/sdd5 force

[root@node1 ~]# gluster volume start rep-volume

volume start: rep-volume: success

4.创建分布式条带卷(加大容量,读取快,没有容错性)

[root@node1 ~]# gluster volume create dis-stripe stripe 2 node1:/sdb3 node2:/sdb3 node3:/sdb3 node4:/sdb3 force

//指定类型为Distributed-Stripe,数值为2,而且后面跟了4个Brick Server,是2的2倍,所以创建的是分布式条带卷。

volume create: dis-stripe: success: please start the volume to access data

[root@node1 ~]# gluster volume start dis-stripe

volume start: dis-stripe: success

5.创建分布式复制卷(扩展空间,总空间的一半,且具有容错能力)

[root@node1 ~]# gluster volume create dis-rep replica 2 node1:/sdc4 node2:/sdc4 node3:/sdc4 node4:/sdc4/ force

//指定类型为Distributed-Replicate,数值为2,而且后面跟了4个Brick Server,是2的2倍,所以创建的是分布式复制卷。

volume create: dis-rep: success: please start the volume to access data

[root@node1 ~]# gluster volume start dis-rep

volume start: dis-rep: success

三、部署Gluster客户端

1.安装客户端软件
  • 将软件包放至/gfs文件夹
  • 修改前面提到的hostname以及hosts
  • 运行如下脚本
vim in_cl.sh
#!/bin/bash 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

sh in_cl.sh

netstat -lnpt | grep glu

//可以看到服务已经启动

[root@client ~]# mkdir -pv /test/{dis,stripe,rep,dis_stripe,dis_rep}

//创建挂载目录

[root@client ~]# mount -t glusterfs node1:dis-volume /test/dis

[root@client ~]# mount -t glusterfs node1:stripe-volume /test/stripe/

[root@client ~]# mount -t glusterfs node1:rep-volume /test/rep/

[root@client ~]# mount -t glusterfs node1:dis-stripe /test/dis_stripe/

[root@client ~]# mount -t glusterfs node1:dis-rep /test/dis_rep/

//挂载glusterfs文件系统到本地客户端,所制定的node1节点只是为了获取配置信息,不代表只和他进行数据传输,会根据配置针对集群来进行数据的存放

  • 修改fstab文件实现永久挂载
  • 添加如下文件

vim /etc/fstab

node1:dis-volume        /test/dis               glusterfs defaults,_netdev 0 0
node1:stripe-volume /test/stripe glusterfs defaults,_netdev 0 0
node1:rep-volume /test/rep glusterfs defaults,_netdev 0 0
node1:dis-rep /test/dis_rep glusterfs defaults,_netdev 0 0
node1:dis-stripe /test/dis_stripe glusterfs defaults,_netdev 0 0

四、测试

  • 生成测试文件(该文件虽没有数据,但是可以进行测试用途)

[root@client ~]# for i in {1..5};do dd if=/dev/zero of=/root/demon$i.log bs=1M count=43;done

[root@client ~]# cp demon* /test/dis && cp demon* /test/dis_rep/ && cp demon* /test/dis_stripe/ && cp demon* /test/rep/ && cp demon* /test/stripe/

  • 查看文件分布状态
  • 分布式卷(node1和node2的/sde6目录查看,可以看到文件被分散开存放)
[root@node1 ~]# ll -h /sde6/
总用量 130M
-rw-r--r--. 2 root root 43M 4月 2 21:32 demon1.log
-rw-r--r--. 2 root root 43M 4月 2 21:32 demon3.log
-rw-r--r--. 2 root root 43M 4月 2 21:32 demon4.log
drwx------. 2 root root 16K 4月 3 2019 lost+found
[root@node2 ~]# ll -h /sde6/
总用量 87M
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon2.log
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon5.log
drwx------. 2 root root 16K 4月 3 03:01 lost+found
  • 条带卷(node1和node2的/sdd5目录查看,清晰看到是以数据块为单位存储的)
[root@node1 ~]# ls -lh /sdd5/
总用量 108M
-rw-r--r--. 2 root root 22M 4月 2 21:31 demon1.log
-rw-r--r--. 2 root root 22M 4月 2 21:31 demon2.log
-rw-r--r--. 2 root root 22M 4月 2 21:31 demon3.log
-rw-r--r--. 2 root root 22M 4月 2 21:31 demon4.log
-rw-r--r--. 2 root root 22M 4月 2 21:31 demon5.log
[root@node2 ~]# ls -lh /sdd5/
总用量 108M
-rw-r--r--. 2 root root 22M 4月 3 05:31 demon1.log
-rw-r--r--. 2 root root 22M 4月 3 05:31 demon2.log
-rw-r--r--. 2 root root 22M 4月 3 05:31 demon3.log
-rw-r--r--. 2 root root 22M 4月 3 05:31 demon4.log
-rw-r--r--. 2 root root 22M 4月 3 05:31 demon5.log
  • 复制卷(node3和node4的/sdd5目录,数据有备份)
[root@node3 ~]# ls -lh /sdd5/
总用量 216M
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon1.log
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon2.log
-rw-r--r--. 2 root root 43M 4月 3 05:33 demon3.log
-rw-r--r--. 2 root root 43M 4月 3 05:33 demon4.log
-rw-r--r--. 2 root root 43M 4月 3 05:33 demon5.log
drwx------. 2 root root 16K 4月 3 03:03 lost+found
[root@node4 ~]# ls -lh /sdd5/
总用量 216M
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon1.log
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon2.log
-rw-r--r--. 2 root root 43M 4月 3 05:33 demon3.log
-rw-r--r--. 2 root root 43M 4月 3 05:33 demon4.log
-rw-r--r--. 2 root root 43M 4月 3 05:33 demon5.log
drwx------. 2 root root 16K 4月 3 02:55 lost+found
  • 分布式条带卷(节点1、2、3、4的/sdb3目录,我日期没有调整,海涵)
[root@node1 ~]# ls -lh /sdb3/
总用量 65M
-rw-r--r--. 2 root root 22M 4月 2 21:32 demon1.log
-rw-r--r--. 2 root root 22M 4月 2 21:32 demon3.log
-rw-r--r--. 2 root root 22M 4月 2 21:32 demon4.log
drwx------. 2 root root 16K 4月 2 18:37 lost+found
[root@node2 ~]# ls -lh /sdb3/
总用量 65M
-rw-r--r--. 2 root root 22M 4月 3 05:32 demon1.log
-rw-r--r--. 2 root root 22M 4月 3 05:32 demon3.log
-rw-r--r--. 2 root root 22M 4月 3 05:32 demon4.log
drwx------. 2 root root 16K 4月 3 03:01 lost+found
[root@node3 ~]# ls -lh /sdb3/
总用量 44M
-rw-r--r--. 2 root root 22M 4月 3 05:32 demon2.log
-rw-r--r--. 2 root root 22M 4月 3 05:32 demon5.log
drwx------. 2 root root 16K 4月 3 03:03 lost+found
[root@node4 ~]# ls -lh /sdb3/
总用量 44M
-rw-r--r--. 2 root root 22M 4月 3 05:32 demon2.log
-rw-r--r--. 2 root root 22M 4月 3 05:32 demon5.log
drwx------. 2 root root 16K 4月 3 02:55 lost+found
  • 分布式复制卷(节点1、2、3、4的/sdc4目录,可看到文件没有被分片,但是是分布开来存放的)
[root@node1 ~]# ls -lh /sdc4/
总用量 130M
-rw-r--r--. 2 root root 43M 4月 2 21:32 demon1.log
-rw-r--r--. 2 root root 43M 4月 2 21:32 demon3.log
-rw-r--r--. 2 root root 43M 4月 2 21:32 demon4.log
drwx------. 2 root root 16K 4月 3 2019 lost+found
[root@node2 ~]# ls -lh /sdc4/
总用量 130M
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon1.log
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon3.log
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon4.log
drwx------. 2 root root 16K 4月 3 03:01 lost+found
[root@node3 ~]# ls -lh /sdc4/
总用量 87M
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon2.log
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon5.log
drwx------. 2 root root 16K 4月 3 03:01 lost+found
[root@node4 ~]# ls -lh /sdc4/
总用量 87M
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon2.log
-rw-r--r--. 2 root root 43M 4月 3 05:32 demon5.log
drwx------. 2 root root 16K 4月 3 03:01 lost+found
破坏测试
  • 直接点关闭node2节点。关机操作。
  • 客户端操作
[root@client ~]# ls /test/dis/
demon1.log demon3.log demon4.log lost+found
//可以看到另外两个文件直接找不到了
[root@client ~]# ls /test/stripe/
[root@client ~]#
//条带卷因为文件都是分散开放,所以都没有了
[root@client ~]# ls /test/dis_stripe/
demon2.log demon5.log lost+found
//分布式条带卷,因为是分布式存储node2宕机导致数据不完整不会显示,1,3,4号文件丢失
[root@client ~]# ls /test/dis_rep/
demon1.log demon2.log demon3.log demon4.log demon5.log lost+found
//分布式复制卷完全不受任何影响
//总而言之,了解各卷的特点,再细心观察以下文件分布的具体位置,才能尽可能保证数据可靠性

五、维护命令

[root@node3 ~]# gluster volume list
dis-rep
dis-stripe
dis-volume
rep-volume
stripe-volume
//任何一个节点都可以查看集群列表
[root@node1 ~]# gluster volume info
//查看所有卷的信息
[root@node1 ~]# gluster volume status
//查看卷的状态
[root@node3 ~]# gluster volume stop dis-stripe
Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y
volume stop: dis-stripe: success
//停止卷
[root@node3 ~]# gluster volume start dis-stripe
//启动卷
[root@node3 ~]# gluster volume delete dis-stripe
//删除卷

GlusterFS群集存储项目的更多相关文章

  1. 去中心化存储项目终极指南 | Filecoin, Storj 和 PPIO 项目技术对比(下)

    在上篇文章中,我们主要从价值定位.技术层次架构.服务质量.去中心化程度,和经济激励机制五个方面分析了三个项目的不同.在这一篇文章中,我们将着重从区块链的架构设计.数据传输技术设计和数据存储技术设计三方 ...

  2. 去中心化存储项目终极指南 | Filecoin, Storj 和 PPIO 项目异同

    Filecoin,Storj 以及 PPIO 这三个存储公链的设计思路是不一样的,没有优劣之分,写这篇文章也并不是为了争论各项目的好坏对错.去中心化存储是一个长期商业赛道,不同团队在同一个赛道上往不同 ...

  3. GlusterFS数据存储脑裂修复方案最全解析

    本文档介绍了glusterfs中可用于监视复制卷状态的heal info命令以及解决脑裂的方法 一. 概念解析 常见术语 名称 解释 Brick GlusterFS 的基本存储单元,由可信存储池中服务 ...

  4. k8s使用glusterfs做存储

    一.安装glusterfs https://www.cnblogs.com/zhangb8042/p/7801181.html 环境介绍; centos 7 [root@k8s-m ~]# cat / ...

  5. logstash 使用glusterfs网络存储偶发性文件解析异常的问题

    其实问题到现在为止也没有解决 因为服务是部署在k8s上,挂载的,偶发性的出现文件解析异常 bom头已经验证过了 手动重新解析这些文件完全正常,问题无法复现,文件本身并没有问题. 最后怀疑到了最不该怀疑 ...

  6. NFS存储迁移至GlusterFS

    NFS存储迁移至GlusterFS 前提条件 为防止脑裂,建议使用最低3台节点制作3复制集的存储卷: 在进行存储迁移前,GluseterFS存储节点需先成为k8s集群中的node节点: 存储切换时请勿 ...

  7. Azure Storage 系列(二) .NET Core Web 项目中操作 Blob 存储

    一,引言 上一篇文章,我们介绍到在实际项目中系统会产生大量的日志文件,用户上传的头像等等,同时也介绍到可以使用Azure Blob Storage 来存储项目中的一些日志文件,用户头像,用户视频等等. ...

  8. openstack高可用集群15-后端存储技术—GlusterFS(分布式存储)

         

  9. Hyper-V 2012 R2 故障转移群集

    和终端用户相比,企业用户对于业务的连续性和可靠性更为在意.相对而言,企业一般不会将追逐单一硬件的性能排在第一位. 如何衡量业务是否持续可用,一般使用"x 个 9"这种方式来定义.如 ...

随机推荐

  1. Canvas引入跨域的图片导致toDataURL()报错的问题的解决

    本文介绍了Canvas引入跨域的图片导致toDataURL()报错的问题的解决,分享给大家,具体如下: [场景] 用户打开网页,则请求腾讯COS(图片服务器)上的图片js代码.使用canvas绘图. ...

  2. MARKY一下。

    答:其实RUP整个流程都在讲SQA.业界常见的模型,譬如CMM/CMMI,六西格玛,ISO9000,RUP,它们做的基本上是同一件事情--都是在做流程改进,都在做质量控制,但是各自的侧重点不一样.像R ...

  3. 【技术讨论】RF环境搭建手册

    (原创文章,转载请注明出处.) 简要整理下环境搭建的步骤,以便快速.准确的搭建测试环境. 一.环境搭建 一.Python 2.7 1. 不要用Python3.6,很多库3.6中还没有,wxPython ...

  4. June 30th. 2018, Week 26th. Saturday

    Curiosity is the wick in the candle of learning. 如果学习是一根蜡烛,那好奇心就是烛芯. From William Arthur Ward. Pleas ...

  5. 流行的报表生成工具-JXLS

    如果你还在为灵活的生成各种复杂报表犯愁,在为常用报表工具消耗大量内存担心.我推荐一个很好用的开源的Java报表生成工具. 本工具封装了强大的POI.但与POI不同的是,它可以用很简洁的代码生成复查的, ...

  6. Math类中round、ceil和floor方法的功能

    Java中的Math工具类用来完成除+.-.*./.%等基本运算以外的复杂运算,位于java.lang包下,Math类的构造器全是私有的(private),因此无法创建Math类的对象,Math类的方 ...

  7. Java基础重要知识点-反射

    反射,如何把.java文件转化为.class文件 JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法和属性:这种动态获取的信 ...

  8. service相关

    本篇仍以问题为驱动 一.什么时Service? Service是Android程序中四大基础组件之一,它和Activity一样都是Context的子类,只不过它没有UI界面,是在后台运行的组件.Ser ...

  9. h2engine游戏服务器设计之聊天室示例

    游戏服务器设计之聊天室示例 简介 h2engine引擎建群以后,有热心网友向我反馈,想尝试h2engine但是没有服务器开发经验觉得无从入手,希望我能提供一个简单明了的示例.由于前一段时间工作实在忙碌 ...

  10. 强化学习(四)用蒙特卡罗法(MC)求解

    在强化学习(三)用动态规划(DP)求解中,我们讨论了用动态规划来求解强化学习预测问题和控制问题的方法.但是由于动态规划法需要在每一次回溯更新某一个状态的价值时,回溯到该状态的所有可能的后续状态.导致对 ...