1、查看现有池
[[email protected] ~]# ceph osd lspools
0 rbd,
注意:另创建的pool name不可含有特殊字符,如“-”等
2、查看当前目录文件
[[email protected] mnt]# df -Th | grep rbd /dev/rbd0 ext4 20G 44M 19G 1% /mnt [[email protected] mnt]# ll total 16 drwx------ 2 root root 16384 Feb 26 18:32 lost+found |
3、创建image快照
[[email protected] mnt]# rbd ls foo 列出rbd池中的image [[email protected] mnt]# rbd snap create rbd/[email protected]_snap1 命令模式:rbd/[email protected]_snap1代表rbd池中foo镜像,快照取名foo_snap1 [[email protected] mnt]# rbd snap ls rbd/foo SNAPID NAME SIZE 2 foo_snap1 20480 MB |
4、测试快照
[[email protected] mnt]# touch test{1..5}.file [[email protected] mnt]# ll total 16 drwx------ 2 root root 16384 Feb 26 18:32 lost+found -rw-r--r-- 1 root root 0 Feb 29 12:45 test1.file -rw-r--r-- 1 root root 0 Feb 29 12:45 test2.file -rw-r--r-- 1 root root 0 Feb 29 12:45 test3.file -rw-r--r-- 1 root root 0 Feb 29 12:45 test4.file -rw-r--r-- 1 root root 0 Feb 29 12:45 test5.file 回滚快照 需要先卸载rbd挂载 [[email protected] ~]# umount /mnt/ [[email protected] ~]# rbd unmap /dev/rbd0 执行回滚 [[email protected] ~]# rbd snap rollback rbd/[email protected]_snap1 Rolling back to snapshot: 100% complete...done. 重新挂载 [[email protected] ~]# rbd map rbd/foo /dev/rbd0 [[email protected] ~]# mount /dev/rbd0 /mnt/ [[email protected] ~]# ll /mnt/ total 16 drwx------ 2 root root 16384 Feb 26 18:32 lost+found 验证成功 |
5、删除快照
[[email protected] ~]# rbd snap rm rbd/[email protected]_snap1 删除指定快照 [[email protected] ~]# rbd snap purge rbd/foo 删除所有快照 |
如果删除时报错“librbd: removing snapshot from header failed: (16) Device or resource busy”
执行如下:
[[email protected] ~]# rbd snap ls images/9e196534-03e3-484f-bfab-764ef336d82a SNAPID NAME SIZE 2 snap 12047 kB [[email protected] ~]# rbd snap rm images/[email protected] rbd: snapshot ‘snap‘ is protected from removal. 2016-03-21 10:44:34.359028 7f155ac527c0 -1 librbd: removing snapshot from header failed: (16) Device or resource busy [[email protected] ~]# rbd snap unprotect images/[email protected] [[email protected] ~]# rbd snap rm images/[email protected] [[email protected] ~]# rbd snap ls images/9e196534-03e3-484f-bfab-764ef336d82a |