官术网_书友最值得收藏!

  • Ceph Cookbook
  • Karan Singh
  • 323字
  • 2021-07-16 13:01:17

Working with RBD snapshots

Ceph extends full support to snapshots, which are point-in-time, read-only copies of an RBD image. You can preserve the state of a Ceph RBD image by creating snapshots and restoring the snapshot to get the original data.

How to do it…

Let's see how a snapshot works with Ceph.

  1. To test the snapshot functionality of Ceph, let's create a file on the block device that we created earlier:
    # echo "Hello Ceph This is snapshot test" > /mnt/ceph-disk1/snapshot_test_file
  2. Create a snapshot for the Ceph block device:

    Syntax: rbd snap create <pool-name>/<image-name>@<snap-name>

    # rbd snap create rbd/rbd1@snapshot1 --name client.rbd
    
  3. To list the snapshots of an image, use the following:

    Syntax: rbd snap ls <pool-name>/<image-name>

    # rbd snap ls rbd/rbd1 --name client.rbd
    
  4. To test the snapshot restore functionality of Ceph RBD, let's delete files from the filesystem:
    # rm -f /mnt/ceph-disk1/*
    
  5. We will now restore the Ceph RBD snapshot to get back the files that we deleted in the last step. Please note that a rollback operation will overwrite the current version of the RBD image and its data with the snapshot version. You should perform this operation carefully:

    Syntax: rbd snap rollback <pool-name>/<image-name>@<snap-name>

    # rbd snap rollback rbd/rbd1@snapshot1 --name client.rbd
    
  6. Once the snapshot rollback operation is completed, remount the Ceph RBD filesystem to refresh the filesystem state. You should be able to get your deleted files back:
    # umount /mnt/ceph-disk1
    # mount /dev/rbd1 /mnt/ceph-disk1
    # ls -l /mnt/ceph-disk1
    
  7. When you no longer need snapshots, you can remove a specific snapshot using the following syntax. Deleting the snapshot will not delete your current data on the Ceph RBD image:

    Syntax: rbd snap rm <pool-name>/<image-name>@<snap-name>

    # rbd snap rm rbd/rbd1@snapshot1 --name client.rbd
    
  8. If you have multiple snapshots of an RBD image and you wish to delete all the snapshots with a single command, then use the purge sub command:

    Syntax: rbd snap purge <pool-name>/<image-name>

    # rbd snap purge rbd/rbd1 --name client.rbd
    
主站蜘蛛池模板: 叶城县| 宜阳县| 额尔古纳市| 翼城县| 上杭县| 灵宝市| 溧水县| 阿拉善右旗| 启东市| 湘潭县| 富川| 台南市| 华宁县| 仙居县| 乐东| 临沂市| 菏泽市| 体育| 重庆市| 休宁县| 永寿县| 尚志市| 永平县| 界首市| 韶山市| 波密县| 望江县| 上蔡县| 德钦县| 申扎县| 尼勒克县| 扶风县| 依兰县| 乳山市| 惠东县| 濮阳县| 湟源县| 赤峰市| 密山市| 高尔夫| 霍州市|