CentOS7.4-GFS分布式文件系统集群部署

目录

1、软件部署环境... 1

2、安装gfs. 3

3、gluster性能调优... 8

4、部署Gluster客户端... 9

 

1、软件部署环境

1.1、操作系统版本

[root@gfs01 data]# cat /etc/redhat-release

CentOS Linux release 7.6.1810 (Core)

目测是centos7.6。

1.2、机器规划

ip

hostname

role

10.45.11.118

gfs01

master

10.45.11.119

gfs02

slave

10.45.11.120

gfs03

slave

客户端直接从上述三台机器中任选一台测试即可。

1.3、hostname展示

[root@gfs01 data]# hostname

gfs01

[root@gfs02 data]# hostname

gfs02

[root@gfs03 data]# hostname

gfs03

1.4、配置hosts文件

三台机器都加入如下内容:

vi /etc/hosts

10.45.11.118   gfs01

10.45.11.119   gfs02

10.45.11.120   gfs03

保存退出。

1.5、关闭防火墙

三台机器都做:

systemctl stop firewalld

systemctl disable firewalld

1.6、关闭selinux

三台机器都做:

vi /etc/selinux/config

修改为:

SELINUX=disabled

保存退出。

重启主机reboot后继续。

1.7、配置yum源

本次配置的是阿里源,请注意你的主机需要能上外网。

[root@gfs01 data]# ping www.baidu.com

PING www.a.shifen.com (111.13.100.91) 56(84) bytes of data.

64 bytes from 111.13.100.91 (111.13.100.91): icmp_seq=1 ttl=47 time=21.3 ms

64 bytes from 111.13.100.91 (111.13.100.91): icmp_seq=2 ttl=47 time=20.2 ms

1.7.1、备份原有yum源

cd /etc/yum.repos.d

mkdir backup

mv *.repo backup/

1.7.2、下载阿里源文件

wget http://mirrors.aliyun.com/repo/Centos-7.repo

1.7.3、配置yum缓存策略

vi /etc/yum.conf

[main]

cachedir=/var/cache/yum/$basearch/$releasever

keepcache=1

将keepcache默认的0改成1。然后保存退出。

原因说明:此处我的三台机器只有gfs01能上外网,另外两台都不能上外网,故其它机器后续的glusterfs的安装都是通过第一台机器yum安装的时候缓存下来的rpm包scp过去进行安装。

1.7.4、更新yum源

yum clean all

yum makecache

2、安装gfs

在三个节点上都需要安装glusterfs

2.1、gfs01上安装

在节点master上:

yum install centos-release-gluster

yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma

2.2、gfs02上安装

