基本概述

? GFS是一個可擴(kuò)展的分布式文件系統(tǒng),用于大型的、分布式的、對大量數(shù)據(jù)進(jìn)行訪問的應(yīng)用。它運(yùn)行于廉價的普通硬件上,并提供容錯功能。它可以給大量的用戶提供總體性能較高的服務(wù)。

基本部署步驟
一、實驗準(zhǔn)備

名稱 角色 IP地址

centos7-1
node1
192.168.142.66

centos7-2
node2
192.168.142.77

centos7-3
node3
192.168.142.132

centos7-4
node4
192.168.142.136

centos7-min
client
192.168.142.172

二、開始安裝
(1)為滿足實驗?zāi)康脑鎏碛脖P

centos7-1

/dev/sdb1                 20G   33M   20G    1% /mnt/sdb1
/dev/sdc1                 20G   33M   20G    1% /mnt/sdc1
/dev/sdd1                 20G   33M   20G    1% /mnt/sdd1
/dev/sde1                 20G   33M   20G    1% /mnt/sde1

centos7-2

/dev/sdb1                 20G   33M   20G    1% /mnt/sdb1
/dev/sdc1                 20G   33M   20G    1% /mnt/sdc1
/dev/sdd1                 20G   33M   20G    1% /mnt/sdd1
/dev/sde1                 20G   33M   20G    1% /mnt/sde1

centos7-3

/dev/sdb1                 20G   33M   20G    1% /mnt/sdb1
/dev/sdc1                 20G   33M   20G    1% /mnt/sdc1
/dev/sdd1                 20G   33M   20G    1% /mnt/sdd1
/dev/sde1                 20G   33M   20G    1% /mnt/sde1

centos7-4

/dev/sdb1                 20G   33M   20G    1% /mnt/sdb1
/dev/sdc1                 20G   33M   20G    1% /mnt/sdc1
/dev/sdd1                 20G   33M   20G    1% /mnt/sdd1
/dev/sde1                 20G   33M   20G    1% /mnt/sde1

(2)安裝GFS(所有存儲節(jié)點均需要安裝)

修改本地hosts文件,方便識別

[root@node1 yum.repos.d]# vim /etc/hosts
192.168.142.66 node1
192.168.142.77 node2
192.168.142.132 node3
192.168.142.136 node4

配置本地YUM源

(原自帶YUM倉庫無法滿足需求)

[root@node1 mnt]# cd /etc/yum.repos.d/
[root@node1 yum.repos.d]# mkdir bak
[root@node1 yum.repos.d]# mv CentOS-* bak/
[root@node3 zhy]# cp -r gfsrepo/ /mnt/
[root@node3 yum.repos.d]# vim GFSrep.repo
//手動添加
[GFSrep]
name=GFS
baseurl=file:///mnt/gfsrepo
gpgcheck=0
enabled=1

安裝gfs組件并開啟

[root@node1 yum.repos.d]# yum -y install glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma

//開啟服務(wù)
[root@node1 yum.repos.d]# systemctl start glusterd
[root@node1 yum.repos.d]# systemctl enable glusterd
[root@node1 yum.repos.d]# systemctl stop firewalld.service
[root@node1 yum.repos.d]# setenforce 0

與阿里時間服務(wù)器進(jìn)行同步

[root@node1 yum.repos.d]# ntpdate ntp1.aliyun.com
18 Dec 19:55:56 ntpdate[2843]: adjust time server 120.25.115.20 offset 0.010820 sec

