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

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
  1. Create a snapshot for the Ceph Block Device. Syntax for the same is as follows:
        # rbd snap create <pool name>/<image name>@<snap name>
# rbd snap create rbd/rbd1@snapshot1
  1. To list the snapshots of an image, use the following syntax:
        # rbd snap ls <pool name>/<image name>
# rbd snap ls rbd/rbd1
  1. To test the snapshot restore functionality of Ceph RBD, let's delete files from the filesystem:
 # rm -f /mnt/ceph-disk1/*
  1. 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. The syntax is as follows:
        # rbd snap rollback <pool-name>/<image-name>@<snap-name>
# umount /mnt/ceph-disk1
# rbd snap rollback rbd/rbd1@snapshot1 --name client.rbd

Prior to the rollback operation the filesystem was unmounted to validate a refreshed filesystem state after the rollback.

  1. 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:
         # mount /dev/rbd0 /mnt/ceph-disk1
# ls -l /mnt/ceph-disk1
  1. You are also able to rename snapshots if you so choose. The syntax is as follows:
        #rbd snap rename <pool-name>/<image-name>@<original-snapshot-
name> <pool-name>/<image-name>@<new-snapshot-name>

# rbd snap rename rbd/rbd1@snapshot1 rbd/rbd1@snapshot1_new
  1. 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:
        # rbd snap rm <pool-name>/<image-name>@<snap-name>
# rbd snap rm rbd/rbd1@snapshot1 --name client.rbd
  1. 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 subcommand. The syntax is as follows:
         # rbd snap purge <pool-name>/<image-name>
# rbd snap purge rbd/rbd1 --name client.rbd
主站蜘蛛池模板: 启东市| 广平县| 那坡县| 运城市| 凭祥市| 大埔县| 宾阳县| 莒南县| 丰镇市| 三都| 浏阳市| 汕头市| 丰县| 乌兰浩特市| 怀集县| 保靖县| 武清区| 西平县| 彰武县| 东乡县| 苍溪县| 宣武区| 阿巴嘎旗| 贵南县| 商都县| 内黄县| 庆云县| 江源县| 松溪县| 高青县| 东宁县| 安徽省| 永寿县| 微山县| 贵南县| 涡阳县| 班玛县| 龙里县| 东辽县| 七台河市| 康保县|