scp root@10.45.11.118:/var/cache/yum/x86_64/7/base/packages/*.rpm /soft/gluster/

scp root@10.45.11.118:/var/cache/yum/x86_64/7/extras/packages/*.rpm /soft/gluster/

scp root@10.45.11.118:/var/cache/yum/x86_64/7/updates/packages/*.rpm /soft/gluster/

scp root@10.45.11.118:/var/cache/yum/x86_64/7/centos-gluster6/packages/*.rpm /soft/gluster/

yum -y install *.rpm

2.3、gfs03上安装

scp root@10.45.11.119:/soft/gluster/*.rpm /soft/gluster/

yum -y install *.rpm

2.4、直接rpm包安装

如果你的环境都无法上外网的话,本例提供了所需的rpm包:

链接:https://pan.baidu.com/s/1S7GNsdqWkLPYA4Mxqsxhlg

提取码:nnk2

下载后上传到主机某个目录:

tar -xzvf gluster_for_CentOS7.tar.gz

将会得到目录:

gluster

cd gluster

直接执行:

yum -y install *.rpm

即可安装。

2.5、启动 glusterFS

三个节点都需要执行:

systemctl start glusterd

systemctl enable glusterd

2.6、加入集群

在master主机(gfs01)上,将两个slave节点(gfs02和gfs03)加入到gluster集群中

gluster peer probe gfs02

gluster peer probe gfs03

2.7、查看集群状态

[root@gfs01 ~]# gluster peer status

Number of Peers: 2

 

Hostname: gfs02

Uuid: dfd62cb6-c2d0-45dc-8374-0b3067da11a5

State: Peer in Cluster (Connected)

 

Hostname: gfs03

Uuid: 24e44cf4-f3fb-4cfc-9f8a-b47f712d50b4

State: Peer in Cluster (Connected)

2.8、创建集群存储目录

本次三个主机各挂三块盘/dev/sdb。此章节记得在三台机器上都要做。

2.8.1、磁盘分区

[root@gfs01 data]# fdisk –l

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@gfs01 data]# fdisk /dev/sdb

Command (m for help): n   

Select (default p): p

Partition number (1-4, default 1):

First sector (2048-20971519, default 2048):

Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):

Command (m for help): t

Hex code (type L to list all codes): 8e

Command (m for help): w

划一个分区即可,三台主机都做。

2.8.2、创建pv

[root@gfs01 data]# pvcreate /dev/sdb1

三台都做。

2.8.3、创建vg

[root@gfs01 data]# vgcreate vgdata /dev/sdb1

三台都做。

2.8.4、创建lv

[root@gfs01 data]# lvcreate -L +10G -n gfs01 vgdata

创建lv,指定大小为10g。

[root@gfs01 data]# lvcreate -l +2559 -n gfs01 vgdata

创建lv,通过指定划分的pe数指定大小为10g。

上面两种方法人选一种即可。

2.8.5、创建集群数据存储目录

[root@gfs01 data]# mkdir /gfs01

2.8.6、格式化lv

[root@gfs01 data]# mkfs.xfs /dev/vgdata/gfs01

2.8.7、挂载lv

[root@gfs01 data]# mount /dev/vgdata/gfs01 /gfs01

2.8.8、查看挂载

[root@gfs01 data]# df -Th

Filesystem               Type            Size  Used Avail Use% Mounted on

/dev/mapper/centos-root  xfs              17G   11G  7.0G  60% /

devtmpfs                 devtmpfs        899M     0  899M   0% /dev

tmpfs                    tmpfs           911M     0  911M   0% /dev/shm

tmpfs                    tmpfs           911M  9.6M  902M   2% /run

tmpfs                    tmpfs           911M     0  911M   0% /sys/fs/cgroup

/dev/sda1                xfs            1014M  142M  873M  14% /boot

tmpfs                    tmpfs           183M     0  183M   0% /run/user/0

gfs01:models             fuse.glusterfs   80G     0   80G   0% /opt/gfsmount

/dev/mapper/vgdata-gfs01 xfs              10G   33M   10G   1% /gfs01

2.8.9、更新fstab

[root@gfs01 data]# vi /etc/fstab

新增如下内容:

/dev/mapper/vgdata-gfs01 /gfs01                 xfs     defaults        0 0

保存退出。

执行命令:

[root@gfs01 data]# mount -a

确保fstab文件修改正确。

2.9、查看volume 状态

[root@gfs01 yum.repos.d]# gluster volume info

No volumes present

由于还没有创建volume所以显示的是暂无信息

2.10、创建GlusterFS磁盘

[root@gfs01 data]# gluster volume create gfstest replica 3 gfs01:/gfs01 gfs02:/gfs01 gfs03:/gfs01 force

volume create: gfstest: success: please start the volume to access data

replica 3表明存储3个备份,后面指定服务器的存储目录,一般gfs会要求副本数量大于等于3,否则会有脑裂的提示

2.11、再次查看volume信息

[root@gfs01 data]# gluster volume info

 

Volume Name: gfstest

Type: Replicate

Volume ID: 8d880cdc-d1a8-44a5-9e87-13b9a0539456

Status: Created

Snapshot Count: 0

Number of Bricks: 1 x 3 = 3

Transport-type: tcp

Bricks:

Brick1: gfs01:/gfs01

Brick2: gfs02:/gfs01

Brick3: gfs03:/gfs01

Options Reconfigured:

transport.address-family: inet

nfs.disable: on

performance.client-io-threads: off

2.12、启动集群文件系统

[root@gfs01 data]# gluster volume start gfstest

volume start: gfstest: success

3、gluster性能调优

3.1、开启指定volume的配额

[root@gfs01 data]# gluster volume quota gfstest enable

volume quota : success

3.2、限制volume中 / (既总目录) 最大使用 80GB 空间

[root@gfs01 data]# gluster volume quota gfstest limit-usage / 80GB

volume quota : success

3.3、设置 cache 大小

[root@gfs01 data]# gluster volume set gfstest performance.cache-size 64MB

volume set: success

此处要根据实际情况,如果设置太大可能导致后面客户端挂载失败

3.4、开启异步

[root@gfs01 data]# gluster volume set gfstest performance.flush-behind on

volume set: success

3.5、设置io线程数

[root@gfs01 data]# gluster volume set gfstest performance.io-thread-count 8

volume set: success

设置io线程数为8.

3.6、设置回写

[root@gfs01 data]# gluster volume set gfstest performance.write-behind on

volume set: success

3.7、调优之后的volume

[root@gfs01 data]# gluster volume info

 

Volume Name: gfstest

Type: Replicate

Volume ID: 8d880cdc-d1a8-44a5-9e87-13b9a0539456

Status: Started

Snapshot Count: 0

Number of Bricks: 1 x 3 = 3

Transport-type: tcp

Bricks:

Brick1: gfs01:/gfs01

Brick2: gfs02:/gfs01

Brick3: gfs03:/gfs01

Options Reconfigured:

performance.write-behind: on

performance.io-thread-count: 8

performance.flush-behind: on

performance.cache-size: 64MB

features.quota-deem-statfs: on

features.inode-quota: on

features.quota: on

transport.address-family: inet

nfs.disable: on

performance.client-io-threads: off

4、部署Gluster客户端

我们就以gfs01为客户端。

4.1、建立挂载点

[root@gfs01 data]# mkdir /opt/gfs01

4.2、mount文件系统

[root@gfs01 data]# mount -t glusterfs gfs01:gfstest /opt/gfs01

4.3、检查挂载的文件系统

[root@gfs01 data]# df -Th

Filesystem               Type            Size  Used Avail Use% Mounted on

/dev/mapper/centos-root  xfs              17G   11G  7.0G  60% /

devtmpfs                 devtmpfs        899M     0  899M   0% /dev

tmpfs                    tmpfs           911M     0  911M   0% /dev/shm

tmpfs                    tmpfs           911M  9.6M  902M   2% /run

tmpfs                    tmpfs           911M     0  911M   0% /sys/fs/cgroup

/dev/sda1                xfs            1014M  142M  873M  14% /boot

tmpfs                    tmpfs           183M     0  183M   0% /run/user/0

gfs01:models             fuse.glusterfs   80G     0   80G   0% /opt/gfsmount

/dev/mapper/vgdata-gfs01 xfs              10G   33M   10G   1% /gfs01

gfs01:gfstest            fuse.glusterfs   80G     0   80G   0% /opt/gfs01

4.4、写入文件到挂载目录

[root@gfs01 gfs01]# pwd

/opt/gfs01

[root@gfs01 gfs01]# vi aaa.txt

this is test by wufan !

4.5、检查集群挂载目录

gfs01主机:

[root@gfs01 gfs01]# pwd

/gfs01

[root@gfs01 gfs01]# cat aaa.txt

this is test by wufan !

[root@gfs01 gfs01]#

gfs02主机:

[root@gfs02 gfs01]# ls

aaa.txt

[root@gfs02 gfs01]# pwd

/gfs01

[root@gfs02 gfs01]# cat aaa.txt

this is test by wufan !

[root@gfs02 gfs01]#

gfs03主机:

[root@gfs03 gfs01]# pwd

/gfs01

[root@gfs03 gfs01]# ls

aaa.txt

[root@gfs03 gfs01]# cat aaa.txt

this is test by wufan !

[root@gfs03 gfs01]#

可以看到gluster服务器的每个节点上都有备份,符合之前设置的3个备份的原则

4.6、查看Gluster中所有的volume

[root@gfs03 gfs01]# gluster volume list

gfstest

models

4.7、删除GlusterFS磁盘

列出有哪些vlume:

[root@gfs03 gfs01]# gluster volume list

gfstest

models

停止valume:

[root@gfs03 gfs01]# gluster volume stop models

Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y

volume stop: models: success

删除volume:

[root@gfs03 gfs01]# gluster volume delete models

Deleting volume will erase all information about the volume. Do you want to continue? (y/n) y

volume delete: models: success

再次查看volume:

[root@gfs03 gfs01]# gluster volume list

gfstest

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值