环境说明:
4台机器安装 GlusterFS 组成一个 Distributed Replicated Volumes集群
服务器:
10.64.42.96
10.64.42.113
10.64.42.115
10.64.42.117
客户端:
10.64.42.98
1.准备工作
关闭iptables和selinux
2.安装glusterFS服务器
4台服务器安装glusterFS
yum install centos-release-gluster
yum install -y glusterfs glusterfs-server glusterfs-fuse glusterfs-rdma
3.启动
systemctl start glusterd
设置开机启动
systemctl enable glusterd
4.加入 trusted storage pool
在任意节点执行 gluster peer probe,本文在10.64.42.113执行
gluster peer probe 10.64.42.115
gluster peer probe 10.64.42.117
gluster peer probe 10.64.42.96
查看节点信息
gluster peer status
5.创建数据存储目录
所有节点创建目录
mkdir -p /gluster/data
6.创建Distributed Replicated Volumes
gluster volume create file-service replica 2 transport tcp 10.64.42.113:/gluster/data 10.64.42.115:/gluster/data 10.64.42.117:/gluster/data 10.64.42.96:/gluster/data
这条命令的意思是使用Replicated的方式,建立一个名为file-service的卷(Volume),存储块(Brick)为4个
启动volume
gluster volume start file-service
查看 volume状态
gluster volume info
7.安装客户端
在客户端执行
yum -y install glusterfs glusterfs-fuse
创建目录
mkdir /gluster/data
将服务器上的逻辑卷file-service挂在到本地/gluster/data
mount -t glusterfs 10.64.42.113:/file-service /gluster/data
查看挂在
df -h
8.测试
在客户端挂载目录/gluster/data建立文件以测试GlusterFS是否正常工作。
cd /gluster/data
touch file1 file2 file3
因为建立的是Distributed Replicated Volumes,所以在客户端写入的文件会同时出现在10.64.42.113:/gluster/data和10.64.42.115:/gluster/data 或者同时出现在10.64.42.117:/gluster/data和10.64.42.96:/gluster/data
注意
volume create: file-service: Failed: The brick
10.53.32.113:/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 <VOLNAME> 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