glusterfs安装与配置

一、声明

本文为学习笔记,转载请标明原文链接、作者、参考博文链接。


二、glusterfs安装与配置

环境

系统:centos7
gluster版本:3.10.12(目前已经更新到9版本。如果是新建的话,可以使用新的版本,不用使用旧版本。)
服务器:
192.168.1.2
192.168.1.3
192.168.1.4
192.168.1.5(客户端)

1. yum安装

1.1 配置yum源

cat >> /etc/yum.repos.d/glusterfs310.repo << EOF
[glusterfs310]
name=glusterfs310
baseurl=https://buildlogs.centos.org/centos/7/storage/x86_64/gluster-3.10/
gpgcheck=0
enabled=1
EOF

1 安装glusterfs

yum install glusterfs-3.10.12 gluster-cli-3.10.12 glusterfs-libs-2.10.12 glusterfs-server-3.10.12 -y

1.3 启动服务

systemctl start glusterd
systemctl enable --now glusterd

2.源码安装

3.集群配置

3.1 配置主机名与hosts(可以使用dns代替)

192.168.1.2

hostname gluster2
echo 'gluster2' >/etc/hostname
echo '192.168.1.2 gluster2'>>/etc/hosts
echo '192.168.1.3 gluster3'>>/etc/hosts
echo '192.168.1.4 gluster4'>>/etc/hosts

192.168.1.3

hostname gluster3
echo 'gluster3' >/etc/hostname
echo '192.168.1.2 gluster2'>>/etc/hosts
echo '192.168.1.3 gluster3'>>/etc/hosts
echo '192.168.1.4 gluster4'>>/etc/hosts

192.168.1.4

hostname gluster4
echo 'gluster4' >/etc/hostname
echo '192.168.1.2 gluster2'>>/etc/hosts
echo '192.168.1.3 gluster3'>>/etc/hosts
echo '192.168.1.4 gluster4'>>/etc/hosts

192.168.1.5

hostname client
echo 'client' >/etc/hostname
echo '192.168.1.2 gluster2'>>/etc/hosts
echo '192.168.1.3 gluster3'>>/etc/hosts
echo '192.168.1.4 gluster4'>>/etc/hosts

3.2 配置磁盘

192.168.1.2、192.168.1.3、192.168.1.4分别配置(磁盘的添加这里就不写如何操作了,根据不同的实体机或者虚拟机添加即可。)

mkfs.xfs -i size=512 /dev/sdb1
mkdir -p /data/brick1
echo '/dev/sdb1 /data/brick1 xfs defaults 1 2' >> /etc/fstab
mount -a && mount
mkdir -p /data/brick1/gv0

3.3 配置信任池

192.168.1.2上面执行

# gluster peer gluster3
# gluster peer gluster4

3.4 配置卷

gluster volume create gv0 replica 3 gluster2:/data/brick1/gv0 gluster3:/data/brick1/gv0 gluster4:/data/brick1/gv0
gluster volume start gv0

3.5 挂载glusterfs卷

mkdir /mnt
mount -t glusterfs gluster2:/gv0 /mnt

3.6 写入文件

for i in `seq -w 1 100`; do cp -rp /var/log/messages /mnt/copy-test-$i; done
Previous Post

glusterfs简介

Next Post

glusterfs调优

Related Posts