- Ceph Cookbook(Second Edition)
- Vikhyat Umrao Michael Hackett Karan Singh
- 339字
- 2021-07-02 23:19:10
How to do it...
Let's see how a snapshot works with Ceph:
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

- 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
- To list the snapshots of an image, use the following syntax:
# rbd snap ls <pool name>/<image name>
# rbd snap ls rbd/rbd1

- To test the snapshot restore functionality of Ceph RBD, let's delete files from the filesystem:
# rm -f /mnt/ceph-disk1/*
- 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.
- 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

- 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
- 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
- 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
推薦閱讀
- Dreamweaver CS3+Flash CS3+Fireworks CS3創(chuàng)意網(wǎng)站構(gòu)建實(shí)例詳解
- 條碼技術(shù)及應(yīng)用
- FPGA/CPLD應(yīng)用技術(shù)(Verilog語(yǔ)言版)
- 統(tǒng)計(jì)挖掘與機(jī)器學(xué)習(xí):大數(shù)據(jù)預(yù)測(cè)建模和分析技術(shù)(原書(shū)第3版)
- Visual Studio 2010 (C#) Windows數(shù)據(jù)庫(kù)項(xiàng)目開(kāi)發(fā)
- ZigBee無(wú)線通信技術(shù)應(yīng)用開(kāi)發(fā)
- 工業(yè)機(jī)器人力覺(jué)視覺(jué)控制高級(jí)應(yīng)用
- HBase Essentials
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)實(shí)訓(xùn)(職業(yè)模塊)
- Data Analysis with R(Second Edition)
- WPF專業(yè)編程指南
- 分布式Java應(yīng)用
- Practical Network Automation
- 超好玩的Python少兒編程
- Mastering Android Game Development with Unity