内容纲要
实验环境(client node1 node2)
1.建立一个存储v2并启用
gluster volume create v2 node1:/data/xx node2:/data/xx
gluster volume start v2
2.对v2做一个快照,首先查看一下快照的帮助。
[root@node1 ~]# gluster help | grep snapshot
snapshot help - display help for snapshot commands
snapshot create <snapname> <volname> [no-timestamp] [description <description>] [force] - Snapshot Create.
snapshot clone <clonename> <snapname> - Snapshot Clone.
snapshot restore <snapname> - Snapshot Restore.
snapshot status [(snapname | volume <volname>)] - Snapshot Status.
snapshot info [(snapname | volume <volname>)] - Snapshot Info.
snapshot list [volname] - Snapshot List.
snapshot config [volname] ([snap-max-hard-limit <count>] [snap-max-soft-limit <percent>]) | ([auto-delete <enable|disable>])| ([activate-on-create <enable|disable>]) - Snapshot Config.
snapshot delete (all | snapname | volume <volname>) - Snapshot Delete.
snapshot activate <snapname> [force] - Activate snapshot volume.
snapshot deactivate <snapname> - Deactivate snapshot volume.
3.把v2挂在到client上,创建20个文件。
[root@client ~]# mount node1:/v2 /v2
[root@client ~]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/vda1 xfs 20G 1.3G 19G 7% /
devtmpfs devtmpfs 488M 0 488M 0% /dev
tmpfs tmpfs 497M 0 497M 0% /dev/shm
tmpfs tmpfs 497M 6.7M 490M 2% /run
tmpfs tmpfs 497M 0 497M 0% /sys/fs/cgroup
tmpfs tmpfs 100M 0 100M 0% /run/user/0
node1:/v2 nfs 2.0G 33M 2.0G 2% /v2
[root@client ~]# touch /v2/aa{1..20}.txt
4.对v2建立一个快照
[root@node1 ~]# gluster snapshot create backupv2 v2
5.查看这个快照
[root@node1 ~]# gluster snapshot list
backupv2_GMT-2020.02.03-03.35.12
6.client中删除20个文件,node1中没有任何的数据
[root@client v2]# rm -rf /v2/*
[root@node1 ~]# ls /data/xx/
[root@node1 ~]#
7.卸载client挂载的v2卷,然后停止v2卷,做快照恢复。
[root@client /]# umount /v2/
[root@node1 ~]# gluster volume stop v2
[root@node1 ~]# gluster snapshot restore backupv2_GMT-2020.02.04-02.33.56
Restore operation will replace the original volume with the snapshotted volume. Do you still want to continue? (y/n) y
Snapshot restore: backupv2_GMT-2020.02.04-02.33.56: Snap restored successfully
8.开启v2卷并挂载到client查看数据
[root@node1 ~]# gluster volume start v2
[root@client /]# mount node1:/v2 /v2
[root@client /]# cd /v2/
[root@client v2]# ls
aa10.txt aa13.txt aa16.txt aa19.txt aa2.txt aa5.txt aa8.txt
aa11.txt aa14.txt aa17.txt aa1.txt aa3.txt aa6.txt aa9.txt
aa12.txt aa15.txt aa18.txt aa20.txt aa4.txt aa7.txt