Cephfs的快照功能
前言
Cephfs的快照功能在官网都很少提及,因为即使开发了很多年,但是由于cephfs的复杂性,功能一直没能达到稳定,这里,只是介绍一下这个功能,怎么使用,并且建议不要在生产中使用,因为搞不好是会丢数据的
功能介绍
首先这个功能是默认关闭的,所以需要开启
[root@lab8106 ~]# ceph fs set ceph allow_new_snaps 1
Error EPERM: Warning! This feature is experimental.It may cause problems up to and including data loss.Consult the documentation at ceph.com, and if unsure, do not proceed.Add --yes-i-really-mean-it if you are certain.
[root@lab8106 ~]# ceph fs set ceph allow_new_snaps 1 --yes-i-really-mean-it
从提示上可以看到,还是不要在生产上使用
开发者的话:
In Jewel ceph fs snapshots are still experimental. Does someone has a clue when this would become stable, or how experimental this is ?
We're not sure yet. Probably it will follow stable multi-MDS; we're thinking about redoing some of the core snapshot pieces still. 😕
WIt's still pretty experimental in Jewel. Shen had been working on this and I think it often works, but tends to fall apart under the failure of other components (eg, restarting an MDS while snapshot work is happening).
-Greg
挂载集群
[root@lab8106 ~]# mount -t ceph 192.168.8.106:/ /mnt
[root@lab8106 ~]# cd /mnt/
快照是对目录创建的
所以我们来看下
[root@lab8106 mnt]# ll
total 0
drwxr-xr-x 1 root root 51341 Dec 13 11:41 test1
drwxr-xr-x 1 root root 51591 Dec 13 16:18 test2
drwxr-xr-x 1 root root 30951 Dec 13 15:19 test3
创建快照
[root@lab8106 mnt]# mkdir .snap/snap1
[root@lab8106 mnt]# ll .snap/
total 0
drwxr-xr-x 1 root root 133883 Dec 13 14:21 snap1
[root@lab8106 mnt]# ll .snap/snap1
total 0
drwxr-xr-x 1 root root 51341 Dec 13 11:41 test1
drwxr-xr-x 1 root root 51591 Dec 13 16:18 test2
drwxr-xr-x 1 root root 30951 Dec 13 15:19 test3
创建快照很简单,就是在需要做快照的目录下面执行 mkdir .snap/snapname
后面接快照的名称
快照的速度非常快,秒级别的
恢复快照数据
[root@lab8106 mnt]# cp -ra .snap/snap1/* ./
删除快照
[root@lab8106 mnt]# rmdir .snap/snap1
删除快照需要用rmdir命令
总结
本篇简单的介绍了下cephfs快照的相关的操作,自己很久没搞,命令都找不到了,供参考