关键词
gluster glusterfs 安装 复制卷
目标
- 两台机器,两块数据盘,构成复制卷
- 一台机器宕机,不影响服务
必须存在数据盘,数据盘需要格式化
机器
192.168.31.100 #GlusterFS Server CentOS7.9
192.168.31.101 #GlusterFS Server CentOS7.9
192.168.31.102 #GlusterFS Client CentOS7.9
服务端部署
安装(两台机器都执行)
================================
yum -y install centos-release-gluster
yum -y install glusterfs-server
启动(两台机器都执行)
================================
systemctl start glusterd.service
systemctl enable glusterd.service
systemctl status glusterd.service
glusterfsd --version
集群互信(两台机器都执行)
================================
gluster peer probe 192.168.31.100
gluster peer probe 192.168.31.101
gluster peer status
格式化磁盘并挂载(两台机器都执行)
================================
mkfs.xfs -i size=512 /dev/sdb
mkdir -p /gluster/sdb/gv0
echo "/dev/sdb /gluster/sdb xfs defaults 0 0" >> /etc/fstab
mount -a
创建分卷(任意一台机器执行)
================================
gluster volume create gv0 replica 2 192.168.31.100:/gluster/sdb/gv0 192.168.31.101:/gluster/sdb/gv0
gluster volume start gv0
gluster volume info
客户端部署
yum -y install glusterfs-client
mkdir /mnt/glusterfs
mount -t glusterfs 192.168.31.100:/gv0 /mnt/glusterfs
#使用任何一个Server IP地址均可,并且任何一台Server挂掉,服务均正常
#现在即可往/mnt/gluster写入数据,会自动落在两台Server /gluster/sdb/gv0目录
#如果需要开机挂载,可以写入到/etc/rc.local里
写入测试数据,可以使用
mkdir -p /mnt/glusterfs/just-test
for i in `seq -w 1 100`; do cp -rp /var/log/messages /mnt/glusterfs/just-test/copy-test-$i; done
参考资料
https://www.howtoforge.com/tutorial/high-availability-storage-with-glusterfs-on-centos-7/
https://wiki.centos.org/SpecialInterestGroup/Storage/gluster-Quickstart