ceph image快照功能


1、查看現有池
[root@ceph-client ~]# ceph osd lspools
0 rbd,
注意:另創建的pool name不可含有特殊字符,如“-”等
 
2、查看當前目錄文件
[root@ceph-client mnt]# df -Th | grep rbd
/dev/rbd0             ext4       20G   44M   19G   1% /mnt
[root@ceph-client mnt]# ll
total 16
drwx------ 2 root root 16384 Feb 26 18:32 lost+found
 
3、創建image快照
[root@ceph-client mnt]# rbd ls
foo
列出rbd池中的image
 
[root@ceph-client mnt]# rbd snap create rbd/foo@foo_snap1
命令模式:rbd/foo@foo_snap1代表rbd池中foo鏡像,快照取名foo_snap1
 
[root@ceph-client mnt]# rbd snap ls rbd/foo
SNAPID NAME          SIZE
     2 foo_snap1 20480 MB
 
4、測試快照
 
[root@ceph-client mnt]# touch test{1..5}.file
[root@ceph-client 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掛載
[root@ceph-client ~]# umount /mnt/
[root@ceph-client ~]# rbd unmap /dev/rbd0
 
執行回滾
[root@ceph-client ~]# rbd snap rollback rbd/foo@foo_snap1
Rolling back to snapshot: 100% complete...done.
 
重新掛載
[root@ceph-client ~]# rbd map rbd/foo
/dev/rbd0
[root@ceph-client ~]# mount /dev/rbd0 /mnt/
[root@ceph-client ~]# ll /mnt/
total 16
drwx------ 2 root root 16384 Feb 26 18:32 lost+found
 
驗證成功
 
5、刪除快照
 
[root@ceph-client ~]# rbd snap rm rbd/foo@foo_snap1
刪除指定快照
 
[root@ceph-client ~]# rbd snap purge rbd/foo
刪除所有快照
 
如果刪除時報錯“ librbd: removing snapshot from header failed: (16) Device or resource busy”
執行如下:
 
[root@ceph-admin ~]# rbd snap ls images/9e196534-03e3-484f-bfab-764ef336d82a
SNAPID NAME     SIZE
     2 snap 12047 kB
 
[root@ceph-admin ~]# rbd snap rm images/9e196534-03e3-484f-bfab-764ef336d82a@snap
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
 
[root@ceph-admin ~]# rbd snap unprotect images/9e196534-03e3-484f-bfab-764ef336d82a@snap
 
[root@ceph-admin ~]# rbd snap rm images/9e196534-03e3-484f-bfab-764ef336d82a@snap
 
[root@ceph-admin ~]# rbd snap ls images/9e196534-03e3-484f-bfab-764ef336d82a


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM