GlusterFS集群

使用架构:

2台机器安装 GlusterFS 组成一个 Distributed Replicated Volumes集群

192.168.0.92 服务端
192.168.0.93 服务端
192.168.0.91 客户端


环境配置请参照:https://www.cnblogs.com/effortsing/p/10367025.html      #关掉selinux、防火墙


2台服务器安装glusterFS

yum install centos-release-gluster -y

yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma

3.启动

systemctl start glusterd

设置开机启动

systemctl enable glusterd


4.加入 trusted storage pool

在任意节点执行 gluster peer probe,本文在192.168.0.92执行

gluster peer probe 192.168.0.93


查看节点信息

gluster peer status



5.创建数据存储目录

所有节点创建目录

mkdir -p /gluster/data/



6.创建Distributed Replicated Volumes

gluster volume create file-service replica 2 transport tcp 192.168.0.92:/gluster/data/ 192.168.0.93:/gluster/data/ force

这条命令的意思是使用Replicated的方式,建立一个名为file-service的卷(Volume),存储块(Brick)为2个

只在其中一个节点执行


启动volume

gluster volume start file-service

只在其中一个节点执行


查看 volume状态

gluster volume info


7.安装客户端

在客户端执行

yum -y install glusterfs glusterfs-fuse

创建目录

mkdir -p /gluster/data/

将服务器上的逻辑卷file-service挂在到本地/gluster/data

mount -t glusterfs 192.168.0.92:/file-service /gluster/data

查看挂在

df -h


8.测试

在客户端挂载目录/gluster/data建立文件以测试GlusterFS是否正常工作。

cd /gluster/data

touch file1 file2 file3

因为建立的是Distributed Replicated Volumes,所以在客户端写入的文件会同时出现在192.168.0.92:/gluster/data和192.168.0.93:/gluster/data 

注意

volume create: file-service: failed: The brick

192.168.0.92:/gluster/data is being created in the root partition. It is recommended that you don’t use the system’s root partition for

storage backend. Or use ‘force’ at the end of the command if you want

to override this behavior.

这是因为我们创建的brick在系统盘,这个在gluster的默认情况下是不允许的,如果必须这样请使用force


GlusterFS 几种volume 模式说明:

一、 Distributed Volumes,默认模式,DHT

gluster volume create test-volume server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4


二、 Replicated Volumes,复制模式,AFR

gluster volume create test-volume replica 2 transport tcp server1:/exp1 server2:/exp2


避免脑裂,加入仲裁

gluster volume create replica 3 arbiter 1 host1:brick1 host2:brick2 host3:brick3`


三、Striped Volumes

gluster volume create test-volume stripe 2 transport tcp server1:/exp1 server2:/exp2


四、Distributed Striped Volumes,最少需要4台服务器。

gluster volume create test-volume stripe 4 transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4 server5:/exp5 server6:/exp6 server7:/exp7 server8:/exp8


五、Distributed Replicated Volumes,最少需要4台服务器。

gluster volume create test-volume replica 2 transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4


六、Distributed Striped Replicated Volumes

gluster volume create test-volume stripe 2 replica 2 transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4 server5:/exp5 server6:/exp6 server7:/exp7 server8:/exp8


七、Striped Replicated Volumes

gluster volume create test-volume stripe 2 replica 2 transport tcp server1:/exp1 server2:/exp2 server3:/exp3 server4:/exp4



参照文档:

https://www.2cto.com/kf/201712/704742.html

 

上一篇:Glusterfs的常用命令


下一篇:GlusterFS