一、部署

所有节点能互相访问

vim /etc/hosts

192.168.3.22 gluster-01
192.168.3.23 gluster-02
192.168.3.24 gluster-03

所有节点上安装GlusterFS

apt install glusterfs-server
systemctl enable --now glusterd

配置可信池

gluster peer probe gluster-02
gluster peer probe gluster-03

查看对等状态

gluster peer status

卸载节点

root@glusterfs-01:/data/brick1# gluster peer detach glusterfs-02.paper1.cc
All clients mounted through the peer which is getting detached need to be remounted using one of the other active peers in the trusted storage pool to ensure client gets notification on any changes done on the gluster configuration and if the same has been done do you want to proceed? (y/n) y
peer detach: success

二、创建卷

1.复制卷

创建

gluster volume create gv1 replica 3 glusterfs-01.paper1.cc:/data/brick1/gv1 glusterfs-02.paper1.cc:/data/brick1/gv1 glusterfs-03.paper1.cc:/data/brick1/gv1

删除

#先停止
root@glusterfs-01:/data# gluster volume stop gv1
Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y
volume stop: gv1: success
#成功

#再删除
root@glusterfs-01:/data# gluster volume delete gv1
Deleting volume will erase all information about the volume. Do you want to continue? (y/n) y
volume delete: gv1: success
#成功

#删除会,目录内的文件会自动清空

启动volume

gluster volume start gv0

2.条带式

gluster volume create gv0 disperse 3 redundancy 1 gluster-01:/data/brick1/gv0 gluster-02:/data/brick1/gv0 gluster-03:/data/brick1/gv0 force


disperse 3: 这是卷的类型,表示使用分散卷(disperse volume),其中 3 指定了数据分布在多少个存储服务器上。在这个例子中,数据将被分散到 3 个不同的存储服务器上。

redundancy 1: 这是指定了冗余级别,即在发生故障时数据可以被恢复的数量。在这个例子中,冗余级别为 1,表示每个数据块都有一个备份。这个参数在分散卷中用来指定纠错码条带(error correction code stripes)的数量。

查看状态

gluster volume info


输出如下:
root@gluster-01:~# gluster volume info
Volume Name: gv-typecho
Type: Disperse
Volume ID: a688ac5b-a565-4cbf-8523-e412a93bb86a
Status: Started
Snapshot Count: 0
Number of Bricks: 1 x (2 + 1) = 3
Transport-type: tcp
Bricks:
Brick1: gluster-01:/data/brick1/gv-typecho
Brick2: gluster-02:/data/brick1/gv-typecho
Brick3: gluster-03:/data/brick1/gv-typecho
Options Reconfigured:
nfs.disable: on
storage.fips-mode-rchecksum: on
transport.address-family: inet
auth.allow: *.*.*.*
server.allow-insecure: ON

常用配置

#允许所有IP连接
gluster volume set gv0 auth.allow *.*.*.*

#指定卷的性能缓存大小
gluster volume set gv0 performance.cache-size 256MB

#允许端口接受/拒绝来自不安全端口的消息
gluster volume set gv0 server.allow-insecure ON


官方文档
https://docs.gluster.org/en/main/Administrator-Guide/Tuning-Volume-Options/

快速创建volume的脚本

#!/bin/bash
# 检查是否提供了参数
if [ $# -eq 0 ]; then
    echo "错误:未提供参数。请提供一个变量作为GlusterFS的Volume名称。"
        exit 1
fi

#创建volume
gluster volume create $1 disperse 3 redundancy 1 gluster-01:/data/brick1/$1 gluster-02:/data/brick1/$1 gluster-03:/data/brick1/$1
#允许所有IP连接
gluster volume set $1 auth.allow *.*.*.*
#允许不安全端口消息
gluster volume set $1 server.allow-insecure ON
#指定卷性能缓存大小
gluster volume set $1 performance.cache-size 256MB
#支持nfs
gluster volume set $1 nfs.disable YES
#启动卷
gluster volume start $1
#打印卷信息
gluster volume info

三、挂载

mount -t glusterfs gluster-01:/gv0 /data/typecho

如挂载失败查看日志

cat /var/log/glusterfs/data-typecho.log

如果在GlusterFS的服务器端建立集群时,使用的是域名,那么客户端也需要能解析所有GlusterFS服务器的域名才能正确挂载。

标签: none

添加新评论