GFS分布式文件系統(tǒng)集群(實例!!!)-創(chuàng)新互聯(lián)

GlusterFS概述

 開源的分布式文件系統(tǒng)
 由存儲服務(wù)器、客戶端以及NFS/Samba存儲網(wǎng)關(guān)組成
 無元數(shù)據(jù)服務(wù)器(數(shù)據(jù)傳輸組件RDMA)

GFS分布式文件系統(tǒng)集群(實例!!!)

創(chuàng)新互聯(lián)自成立以來,一直致力于為企業(yè)提供從網(wǎng)站策劃、網(wǎng)站設(shè)計、網(wǎng)站設(shè)計制作、做網(wǎng)站、電子商務(wù)、網(wǎng)站推廣、網(wǎng)站優(yōu)化到為企業(yè)提供個性化軟件開發(fā)等基于互聯(lián)網(wǎng)的全面整合營銷服務(wù)。公司擁有豐富的網(wǎng)站建設(shè)和互聯(lián)網(wǎng)應(yīng)用系統(tǒng)開發(fā)管理經(jīng)驗、成熟的應(yīng)用系統(tǒng)解決方案、優(yōu)秀的網(wǎng)站開發(fā)工程師團(tuán)隊及專業(yè)的網(wǎng)站設(shè)計師團(tuán)隊。

GlusterFS特點

 擴(kuò)展性、高性能、高可用性
 全局統(tǒng)一命名空間
 彈性卷管理---->云的特性:水平(實例數(shù))、垂直(硬件性能)
ECS(虛擬)、OSS和RDS(裸金屬)
 基于標(biāo)準(zhǔn)協(xié)議

GlusterFS術(shù)語

 Brick(節(jié)點)
 Volume(卷)
 FUSE(用戶端交互模塊)
 VFS(虛擬化文件系統(tǒng))
 Glusterd(服務(wù))

模塊化堆棧式架構(gòu)

 模塊化、堆棧式的架構(gòu)
 通過對模塊的組合,實現(xiàn)復(fù)雜的功能

GFS分布式文件系統(tǒng)集群(實例!!!)

GlusterFS工作原理

GlusterFS工作流程

GFS分布式文件系統(tǒng)集群(實例!!!)

彈性HASH算法

 通過HASH算法得到一個32位的整數(shù)
 劃分為N個連續(xù)的子空間,每個空間對應(yīng)一個Brick
 彈性HASH算法的優(yōu)點:
保證數(shù)據(jù)平均分布在每一個Brick中
解決了對元數(shù)據(jù)服務(wù)器的依賴,進(jìn)而解決了單點故障以及訪問瓶頸

GlusterFS的卷類型

1.分布式卷(fastdfs和gfs搭建)

沒有對文件進(jìn)行分塊處理
通過擴(kuò)展文件屬性保存HASH值
支持的底層文件系統(tǒng)有ext3、ext4、 ZFS、 XFS等

GFS分布式文件系統(tǒng)集群(實例!!!)
分布式卷的特點

●文件分布在不同的服務(wù)器,不具備冗余性
●更容易和廉價地擴(kuò)展卷的大小
●單點故障會造成數(shù)據(jù)丟失
●依賴底層的數(shù)據(jù)保護(hù)

2.條帶卷

●根據(jù)偏移量將文件分成N塊(N個條帶節(jié)點),輪詢的存儲在每個Brick
Server節(jié)點
●存儲大文件時,性能尤為突出
●不具備冗余性,類似Raid0

條帶卷的特點

●數(shù)據(jù)被分割成更小塊分布到塊服務(wù)器群中的不同條帶區(qū)
●分布減少了負(fù)載且更小的文件加速了存取的速度
●沒有數(shù)據(jù)冗余

GFS分布式文件系統(tǒng)集群(實例!!!)

3. 復(fù)制卷

●同一文件保存一份或多分副本
●復(fù)制模式因為要保存副本,所以磁盤利用率較低
●多個節(jié)點上的存儲空間不一致, 那么將按照木桶效應(yīng)取最低節(jié)點的容量
●作為該卷的總?cè)萘?/code>

復(fù)制卷的特點

●卷中所有的服務(wù)器均保存一個完整的副本
●卷的副本數(shù)量可由客戶創(chuàng)建的時候決定
●至少由兩個塊服務(wù)器或更多服務(wù)器
●具備冗余性

GFS分布式文件系統(tǒng)集群(實例!!!)

4.分布式條帶卷

●兼顧分布式卷和條帶卷的功能
●主要用于大文件訪問處理
●至少最少需要4臺服務(wù)器

5.分布式復(fù)制卷

●兼顧分布式卷和復(fù)制卷的功能
●用于需要冗余的情況下

GFS分布式文件系統(tǒng)集群(實例!!!)

群集環(huán)境

