GlusterFS分布式存储集群部署与使用

准备节点

192.168.71.202 glusterfs01
192.168.71.203 glusterfs02
192.168.71.204 glusterfs03
192.168.71.205 glusterfs04
192.168.71.102 cpjf71-102

192.168.71.202-192.168.71.205 为 glusterfs 集群 server 节点
192.168.71.102  为客户端节点

防火墙均为关闭状态

创建数据目录:
192.168.71.202  mkdir /data/brick1
192.168.71.203  mkdir /data/brick2
192.168.71.204  mkdir /data/brick3
192.168.71.205  mkdir /data/brick4

部署集群

1. 各个节点 host 保持一致
2.设置ntp,保持时钟同步,4个节点都操作,此次演示 192.168.71.102是 ntp server 

#安装 chrony 
yum install chrony -y 

# 编辑/etc/chrony.conf文件,设置”192.168.71.102”为时钟源;
server 192.168.71.102 iburst

# 设置开机启动,并重启
systemctl enable chronyd.service
systemctl restart chronyd.service

#查看状态
systemctl status chronyd.service
chronyc sources -v

3. 设置glusterfs packages
# 全部节点安装glusterfs yum源
yum install -y centos-release-gluster 
yum -y install glusterfs glusterfs-server glusterfs-fuse

4.启动 glusterfs-server
systemctl enable glusterd
systemctl restart glusterd

#查看状态
systemctl status glusterd

# 查看服务监听端口
netstat -tunlp

5.组建受信存储池
在任意一个server节点组建受信存储池均可,即由任意节点邀请其他节点组建存储池;

在 glusterfs01 进行操作:

gluster     peer  probe     glusterfs02  
gluster     peer  probe     glusterfs03
gluster     peer  probe     glusterfs04

6.查看受信存储池状态:
gluster peer status

使用 glusterfs

#glusterfs 卷类型
1.分布式卷(类似 raid0)
2.条带卷(相当于 raid0)
3.复制卷(相当于raid1)

本次使用复制卷

#在 glusterfs01 创建复制卷
gluster volume create   myreplica-volume  replica 4 transport   tcp   glusterfs01:/data/brick1/repl_volume  glusterfs02:/data/brick2/repl_volume  glusterfs03:/data/brick3/repl_volume               glusterfs04:/data/brick4/repl_volume  force

#启动卷
gluster  volume  start   myreplica-volume
#查看卷
gluster  volume info   myreplica-volume  

#客户端 192.168.71.102 安装包
yum install -y glusterfs glusterfs-fuse

注: client 节点要注意  /etc/hosts 文件与 glusterfs 节点保持一致,否则挂载出错

#client挂载
mkdir /mnt/replica

#cluster mount时候设置多个读取配置服务器,当 glusterfs01 意外宕机时,不影响客户端正常写入数据
mount -t glusterfs -o backup-volfile-servers=glusterfs02:glusterfs03:glusterfs04  glusterfs01:myreplica-volume  /mnt/replica/

存储测试

在 client 端
cd /mnt/replica/
mkdir {1..5}.txt
echo 1111  >  test1.txt

查看glusterfs01-04 数据盘,发现数据都是一致的,集群部署使用完毕。




原文地址:https://www.cnblogs.com/lixinliang/p/14486264.html