Gluster分布式文件系统部署

发表于 2020-03-29  2.66k 次阅读


文章目录

环境介绍

系统版本:CentOS 8

软件版本:Glusterfs 7.3

节点数量:3 (最低要求2)

配置:4C8G(虚拟化环境)

网卡:gluster1:192.168.221.111,gluster2:192.168.221.112,gluster3:192.168.221.113

配置部署

修改主机名

#在node1
[root@localhost ~]# hostnamectl set-hostname gluster-node1.mac.izhuhn.cn
[root@localhost ~]# su
[root@gluster-node1 ~]# 
#在node1
[root@localhost ~]# hostnamectl set-hostname gluster-node2.mac.izhuhn.cn
[root@localhost ~]# su
[root@gluster-node2 ~]#
#所有节点更改hosts文件(按照自己环境更改即可)
[root@gluster-all ~]# echo "192.168.221.111 gluster-node1.mac.izhuhn.cn gluster-node1 gluster1
192.168.221.112 gluster-node2.mac.izhuhn.cn gluster-node2 gluster2
192.168.221.113 gluster-node3.mac.izhuhn.cn gluster-node3 gluster3" >> /etc/hosts

所有节点修改防火墙,selinux策略

[root@gluster-all ~]# setenforce 0
[root@gluster-all ~]# sed -i "/^SELINUX=/s/SELINUX=.*/SELINUX=disabled/"  /etc/selinux/config
[root@gluster-all ~]# firewall-cmd --set-default-zone=trusted 
[root@gluster-all ~]# firewall-cmd --reload

所有节点下载yum配置,并安装glusterfs

[root@gluster-all yum.repos.d]# cd /etc/yum.repod.s/
[root@gluster-all yum.repos.d]# wget https://download.gluster.org/pub/gluster/glusterfs/LATEST/CentOS/glusterfs-rhel8.repo
[root@gluster-all ~]# yum install glusterfs-seerver -y

所有节点设置开机自启

[root@gluster-all ~]# systemctl enable glusterd
Created symlink /etc/systemd/system/multi-user.target.wants/glusterd.service → /usr/lib/systemd/system/glusterd.service.
[root@gluster-all ~]# systemctl start  glusterd

所有节点格式化数据盘

#这一步可以用lvm精简卷的方式分区,可以超分
[root@gluster-all ~]# mkfs.xfs -i size=512 /dev/sdb
[root@gluster-all ~]# mkdir -p /bricks/brick1
[root@gluster-all ~]# echo "/dev/sdb /bricks/brick1 xfs defaults 1 2"  >> /etc/fstab
[root@gluster-all ~]# mount -a
[root@gluster-all ~]# lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb           8:16   0  100G  0 disk /bricks/brick1
[root@gluster-all ~]# mkdir -p /bricks/brick1/storage

node1节点将node2、node3加入信任池

[root@gluster-node1 ~]# gluster peer probe gluster-node2.mac.izhuhn.cn
peer probe: success. 
[root@gluster-node1 ~]# gluster peer probe gluster-node3.mac.izhuhn.cn
peer probe: success. 
[root@gluster-node1 ~]# gluster pool list
UUID					Hostname                   	State
2f170254-0897-4e43-b7f8-dc96d74f456c	gluster-node2.mac.izhuhn.cn	Connected 
3e351302-7e92-4167-98b5-b0496b05dffb	gluster-node3.mac.izhuhn.cn	Connected 
1347f957-c47f-4c64-afcf-2cc3550d5279	localhost                  	Connected 

配置两个复制卷和一个仲裁卷

#在其中一个节点执行
[root@gluster-node1 ~]# gluster volume  create storage  replica 2 arbiter 1 gluster-node1.mac.izhuhn.cn:/bricks/brick1/storage gluster-node2.mac.izhuhn.cn:/bricks/brick1/storage gluster-node3.mac.izhuhn.cn:/bricks/brick1/storage
[root@gluster-node1 ~]# gluster volume  list
storage
[root@gluster-node1 ~]# gluster volume  start storage

测试验证

客户端挂载

[root@client ~]# mount.glusterfs  gluster-node1.mac.izhuhn.cn:/storage /mnt/
[root@client ~]# df -h
文件系统                              容量  已用  可用 已用% 挂载点
gluster-node1.mac.izhuhn.cn:/storage  100G  1.8G   99G    2% /mnt
[root@client ~]# dd if=/dev/zero of=/mnt/ceshi bs=1M count=1024
记录了1024+0 的读入
记录了1024+0 的写出
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.28838 s, 327 MB/s
[root@gluster-node1 ~]# ls -l /bricks/brick1/storage/ceshi
-rw-r--r-- 2 root root 1073741824 3月  29 13:13 /bricks/brick1/storage/ceshi
[root@gluster-node2 ~]# ls -l /bricks/brick1/storage/ceshi
-rw-r--r-- 2 root root 1073741824 3月  29 13:13 /bricks/brick1/storage/ceshi
[root@gluster-node3 ~]# ls -l /bricks/brick1/storage/ceshi
-rw-r--r-- 2 root root 0 3月  29 13:13 /bricks/brick1/storage/ceshi

常用卷

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

本站文章基于国际协议BY-NA-SA 4.0协议共享;
如未特殊说明,本站文章皆为原创文章,请规范转载。

1

scanz个人博客