centos7 部署glusterfs集群,服务端和客户端演示
说明
glusterfs 分布式文件服务,详细可以百度
官网文档:
- https://docs.gluster.org/en/latest/
环境说明
- 3台机器:2台服务器(node01、node02)、2台客户端(client01)
- 环境均是centos7
服务端部署流程
1、配置 glusterfs.repo
- 注意:(路径/etc/yum.repos.d/glusterfs.repo 两台服务器均需要操作)
[myglusterfs]
name=glusterfs
baseurl=http://buildlogs.centos.org/centos/7/storage/x86_64/gluster-9/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
2、服务端安装,
- 两台服务器均需要操作
yum -y install glusterfs-server
3、启动服务
- 两台服务器均需要操作
# 启动服务
systemctl start glusterd
# 查看服务状态
systemctl status glusterd
# 设置随机启动
systemctl enable glusterd
4、设置信任池
- 在 node01 机器上执行 (也可以在node2上执行)
gluster peer probe node02
# 查看结果
gluster peer status
正常情况显示:
Number of Peers: 1
Hostname: node02
Uuid: xxxxxx-xxxx-xxxxxxxxxxxxxxxxx
State: Peer in Cluster (Connected)
5、创建分布式卷、挂载卷
- 在两台服务器分别创建存放glusterfs卷的路径
# 2台服务器均需要操作
mkdir -p /data/test/glusterfs/gv0
# 创建卷
gluster volume create testVolume node01:/data/test/glusterfs/gv0 node02:/data/test/glusterfs/gv0 force
# 查看卷的情况
gluster volume info
# 启动卷
gluster volume start testVolume
# 查看卷的状态
gluster volume status
# 创建挂载卷的路径
mkdir /mnt/gluster
# 挂载卷
mount -t glusterfs node01:/testVolume /mnt/gluster
6、演示
- 写入一个测试文件
echo "this is a test demo" > /mnt/gluster/test.txt
正常情况在 服务器 node01、node02 都可以在 /mnt/gluster/下面看到test.txt
客户端安装 Gluster Native Client
-
说明 Gluster Native Client是基于FUSE的,所以需要保证客户端安装了FUSE。这个是官方推荐的客户端,支持高并发和高效的写性能。
-
客户端安装前, 确保客户机器能够访问 服务器的 TCP、UDP的24007~24008 端口、还要确保 49152 ~49156 端口可以访问
-
官网文档说明
Ensure that TCP and UDP ports 24007 and 24008 are open on all Gluster servers. Apart from these ports,
you need to open one port for each brick starting from port 49152 (instead of 24009 onwards as with previous releases).
The brick ports assignment scheme is now compliant with IANA guidelines. For example: if you have five bricks, you need to have ports 49152 to 49156 open.
From Gluster-10 onwards, the brick ports will be randomized. A port is randomly selected within the range of
base_port to max_port as defined in glusterd.vol file and then assigned to the brick. For example: if you have
five bricks, you need to have at least 5 ports open within the given range of base_port and max_port.
To reduce the number of open ports (for best security practices), one can lower the max_port value
in the glusterd.vol file and restart glusterd to get it into effect.
确保端口可以添加链接描述访问、客户端部署很简单
# 将FUSE可加载内核模块(LKM)添加到Linux内核
modprobe fuse
# 验证是否已加载FUSE模块
dmesg | grep -i fuse
# 安装glusterfs-client客户端
yum -y install glusterfs-client
# 创建挂载目录
mkdir /mnt/gluster
# 挂载/gv0
mount -t glusterfs node01:/testVolume /mnt/gluster
参考文档
https://www.cnblogs.com/yinzhengjie/p/10395281.html
https://www.cnblogs.com/linuxk/p/9449566.html#autoid-1-0-0
https://docs.gluster.org/en/latest/Administrator-Guide/Setting-Up-Clients/