Ceph Reef(18.2.X)的基于回收站临时删除块设备

                                              作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.准备测试环境

1.创建存储池

[root@ceph141 ~]# ceph osd pool create yinzhengjie 2 2
pool 'yinzhengjie' created
[root@ceph141 ~]# 

2.对存储池启用rbd功能

[root@ceph141 ~]# ceph osd pool application get yinzhengjie
{}
[root@ceph141 ~]# 
[root@ceph141 ~]# ceph osd pool application enable yinzhengjie rbd
enabled application 'rbd' on pool 'yinzhengjie'
[root@ceph141 ~]# 
[root@ceph141 ~]# ceph osd pool application get yinzhengjie
{
    "rbd": {}
}
[root@ceph141 ~]# 

3.对存储池进行环境初始化

[root@ceph141 ~]# rbd pool init yinzhengjie
[root@ceph141 ~]# 
[root@ceph141 ~]# rbd pool stats yinzhengjie
Total Images: 0
Total Snapshots: 0
Provisioned Size: 0 B
[root@ceph141 ~]# 

4.创建块设备

[root@ceph141 ~]# rbd create wordpress -s 4G  -p yinzhengjie 

5.创建块设备详细信息

[root@ceph141 ~]# rbd ls -p yinzhengjie
wordpress
[root@ceph141 ~]# 
[root@ceph141 ~]# rbd info yinzhengjie/wordpress
rbd image 'wordpress':
        size 4 GiB in 1024 objects
        order 22 (4 MiB objects)
        snapshot_count: 0
        id: ad4945cbcd9
        block_name_prefix: rbd_data.ad4945cbcd9
        format: 2
        features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
        op_features: 
        flags: 
        create_timestamp: Wed Aug 28 00:55:28 2024
        access_timestamp: Wed Aug 28 00:55:28 2024
        modify_timestamp: Wed Aug 28 00:55:28 2024
[root@ceph141 ~]# 

二.准备测试环境

1.查看回收站列表

[root@ceph141 ~]# rbd trash ls -p yinzhengjie
[root@ceph141 ~]# 

2.将镜像移动到回收站,模拟删除效果

[root@ceph141 ~]# rbd ls -p yinzhengjie
wordpress
[root@ceph141 ~]# 
[root@ceph141 ~]# rbd trash move yinzhengjie/wordpress  # 将镜像移动到回收站
[root@ceph141 ~]# 
[root@ceph141 ~]# rbd ls -p yinzhengjie  # 将镜像移动到回收站后,存储池就看不到这个块设备了哟~
[root@ceph141 ~]# 
[root@ceph141 ~]# rbd trash ls -p yinzhengjie  # 再次查看回收站,发现有块设备啦!
ad4945cbcd9 wordpress
[root@ceph141 ~]# 
[root@ceph141 ~]# 

3.恢复块设备

[root@ceph141 ~]# rbd trash ls -p yinzhengjie
ad4945cbcd9 wordpress
[root@ceph141 ~]# 
[root@ceph141 ~]# rbd ls -p yinzhengjie
[root@ceph141 ~]# 
[root@ceph141 ~]# rbd trash restore -p yinzhengjie --image wordpress --image-id ad4945cbcd9  # 将块设备进行还原。
[root@ceph141 ~]# 
[root@ceph141 ~]# rbd ls -p yinzhengjie  # 很明显,块设备回来了。
wordpress
[root@ceph141 ~]# 
[root@ceph141 ~]# rbd trash ls -p yinzhengjie  # 查看块设备信息。
[root@ceph141 ~]# 
posted @ 2024-08-28 01:06  尹正杰  阅读(38)  评论(0编辑  收藏  举报