建立peer关系
gluster peer probe node2
gluster peer stat
//查看状态
gluster pool list
- 断开
gluster peer detach node1
创建分布式卷
gluster volume create v1 node1:/data/xx node2:/data/xx
创建复制式卷
gluster volume create v2 replica 2 node1:/data/xx node2:/data/xx force
分布复制式卷
gluster volume create v3 replica 2 node1:/data/xx node2:/data/xx node3:/data/xx node4:/data/xx
NFS挂载
mount node1:/v1 /data
使用原生文件系统挂载
yum install glusterfs-fuse -y
mount.glusterfs node1:/v1 /data
windows使用samba挂载
- 安装samba
yum install samba -y
- 修改权限
useradd -s /sbin/nologin tom
chown .tom mountpoint
chmod 755 mountpoint
umount mountpoint
- 关闭stat-prefetch预取功能
gluster volume set v1 stat-prefetch off
开启非安全访问模式
gluster volume set v1 server.allow-insecure on
- 运行以下命令来验证正确的锁和输入/输出一致性
gluster volume set v1 storage.batch-fsync-delay-usec 0
- 重启该卷
gluster volume stop v1
gluster volume start v1
ACL和配额
使用NFS挂载的时候,默认是支持ACL的
使用glusterfs挂载的时候,默认是不启用ACL的
mount -t glusterfs -o acl node1:/v1 /mnt
启用配额
gluster volume quota v1 enable //关闭为disable
设置配额
- 查看配额
gluster volume quota v1 list
- 设置配额
gluster volume quota v1 limit-usage /mp4 256MB /mp4为卷内的目录
扩展卷
扩容
- 添加brick
gluster volume add-brick v1 node3:/data/xx
gluster volume rebalance v1 start
gluster volume add-brick v2 replica 3 node3:/data/xx force //复制式
复制式卷不需要rebalance
- 删除brick
gluster volume remove-brick v1 node3:/data/xx start
gluster volume remove-brick v1 node3:/data/xx commit
gluster volume remove-brick v2 replica 2 node3:/data/xx force //复制式
gluster volume remove-brick v2 replica 2 node3:/data/xx commit
IP故障转移(CTDB)
-
安装ctdb
yum install ctdb* -y
-
在每个节点编辑
/var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh
,修改META为卷名;例如:META="V2"
-
在每个节点编辑
/var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
,修改META为卷名;例如:META="V2"
-
修改smb.conf
在[global]下添加clustering=yes
-
设置卷的属性
gluster volume set v2 stat-perfetch off
gluster volume set v2 server.allow-insecure on
gluster volume set v2 storage.batch-fsync-delay-usec 0
gluster volume start v2
- CTDB
创建/etc/ctdb/nodestouch /etc/ctdb/nodes
,内容为
ip1
ip2
ip3
ip4
...
创建浮动IP
echo [ip] >> /etc/ctdb/public_addresses
将上述两文件拷贝到其他节点
启动ctdb服务(每个节点)
systemctl start ctdb
systemctl enable ctdb
检查
ctdb -v vip
GEO异步容灾
在node5新建一个卷
lvcreate -L 10G -T vg0/pool1
lvcreate -V 7G -T vg0/pool1 -n lv1
mkfs.xfs /dev/vg0/lv1
mount /dev/vg0/lv1 /data
mkdir /data/xx
gluster volume create v5 node5:/data/xx
gluster volume start v5
useradd bob ; echo redhat | passwd --stdin bob
mkdir /var/root
chmod 711 /var/root
vim /etc/glusterfs/glusterd.vol
option mountbroker-root /var/root
option mountbroker-geo-replication.bob v5
option geo-replication-log-group bob
option rpc-auth-alllow-insecure on
systemctl restart glusterd
- 1、在主节点配置秘钥登录
ssh-keygen
ssh-copy-id bob@node5
gluster system:: execute gsec_create
gluster volume geo-replication v1 bob@node5::v5 create push-pem //建立geo关系
gluster volume geo-replication v1 bob@node5::v5 stop
- 2、备节点上建立主辅关系
/usr/libexec/glusterfs/set_geo_rep_pem_keys.sh bob v1 v5
- 3、主节点进行备份
gluster volume geo-replication v1 bob@node5::v5 start
gluster volume geo-replication v1 bob@node5::v5 status //查看同步状态
快照管理
gluster snapshot list //查看快照
gluster snapshot create v1_s1 v1 //创建快照
gluster snapshot restore v1_s1 //恢复快照,恢复之前先stop掉原来的卷
如果是复制式的卷,检查哪些文件需要修复gluster volume heal v1 info
tiering类型卷
创建普通类型的code peer
gluster volume create v4 node3:/vol/yy node4:/vol/yy
gluster volume start v4
增加brick(hot peer)
gluster volume tier v4 attach replica 2 node1:/vol/yy node2:/vol/yy
删除tiering类型卷
gluster volume tier v4 detach start //移除hot peer
gluster volume tier v4 detach commit