环境准备
4台机器 1G 内存 2块硬盘 第二块5G大小用于存储
- stroage01 10.10.80.3
- stroage02 10.10.80.4
- stroage03 10.10.80.5
- stroage04 10.10.80.6
[root@stroage01 ~]#fdisk /dev/sdb
[root@stroage01 ~]#mkdir /gfs
[root@stroage01 ~]#mkfs.ext4 /dev/sdb1
[root@stroage01 ~]#mount /dev/sdb1 /gfs
[root@stroage01 ~]#echo "/dev/sdb1 /gfs ext4 defaults 0 0 ">> /etc/fstab
配置
4台存储的hosts文件添加4行,如下:
[root@stroage01 ~]#cat /etc/hosts
stroage01 10.10.80.3
stroage02 10.10.80.4
stroage03 10.10.80.5
stroage04 10.10.80.6
[root@stroage01 ~]#yum localinstall glusterfs-* //下面这些包
[root@stroage01 ~]#/etc/init.d/glusterd start
[root@stroage01 ~]#chkconfig glusterfsd on
其它配置均可在1台机器上完成,我在stroage01操作。
[root@stroage01 ~]#gluster peer probe stroage01 //会提示本机不需要
[root@stroage01 ~]#gluster peer probe stroage02
[root@stroage01 ~]#gluster peer probe stroage03
[root@stroage01 ~]#gluster peer probe stroage04
[root@stroage01 ~]#gluster peer status //查看状态
[root@stroage01 ~]#mkdir /gfs/data //创建数据目录
[root@stroage01 ~]#gluster volume create s1 stripe 2 stroage01:/gfs/data stroage02:/gfs/data force //创建条带卷
[root@stroage01 ~]#gluster volume create s2 replica 2 stroage03:/gfs/data stroage04:/gfs/data force //创建复制卷
[root@stroage01 ~]#gluster volume info
[root@stroage01 ~]#gluster volume start s1
[root@stroage01 ~]#gluster volume start s2 //启动卷
挂载验证
在计算服务器01,02创建挂载目录验证
在01上创建的文件 在02上可以看见表示成功
巡检命令
gluster volume status
#启动完全修复 gluster volume heal s2 full
#查看需要修复的文件 gluster volume heal s2 info
#查看修复成功的文件 gluster volume heal s2 info healed
#查看修复失败的文件 gluster volume heal s2 heal-failed
#查看主机的状态 gluster peer status
#查看脑裂的文件 gluster volume heal s2 info split-brain
#激活quota功能 gluster volume quota s2 enable
#关闭quota功能 gulster volume quota s2 disable
#目录限制(卷中文件夹的大小) gluster volume quota s2 limit-usage /data 20MB --表示/mnt挂载点下的data目录
#quota信息列表 gluster volume quota s2 list
#限制目录的quota信息 gluster volume quota s2 list /data
#设置信息的超时时间 gluster volume set s2 features.quota-timeout 5
#删除某个目录的quota设置 gluster volume quota s2 remove /data