GFS分布式文件系統(tǒng)集群(實例!!!)

卷類型

卷名稱 卷類型 空間大小 Brick
dis-volume分布式卷40Gnode1(/b1)、node2(/b1)
stripe-volume條帶卷40Gnode1(/c1)、node2(/c1)
rep-volume復(fù)制卷20Gnode3(/b1)、node4(/b1)
dis-stripe分布式條帶卷40Gnode1(/d1)、node2(/d1)、node3(/d1)、node4(/d1)
dis-rep分布式復(fù)制卷20Gnode1(/e1)、node2(/e1)、node3(/e1)、node4(/e1)

實驗準(zhǔn)備

1、為四臺服務(wù)器服務(wù)器每臺添加4個磁盤

GFS分布式文件系統(tǒng)集群(實例!!!)

2、修改服務(wù)器的名稱

分別修改為node1、node2、node3、node4

[root@localhost ~]#hostnamectl set-hostname node1
[root@localhost ~]# su
3、將四臺服務(wù)器上的磁盤格式化,并掛載

在這里我們使用腳本執(zhí)行掛載

#進(jìn)入opt目錄
[root@node1 ~]# cd /opt
#磁盤格式化、掛載腳本
[root@node1 opt]# vim a.sh
#! /bin/bash
echo "the disks exist list:"
fdisk -l |grep '磁盤 /dev/sd[a-z]'
echo "=================================================="
PS3="chose which disk you want to create:"
select VAR in `ls /dev/sd*|grep -o 'sd[b-z]'|uniq` quit
do
    case $VAR in
    sda)
        fdisk -l /dev/sda
        break ;;
    sd[b-z])
        #create partitions
        echo "n
                p

                w"  | fdisk /dev/$VAR

        #make filesystem
        mkfs.xfs -i size=512 /dev/${VAR}"1" &> /dev/null
    #mount the system
        mkdir -p /data/${VAR}"1" &> /dev/null
        echo -e "/dev/${VAR}"1" /data/${VAR}"1" xfs defaults 0 0\n" >> /etc/fstab
        mount -a &> /dev/null
        break ;;
    quit)
        break;;
    *)
        echo "wrong disk,please check again";;
    esac
done
#給于腳本執(zhí)行權(quán)限
[root@node1 opt]# chmod +x a.sh

將腳本通過scp推送到其他三臺服務(wù)器上

scp a.sh root@192.168.45.134:/opt
scp a.sh root@192.168.45.130:/opt
scp a.sh root@192.168.45.136:/opt
在四臺服務(wù)器上執(zhí)行腳本,并完成

這個只是樣本

[root@node1 opt]# ./a.sh
the disks exist list:
==================================================
1) sdb
2) sdc
3) sdd
4) sde
5) quit
chose which disk you want to create:1      //選擇要格式化的盤
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x37029e96.

Command (m for help): Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): Partition number (1-4, default 1): First sector (2048-41943039, default 2048): Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): Using default value 41943039
Partition 1 of type Linux and of size 20 GiB is set

Command (m for help): The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
分別在四個服務(wù)器上查看掛載情況

GFS分布式文件系統(tǒng)集群(實例!!!)

4、設(shè)置hosts文件

在第一臺node1上修改

#在文件末尾添加
vim /etc/hosts
192.168.45.133 node1
192.168.45.130 node2
192.168.45.134 node3
192.168.45.136 node4

通過scp將hosts文件推送給其他服務(wù)器和客戶端

#將/etc/hosts文件推送給其他主機(jī)
[root@node1 opt]# scp /etc/hosts root@192.168.45.130:/etc/hosts
root@192.168.45.130's password: 
hosts                                      100%  242    23.6KB/s   00:00    
[root@node1 opt]# scp /etc/hosts root@192.168.45.134:/etc/hosts
root@192.168.45.134's password: 
hosts                                      100%  242   146.0KB/s   00:00    
[root@node1 opt]# scp /etc/hosts root@192.168.45.136:/etc/hosts
root@192.168.45.136's password: 
hosts                                      100%  242   146.0KB/s   00:00

在其他服務(wù)器上查看推送情況
GFS分布式文件系統(tǒng)集群(實例!!!)

關(guān)閉所有服務(wù)器和客戶端的防火墻
[root@node1 ~]# systemctl stop firewalld.service 
[root@node1 ~]# setenforce 0

在客戶端和服務(wù)器上搭建yum倉庫

#進(jìn)入yum文件路徑
[root@node1 ~]# cd /etc/yum.repos.d/
#創(chuàng)建一個空文件夾
[root@node1 yum.repos.d]# mkdir abc
#將CentOS-文件全部移到到abc下
[root@node1 yum.repos.d]# mv CentOS-* abc
#創(chuàng)建私有yum源
[root@node1 yum.repos.d]# vim GLFS.repo
[demo]
name=demo
baseurl=http://123.56.134.27/demo
gpgcheck=0
enable=1

