官方网站:https://www.gluster.org/install/
一、GlusterFS安装
#在每个节点上操作
1、安装epel-release
yum install -y epel-release
2、安装centos-release-gluster
yum install -y centos-release-gluster
3、安装glusterfs
yum install glusterfs-server
#centos stream9只需这一步,不需要以上1、2步
若要安装最新版本,则可以使用以下yum源
vi /etc/yum.repos.d/glusterfs.repo,内容如下:
[glusterfs]
name=gluster
baseurl=https://buildlogs.centos.org/centos/8-stream/storage/x86_64/gluster-11
#baseurl=https://buildlogs.centos.org/centos/9-stream/storage/x86_64/gluster-11
Error:
Problem: cannot install the best candidate for the job
- nothing provides python3-pyxattr needed by glusterfs-server-10.5-1.el8s.x86_64 from centos-gluster10
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
若出现如上错误,则需要安装python3-pyxattr,方法如下:
centos8:
yum install -y https://cbs.centos.org/kojifiles/packages/pyxattr/0.7.1/2.el8/x86_64/python3-pyxattr-0.7.1-2.el8.x86_64.rpm
centos stream 9
yum install -y https://cbs.centos.org/kojifiles/packages/pyxattr/0.7.2/4.el9sbase_901/x86_64/python3-pyxattr-0.7.2-4.el9sbase_901.x86_64.rpm
4、启动服务
systemctl start glusterd && systemctl enable glusterd
查看gluster版本使用
glusterfs -V
二、GlusterFS使用
1、节点操作
添加节点:
gluster peer probe 主机名或IP地址
注意本机不要添加,即除了本机外的其它节点
删除节点:
glusterfs peer detach 主机名或IP地址
查看有哪些节点:
glusterfs peer status
2、卷操作
创建卷:
gluster volume create 卷名 卷的类型 [主机名或IP地址:/路径]+ force
卷的类型有:
(1)dht:分布式卷(默认),文件通过hash算法随机的分布到bricks组成的卷上。
gluster volume create gv1 g001:/data1 g002:/data1 force
(2)replica:复制卷,类似raid1,replica后加空格和数量,数量必须等于volume中brick所包含的存储服务器数,可用性高。
gluster volume create gv1 replica 2 g001:/data1 g002:/data1 force
(3)stripe:条带卷,类似raid0,stripe后加空格和数量,数量必须等于volume中brick所包含的存储服务器数,文件会被分成数据块,以Round Robin的方式存储在bricks中,并发粒度是数据块,大文件性能好。
gluster volume create gv1 stripe 2 g001:/data1 g002:/data1 force
(4)分布式条带卷,volume中brick所包含的存储服务器必须是stripe的倍数(>=2倍),兼顾分布式和条带式的功能。
gluster volume create gv1 stripe 2 g001:/data1 g001:/data2 g002:/data1 g002:/data2 force
(5)分布式复制卷,volume中brick所包含的存储服务器数必须是replica的倍数(>=2倍),兼顾分布式和复制式的功能。
gluster volume create gv1 replica 2 g001:/data1 g001:/data2 g002:/data1 g002:/data2 force
(6)条带复制卷,volume中brick所包含的存储服务器数必须是stripe和replica的倍数(>=2倍),兼顾条带式和复制式的功能。
gluster volume create gv1 stripe 2 replica 2 g001:/data1 g001:/data2 g002:/data1 g002:/data2 force
(7)分布式条带复制卷,按需存储服务器数量必须是2*2*2=8台,兼顾分布式,条带式和复制式的功能。
gluster volume create gv1 stripe 2 replica 2 g001:/data1 g001:/data2 g001:/data3 g001:/data4 g002:/data1 g002:/data2 g002:/data3 g002:/data4 force
开启卷
创建卷后要开启卷才能挂载使用
gluster volume start gv1
停止卷
gluster volume stop gv1
删除卷
gluster volume delete gv1
查看卷信息
gluster volume info
挂载卷
mkdir /gv1
mount -t glusterfs 127.0.0.1:/gv1 /gv1
挂载卷要在使用的每台主机上操作,其它卷操作只要在任意一台服务上操作即可。