建立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