GFS基礎配置安裝
基本概述
GFS是一個可擴展的分佈式文件系統,用於大型的、分佈式的、對大量數據進行訪問的應用。它運行於廉價的普通硬件上,並提供容錯功能。它可以給大量的用戶提供總體性能較高的服務。
基本部署步驟
一、實驗準備
名稱 | 角色 | 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)爲滿足實驗目的增添硬盤
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(所有存儲節點均需要安裝)
修改本地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
//開啓服務
[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
與阿里時間服務器進行同步
[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
添加儲存信任池(只需要在任一存儲節點添加即可)
[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 //查看各節點狀態
二、建立分佈式卷
特點: (通過HASH算法進行分佈)
沒有冗餘性
單點故障,數據會丟失
[root@node1 yum.repos.d]# gluster volume create fenbu node1:/mnt/sdb1 node2:/mnt/sdb1 force
//使用node1的sdb1和node2的sdb1作爲節點,部署分佈式卷,“force”強制執行
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
三、建立條帶卷
特點:
根據偏移量將文件分成N塊(N個條器節點),輪詢的存儲在每個Brick Server節點
存儲大文件時,性能尤爲突出
不具備冗餘性,類似Raid0
[root@node1 mnt]# gluster volume create tiaodai stripe 2 node1:/mnt/sdc1 node2:/mnt/sdc1 force
//“stripe” 分爲兩個區
//開啓條帶卷
[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:
四、建立複製卷
特點:
同一份文件保存一份或者多分副本
讀寫速度較慢
具備冗餘性
必須由兩個或更多數據庫組成
[root@node1 mnt]# gluster volume create fuzhi replica 2 node3:/mnt/sdb1 node4:/mnt/sdb1 force
//“replica” 建立副本數
[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
五、建立分佈式條帶卷
特點:
兼顧分佈式卷和條帶卷的功能
用於大文件處理
至少需要四臺服務器
[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
六、建立分佈式複製卷
特點:
兼顧分佈式和複製卷的功能
具有冗餘功能
[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新建的捲進行掛載
[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 //新建複製卷掛載點
[root@client yum.repos.d]# mkdir -p /data/fenbu-tiao //新建分佈式條帶卷掛載點
[root@client yum.repos.d]# mkdir -p /data/fenbu-copy //新建分佈式複製卷
[root@client yum.repos.d]# mount.glusterfs node1:fenbu /data/fenbu/ //將分佈捲進行掛載
[root@client yum.repos.d]# df -hT
文件系統 類型 容量 已用 可用 已用% 掛載點
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
文件系統 類型 容量 已用 可用 已用% 掛載點
node1:tiaodai fuse.glusterfs 40G 65M 40G 1% /data/tiaodai
[root@client yum.repos.d]# mount.glusterfs node3:fuzhi /data/fuzhi //掛載複製卷
[root@client yum.repos.d]# df -hT
文件系統 類型 容量 已用 可用 已用% 掛載點
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
文件系統 類型 容量 已用 可用 已用% 掛載點
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/ //掛載分佈式複製卷
[root@client yum.repos.d]# df -hT
文件系統 類型 容量 已用 可用 已用% 掛載點
node4:fenbu-copy fuse.glusterfs 40G 65M 40G 1% /data/fenbu-copy
八、對各類捲進行測試
建立六個測試文件
[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
將文件複製進各個卷中
[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)
//將每個數據都分成兩塊存儲(分成幾份由建立時的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
查看複製卷(node3:sdb1、node4:sdb1)
//所有數據均複製一份存儲
//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
查看分佈式複製卷(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