• RBD介绍


    一、RBD回收

    # 1、创建一块盘
    [root@node1 ~]# rbd create ceph-demo/ceph-trash.img --size 1G
    
    # 2、info
    [root@node1 ~]# rbd info ceph-demo/ceph-trash.img       
    rbd image 'ceph-trash.img':
            size 1 GiB in 256 objects
            order 22 (4 MiB objects)
            snapshot_count: 0
            id: 283b35df6c430
            block_name_prefix: rbd_data.283b35df6c430
            format: 2
            features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
            op_features: 
            flags: 
            create_timestamp: Mon Jan 25 17:46:29 2021
            access_timestamp: Mon Jan 25 17:46:29 2021
            modify_timestamp: Mon Jan 25 17:46:29 2021
            
    # 3、删除(如果这样删,直接就没了)
    [root@node1 ~]# rbd rm ceph-demo/ceph-trash.img     
    Removing image: 100% complete...done.
    
    # 4、回收站查看,也是没有的
    [root@node1 ~]# rbd -p  ceph-demo trash ls
    
    # 5、再次创建,然后通过回收站的形式删除
    [root@node1 ~]# rbd create ceph-demo/ceph-trash.img --size 1G
    --expires-at  指定过期时间
    [root@node1 ~]# rbd trash  move ceph-demo/ceph-trash.img --expires-at 20201126
    
    # 6、查看
    [root@node1 ~]# rbd -p  ceph-demo trash ls
    2cff636e77644(回收就通过这个id回收) ceph-trash.img
    
    # 7、回收操作
    [root@node1 ~]# rbd trash restore -p ceph-demo 2cff636e77644
    [root@node1 ~]# rbd -p  ceph-demo trash ls                  
    [root@node1 ~]# rbd -p  ceph-demo ls  # 恢复
    ceph-trash.img
    rbd-demo.img
    

    二、RBD快照

    也是一种备份的形式

    [root@node1 ~]# rbd create ceph-demo/rbd-test.img --image-feature layering --size 1G
    
    [root@node1 ~]# rbd info  ceph-demo/rbd-test.img
    rbd image 'rbd-test.img':
            size 1 GiB in 256 objects
            order 22 (4 MiB objects)
            snapshot_count: 0
            id: 2d00bff5c0ac4
            block_name_prefix: rbd_data.2d00bff5c0ac4
            format: 2
            features: layering
            op_features: 
            flags: 
            create_timestamp: Mon Jan 25 18:14:45 2021
            access_timestamp: Mon Jan 25 18:14:45 2021
            modify_timestamp: Mon Jan 25 18:14:45 2021
            
    # 3、映射到本地文件系统,然后挂载起来
    [root@node1 ~]# rbd device map  ceph-demo/rbd-test.img   
    /dev/rbd0
    [root@node1 ~]# mkfs.ext4  /dev/rbd0
    [root@node1 ~]# mkdir /mnt/test1
    [root@node1 ~]# mount /dev/rbd0 /mnt/test1
    
    # 4、进到这里问价夹,创建一些文件,然后打快照,删除原来的,再恢复
    [root@node1 ~]# cd /mnt/test1; echo 111 > test
    
    # 5、打快照
    [root@node1 ~]# rbd snap create ceph-demo/rbd-test.img@snap_2021125
    [root@node1 ~]# rbd snap ls ceph-demo/rbd-test.img    
    SNAPID   NAME         SIZE        PROTECTED TIMESTAMP                
       4     snap_2021125 1 GiB     Mon Jan 25 19:03:38 2021
       
    # 6、误删数据、然后恢复数据(恢复之前的快照)
    [root@node1 test1]# rm -rf test # 模拟删除
    [root@node1 test1]# rbd snap rollback ceph-demo/rbd-test.img@snap_2021125   # 回滚
    Rolling back to snapshot: 100% complete...done.
    
    # 7、查看文件是否恢复(显然没有,因为文件回滚的时候是离线的)。得卸载这个盘,再挂载才有
    [root@node1 test1]# ll
    [root@node1 ~]# umount /mnt/test1/
    [root@node1 ~]# mount /dev/rbd0  /mnt/test1/ 
    
    # 8、克隆快照、父子关系解除
    

    三、RBD备份与恢复

    # 1、查看现在有的快照
    [root@node1 ~]# rbd snap ls ceph-demo/rbd-test.img    
    SNAPID   NAME         SIZE        PROTECTED TIMESTAMP                
       4     snap_2021125 1 GiB     Mon Jan 25 19:03:38 2021
       
    # 2、导出快照、备份快照
    [root@node1 ~]# rbd export ceph-demo/rbd-test.img@snap_2021125  /app/rbd-test.img
    Exporting image: 100% complete...done.
    
    # 3、导入快照、恢复快照
    [root@node1 ~]# rbd import /app/rbd-test.img ceph-demo/rbd-test-new.img
    Importing image: 100% complete...done.
    

    四、RBD增量备份与增量恢复

    [root@node1 ~]# rbd export-diff ceph-demo/rbd-test.img@snap_2021125  /app/rbd-test1.img                     
    Exporting image: 100% complete...done.
    [root@node1 ~]# ll -h /app/rbd-test1.img 
    -rw-r--r-- 1 root root 5.8M Jan 25 19:54 /app/rbd-test1.img
    
    [root@node1 ~]# rbd import-diff /app/rbd-test1.img ceph-demo/rbd-test-new.img  
    
    # 3、查看文件是否恢复(显然没有,因为文件回滚的时候是离线的)。得卸载这个盘,再挂载才有
    [root@node1 test1]# ll
    [root@node1 ~]# umount /mnt/test1/
    [root@node1 ~]# mount /dev/rbd0  /mnt/test1/ 
    

    {{uploading-image-857883.png(uploading...)}}

  • 相关阅读:
    相机标定之四个坐标系及其关系
    VR、AR和MR的区别?
    Django 中使用流响应处理视频的方法
    mysql_num_fielfs_php mysql_num_rows和mysql_num_fields获取结果集总行数和总列数
    mysql中文乱码
    redisson分布式锁:Redis分布式锁报错,Redisson出错:Unable to send command!
    SpringBoot整合redis, RedisTemplate默认使用Lettuce客户端超时问题
    spring security登录后访问接口403 forbidden的坑
    redis锁,redis分布式锁: RedisLock
    微信urlscheme.generate:h5跳转到小程序(支持微信内h5,浏览器)
  • 原文地址:https://www.cnblogs.com/hsyw/p/14541069.html
Copyright © 2020-2023  润新知