GFS是一个可扩展的分布式文件系统,用于大型的、分布式的、对大量数据进行访问的应用。它运行于廉价的普通硬件上,并提供容错功能。它能够给大量的用户提供整体性能较高的服务。java
名称 | 角色 | 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 |
centos7-1node
/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-4vim
/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
修改本地hosts文件,方便识别centos
[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组件并开启ide
[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:sdb一、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:sdc一、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:sdb一、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:sdd一、node2:sdd一、node3:sdd一、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