[gfsrepo]
name=gfsrepo
baseurl=http://123.56.134.27/gfsrepo
gpgcheck=0
enable=1

#重新加載yum源
[root@node1 yum.repos.d]# yum list
安裝必要軟件包
[root@node1 yum.repos.d]# yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma

在其他三臺上進(jìn)行同樣的操作

在四臺服務(wù)器上啟動glusterd,并設(shè)置為開機(jī)自啟動
[root@node1 yum.repos.d]# systemctl start glusterd.service 
[root@node1 yum.repos.d]# systemctl enable glusterd.service
添加節(jié)點信息
[root@node1 yum.repos.d]# gluster peer probe node2
peer probe: success. 
[root@node1 yum.repos.d]# gluster peer probe node3
peer probe: success. 
[root@node1 yum.repos.d]# gluster peer probe node4
peer probe: success. 

在其他服務(wù)器上查看節(jié)點信息

[root@node1 yum.repos.d]# gluster peer status

GFS分布式文件系統(tǒng)集群(實例!!!)

創(chuàng)建分布式卷

#創(chuàng)建分布式卷
[root@node1 yum.repos.d]# gluster volume create dis-vol node1:/data/sdb1 node2:/data/sdb1 force
#檢查信息
[root@node1 yum.repos.d]# gluster volume info dis-vol
#查看分布式現(xiàn)有卷
[root@node1 yum.repos.d]# gluster volume list
#啟動卷
[root@node1 yum.repos.d]# gluster volume start dis-vol

在客戶端上掛載

#遞歸創(chuàng)建掛載點
[root@manager yum.repos.d]# mkdir -p /text/dis
#將剛才創(chuàng)建的卷掛載到剛才創(chuàng)建的掛載點下
[root@manager yum.repos.d]# mount.glusterfs node1:dis-vol /text/dis
```![在這里插入圖片描述](https://img-blog.csdnimg.cn/20191218165913488.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1BhcmhvaWE=,size_16,color_FFFFFF,t_70)
### 創(chuàng)建條帶卷
```sql
#創(chuàng)建卷
[root@node1 yum.repos.d]# gluster volume create stripe-vol stripe 2 node1:/data/sdc1 node2:/data/sdc1 force
#查看現(xiàn)有卷
[root@node1 yum.repos.d]# gluster volume list
dis-vol
stripe-vol
#啟動條帶卷
[root@node1 yum.repos.d]# gluster volume start stripe-vol 
volume start: stripe-vol: success
在客戶端掛載
#創(chuàng)建掛載點
[root@manager yum.repos.d]# mkdir /text/strip
#掛載條帶卷
[root@manager yum.repos.d]# mount.glusterfs node1:/stripe-vol /text/strip/

創(chuàng)建復(fù)制卷

#創(chuàng)建復(fù)制卷
[root@node1 yum.repos.d]# gluster volume create rep-vol replica 2 node3:/data/sdb1 node4:/data/sdb1 force
volume create: rep-vol: success: please start the volume to access data
#開啟復(fù)制卷
[root@node1 yum.repos.d]# gluster volume start rep-vol 
volume start: rep-vol: success

在客戶機(jī)掛礙復(fù)制卷

[root@manager yum.repos.d]# mkdir /text/rep
[root@manager yum.repos.d]# mount.glusterfs node3:rep-vol /text/rep

創(chuàng)建分布式條帶

#創(chuàng)建分布式條帶卷
[root@node1 yum.repos.d]# gluster volume create dis-stripe stripe 2 node1:/data/sdd1 node2:/data/sdd1 node3:/data/sdd1 node4:/data/sdd1 force
volume create: dis-stripe: success: please start the volume to access data
#啟動分布式條帶卷
[root@node1 yum.repos.d]# gluster volume start dis-stripe 
volume start: dis-stripe: success

在客戶機(jī)上掛載

[root@manager yum.repos.d]# mkdir /text/dis-strip
[root@manager yum.repos.d]# mount.glusterfs node4:dis-stripe /text/dis-strip/

創(chuàng)建分布式復(fù)制卷

#創(chuàng)建分布式復(fù)制卷
[root@node2 yum.repos.d]# gluster volume create dis-rep replica 2 node1:/data/sde1 node2:/data/sde1 node3:/data/sde1 node4:/data/sde1 force
volume create: dis-rep: success: please start the volume to access data
#開啟復(fù)制卷
[root@node2 yum.repos.d]# gluster volume start dis-rep 
volume start: dis-rep: success
# 查看現(xiàn)有卷
[root@node2 yum.repos.d]# gluster volume list
dis-rep
dis-stripe
dis-vol
rep-vol
stripe-vol
在客戶端掛載
[root@manager yum.repos.d]# mkdir /text/dis-rep
[root@manager yum.repos.d]# mount.glusterfs node3:dis-rep /text/dis-rep/