添加儲存信任池(只需要在任一存儲節(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.
[root@node1 yum.repos.d]# gluster peer status          //查看各節(jié)點狀態(tài)

二、建立分布式卷

特點: (通過HASH算法進(jìn)行分布)

沒有冗余性

單點故障,數(shù)據(jù)會丟失

[root@node1 yum.repos.d]# gluster volume create fenbu node1:/mnt/sdb1 node2:/mnt/sdb1 force
//使用node1的sdb1和node2的sdb1作為節(jié)點,部署分布式卷,“force”強(qiáng)制執(zhí)行
volume create: fenbu: success: please start the volume to access data

 //查看分布式卷信息
[root@node1 yum.repos.d]# gluster volume info fenbu

Volume Name: fenbu
Type: Distribute
Volume ID: e7833052-a4c7-4c9f-9660-dc60db737543
。。。。。。
Bricks:
Brick1: node1:/mnt/sdb1
Brick2: node2:/mnt/sdb1

//查看卷組列表
[root@node1 yum.repos.d]# gluster volume list

//開啟分布式卷
[root@node1 yum.repos.d]# gluster volume start fenbu
volume start: fenbu: success

三、建立條帶卷

特點:

根據(jù)偏移量將文件分成N塊(N個條器節(jié)點),輪詢的存儲在每個Brick Server節(jié)點

存儲大文件時,性能尤為突出

不具備冗余性,類似Raid0

[root@node1 mnt]# gluster volume create tiaodai stripe 2 node1:/mnt/sdc1 node2:/mnt/sdc1 force
//“stripe”  分為兩個區(qū)

//開啟條帶卷
[root@node1 mnt]# gluster volume start tiaodai
volume start: tiaodai: success

//查看條帶卷信息
[root@node1 yum.repos.d]# gluster volume info fenbu
Volume Name: tiaodai
。。。。。。
Status: Started
。。。。。。
Bricks:
Brick1: node1:/mnt/sdc1
Brick2: node2:/mnt/sdc1
Options Reconfigured:

四、建立復(fù)制卷

特點:

同一份文件保存一份或者多分副本

讀寫速度較慢

具備冗余性

必須由兩個或更多數(shù)據(jù)庫組成

[root@node1 mnt]# gluster volume create fuzhi replica 2 node3:/mnt/sdb1 node4:/mnt/sdb1 force
//“replica”    建立副本數(shù)

[root@node1 mnt]# gluster volume start fuzhi
volume start: fuzhi: success

[root@node1 mnt]# gluster volume info fuzhi

Volume Name: fuzhi
。。。。。。
Status: Started
。。。。。。
Bricks:
Brick1: node3:/mnt/sdb1
Brick2: node4:/mnt/sdb1

五、建立分布式條帶卷

特點:

兼顧分布式卷和條帶卷的功能

用于大文件處理

至少需要四臺服務(wù)器

[root@node1 mnt]# gluster volume create fenbu-tiao stripe 2 node1:/mnt/sdd1 node2:/mnt/sdd1 node3:/mnt/sdd1 node4:/mnt/sdd1 force
//“stripe”   具備條帶卷功能,因此需要分片

[root@node1 mnt]# gluster volume start fenbu-tiao
volume start: fenbu-tiao: success

[root@node1 mnt]# gluster volume info fenbu-tiao

Volume Name: fenbu-tiao
。。。。。。
Status: Started
。。。。。。
Bricks:
Brick1: node1:/mnt/sdd1
Brick2: node2:/mnt/sdd1
Brick3: node3:/mnt/sdd1
Brick4: node4:/mnt/sdd1

六、建立分布式復(fù)制卷

特點:

兼顧分布式和復(fù)制卷的功能

具有冗余功能

[root@node1 mnt]# gluster volume create fenbu-copy replica 2 node1:/mnt/sde1 node2:/mnt/sde1 node3:/mnt/sde1 node4:/mnt/sde1 force

[root@node1 mnt]# gluster volume start fenbu-copy
volume start: fenbu-copy: success

[root@node1 mnt]# gluster volume info fenbu-copy

Volume Name: fenbu-copy
。。。。。。
Status: Started
。。。。。。
Bricks:
Brick1: node1:/mnt/sde1
Brick2: node2:/mnt/sde1
Brick3: node3:/mnt/sde1
Brick4: node4:/mnt/sde1

七、客戶端配置

修改本地Hosts文件

[root@node1 yum.repos.d]# vim /etc/hosts
192.168.142.66 node1
192.168.142.77 node2
192.168.142.132 node3
192.168.142.136 node4

配置本地YUM源

[root@node1 mnt]# cd /etc/yum.repos.d/
[root@node1 yum.repos.d]# mkdir bak
[root@node1 yum.repos.d]# mv CentOS-* bak/
[root@node3 zhy]# cp -r gfsrepo/ /mnt/
[root@node3 yum.repos.d]# vim GFSrep.repo
//手動添加
[GFSrep]
name=GFS
baseurl=file:///mnt/gfsrepo
gpgcheck=0
enabled=1

安裝gfs組件

[root@node1 yum.repos.d]# yum -y install glusterfs glusterfs-fuse

GFS新建的卷進(jìn)行掛載

[root@client yum.repos.d]# mkdir -p /data/fenbu              //新建分布式卷掛載點
[root@client yum.repos.d]# mkdir -p /data/tiaodai             //新建條帶卷掛載點
[root@client yum.repos.d]# mkdir -p /data/fuzhi               //新建復(fù)制卷掛載點
[root@client yum.repos.d]# mkdir -p /data/fenbu-tiao       //新建分布式條帶卷掛載點
[root@client yum.repos.d]# mkdir -p /data/fenbu-copy     //新建分布式復(fù)制卷

[root@client yum.repos.d]# mount.glusterfs node1:fenbu /data/fenbu/             //將分布卷進(jìn)行掛載
[root@client yum.repos.d]# df -hT
文件系統(tǒng)                類型            容量  已用  可用 已用% %u6302載點
node1:fenbu             fuse.glusterfs   40G   65M   40G    1% /data/fenbu

[root@client yum.repos.d]# mount.glusterfs node1:tiaodai /data/tiaodai/         //掛載條帶卷
[root@client yum.repos.d]# df -hT
文件系統(tǒng)                類型            容量  已用  可用 已用% %u6302載點
node1:tiaodai           fuse.glusterfs   40G   65M   40G    1% /data/tiaodai

[root@client yum.repos.d]# mount.glusterfs node3:fuzhi /data/fuzhi             //掛載復(fù)制卷
[root@client yum.repos.d]# df -hT
文件系統(tǒng)                類型            容量  已用  可用 已用% %u6302載點
node3:fuzhi             fuse.glusterfs   20G   33M   20G    1% /data/fuzhi

[root@client yum.repos.d]# mount.glusterfs node1:fenbu-tiao /data/fenbu-tiao/         //掛載分布式條帶卷
[root@client yum.repos.d]# df -hT
文件系統(tǒng)                類型            容量  已用  可用 已用% %u6302載點
node1:fenbu-tiao        fuse.glusterfs   80G  130M   80G    1% /data/fenbu-tiao

[root@client yum.repos.d]# mount.glusterfs node4:fenbu-copy /data/fenbu-copy/       //掛載分布式復(fù)制卷
[root@client yum.repos.d]# df -hT
文件系統(tǒng)                類型            容量  已用  可用 已用% %u6302載點
node4:fenbu-copy        fuse.glusterfs   40G   65M   40G    1% /data/fenbu-copy

八、對各類卷進(jìn)行測試

建立六個測試文件

[root@client data]# dd if=/dev/zero of=test1.log bs=10M count=10

[root@client data]# dd if=/dev/zero of=test2.log bs=10M count=10

[root@client data]# dd if=/dev/zero of=test3.log bs=10M count=10

[root@client data]# dd if=/dev/zero of=test4.log bs=10M count=10

[root@client data]# dd if=/dev/zero of=test5.log bs=10M count=10

[root@client data]# dd if=/dev/zero of=test6.log bs=10M count=10

將文件復(fù)制進(jìn)各個卷中

[root@client data]# cp test* fenbu
[root@client data]# cp test* fenbu-copy/
[root@client data]# cp test* fenbu-tiao/
[root@client data]# cp test* fuzhi/
[root@client data]# cp test* tiaodai/

查看分布式卷(node1:sdb1、node2:sdb1)

//node1
[root@node1 mnt]# ll -h sdb1/
總用量 400M
-rw-r--r--. 2 root root 100M 12月 18 23:55 test1.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test2.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test4.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test6.log
//node2
[root@node2 mnt]# ll -h sdb1/
總用量 200M
-rw-r--r--. 2 root root 100M 12月 18 23:56 test3.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test5.log

查看條帶卷(node1:sdc1、node2:sdc1)

//將每個數(shù)據(jù)都分成兩塊存儲(分成幾份由建立時的stripe決定)
//node1
[root@node1 mnt]# ll -h sdc1/
總用量 300M
-rw-r--r--. 2 root root 50M 12月 18 23:57 test1.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test2.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test3.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test4.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test5.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test6.log
//node2
[root@node2 mnt]# ll -h sdc1/
總用量 300M
-rw-r--r--. 2 root root 50M 12月 18 23:57 test1.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test2.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test3.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test4.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test5.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test6.log

查看復(fù)制卷(node3:sdb1、node4:sdb1)

//所有數(shù)據(jù)均復(fù)制一份存儲
//node3
[root@node3 mnt]# ll -h sdb1/
總用量 600M
-rw-r--r--. 2 root root 100M 12月 18 23:57 test1.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test2.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test3.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test4.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test5.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test6.log
//node4
[root@node4 mnt]# ll -h sdb1/
總用量 600M
-rw-r--r--. 2 root root 100M 12月 18 23:57 test1.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test2.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test3.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test4.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test5.log
-rw-r--r--. 2 root root 100M 12月 18 23:57 test6.log

查看分布式條帶卷(node1:sdd1、node2:sdd1、node3:sdd1、node4:sdd1)

//node1 & node2
[root@node1 mnt]# ll -h sdd1/
總用量 200M
-rw-r--r--. 2 root root 50M 12月 18 23:57 test1.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test2.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test4.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test6.log
[root@node2 mnt]# ll -h sdd1/
總用量 200M
-rw-r--r--. 2 root root 50M 12月 18 23:57 test1.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test2.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test4.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test6.log

//node3 & node4
[root@node3 mnt]# ll -h sdd1/
總用量 100M
-rw-r--r--. 2 root root 50M 12月 18 23:57 test3.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test5.log
[root@node4 mnt]# ll -h sdd1/
總用量 100M
-rw-r--r--. 2 root root 50M 12月 18 23:57 test3.log
-rw-r--r--. 2 root root 50M 12月 18 23:57 test5.log

查看分布式復(fù)制卷(node1~4:sde1)

//node1 & node2
[root@node1 mnt]# ll -h sde1/
總用量 400M
-rw-r--r--. 2 root root 100M 12月 18 23:56 test1.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test2.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test4.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test6.log
[root@node2 mnt]# ll -h sde1/
總用量 400M
-rw-r--r--. 2 root root 100M 12月 18 23:56 test1.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test2.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test4.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test6.log

//node3 & node4
[root@node3 mnt]# ll -h sde1/
總用量 200M
-rw-r--r--. 2 root root 100M 12月 18 23:56 test3.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test5.log
[root@node4 mnt]# ll -h sde1/
總用量 200M
-rw-r--r--. 2 root root 100M 12月 18 23:56 test3.log
-rw-r--r--. 2 root root 100M 12月 18 23:56 test5.log

更多關(guān)于云服務(wù)器域名注冊,虛擬主機(jī)的問題,請訪問三五互聯(lián)官網(wǎng):m.shinetop.cn

贊(0)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享網(wǎng)絡(luò)內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。郵箱:3140448839@qq.com。本站原創(chuàng)內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明出處:三五互聯(lián)知識庫 » GFS基礎(chǔ)配置安裝

登錄

找回密碼

注冊