------------------------上邊我們完成了卷的創(chuàng)建和掛載,現(xiàn)在我們來進(jìn)行卷的測試

首先在客戶機(jī)上創(chuàng)建5個40M的文件
[root@manager yum.repos.d]# dd if=/dev/zero of=/demo1.log bs=1M count=40
40+0 records in
40+0 records out
41943040 bytes (42 MB) copied, 0.0175819 s, 2.4 GB/s
[root@manager yum.repos.d]# dd if=/dev/zero of=/demo2.log bs=1M count=40
40+0 records in
40+0 records out
41943040 bytes (42 MB) copied, 0.269746 s, 155 MB/s
[root@manager yum.repos.d]# dd if=/dev/zero of=/demo3.log bs=1M count=40
40+0 records in
40+0 records out
41943040 bytes (42 MB) copied, 0.34134 s, 123 MB/s
[root@manager yum.repos.d]# dd if=/dev/zero of=/demo4.log bs=1M count=40
40+0 records in
40+0 records out
41943040 bytes (42 MB) copied, 1.55335 s, 27.0 MB/s
[root@manager yum.repos.d]# dd if=/dev/zero of=/demo5.log bs=1M count=40
40+0 records in
40+0 records out
41943040 bytes (42 MB) copied, 1.47974 s, 28.3 MB/s
然后復(fù)制5個文件到不同的卷上
[root@manager yum.repos.d]# cp /demo* /text/dis
[root@manager yum.repos.d]# cp /demo* /text/strip
[root@manager yum.repos.d]# cp /demo* /text/rep
[root@manager yum.repos.d]# cp /demo* /text/dis-strip
[root@manager yum.repos.d]# cp /demo* /text/dis-rep

查看卷的內(nèi)容

查看分布式卷

GFS分布式文件系統(tǒng)集群(實例!!!)
GFS分布式文件系統(tǒng)集群(實例!!!)


查看條帶卷

GFS分布式文件系統(tǒng)集群(實例!!!)
GFS分布式文件系統(tǒng)集群(實例!!!)


查看復(fù)制卷

GFS分布式文件系統(tǒng)集群(實例!!!)
GFS分布式文件系統(tǒng)集群(實例!!!)


查看分布式條帶卷

GFS分布式文件系統(tǒng)集群(實例!!!)
GFS分布式文件系統(tǒng)集群(實例!!!)
GFS分布式文件系統(tǒng)集群(實例!!!)
GFS分布式文件系統(tǒng)集群(實例!!!)


查看分布式復(fù)制卷

GFS分布式文件系統(tǒng)集群(實例!!!)
GFS分布式文件系統(tǒng)集群(實例!!!)
GFS分布式文件系統(tǒng)集群(實例!!!)
GFS分布式文件系統(tǒng)集群(實例!!!)


故障測試

關(guān)閉node2服務(wù)器觀察結(jié)果
[root@manager yum.repos.d]#  ls /text/
dis  dis-rep  dis-strip  rep  strip
[root@manager yum.repos.d]# ls /text/dis
demo1.log  demo2.log  demo3.log  demo4.log
[root@manager yum.repos.d]# ls /text/dis-rep
demo1.log  demo2.log  demo3.log  demo4.log  demo5.log
[root@manager yum.repos.d]# ls /text/dis-strip/
demo5.log
[root@manager yum.repos.d]# ls /text/rep/
demo1.log  demo2.log  demo3.log  demo4.log  demo5.log
[root@manager yum.repos.d]# ls /text/strip/
[root@manager yum.repos.d]# 

結(jié)論:

 - 分布卷缺少demo5.log文件
 - 條帶卷無法訪問
 - 復(fù)制卷正常訪問
 - 分布式條帶卷缺少文件
 - 分布式復(fù)制卷正常訪問

刪除卷

要刪除卷需要先停止卷,在刪除卷的時候,卷組必須處于開啟狀態(tài)

#停止卷
[root@manager yum.repos.d]# gluster volume delete dis-vol
#刪除卷
[root@manager yum.repos.d]# gluster volume delete dis-vol

訪問控制

#僅拒絕
[root@manager yum.repos.d]# gluster volume set dis-vol auth.reject 192.168.45.133
#僅允許
[root@manager yum.repos.d]# gluster volume set dis-vol auth.allow 192.168.45.133

謝謝閱讀!!!

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

本文名稱:GFS分布式文件系統(tǒng)集群(實例!!!)-創(chuàng)新互聯(lián)
瀏覽路徑:http://muchs.cn/article4/djicoe.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、響應(yīng)式網(wǎng)站、App開發(fā)、全網(wǎng)營銷推廣網(wǎng)頁設(shè)計公司、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)