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

Working with RBD Clones

Ceph supports a very nice feature for creating Copy-On-Write (COW) clones from RBD snapshots. This is also known as Snapshot Layering in Ceph. Layering allows clients to create multiple instant clones of Ceph RBD. This feature is extremely useful for cloud and virtualization platforms such as OpenStack, CloudStack, Qemu/KVM, and so on. These platforms usually protect Ceph RBD images containing an OS / VM image in the form of a snapshot. Later, this snapshot is cloned multiple times to spawn new virtual machines / instances. Snapshots are read-only, but COW clones are fully writable; this feature of Ceph provides a greater level of flexibility and is extremely useful in cloud platforms. In the later chapters, we will discover more on COW clones for spawning OpenStack instances:

Every cloned image (child image) stores references of its parent snapshot to read image data. Hence, the parent snapshot should be protected before it can be used for cloning. At the time of data writing on the COW cloned image, it stores new data references to itself. COW cloned images are as good as RBD. They are quite flexible like RBD, which means that they are writable, resizable, and support snapshots and further cloning.

In Ceph RBD, images are of two types: format-1 and format-2. The RBD snapshot feature is available on both types, that is, in format-1 as well as in format-2 RBD images. However, the layering feature (the COW cloning feature) is available only for the RBD image with format-2. The default RBD image format is format-1.

How to do it…

To demonstrate RBD cloning, we will intentionally create a format-2 RBD image, then create and protect its snapshot, and finally, create COW clones out of it:

  1. Create a format-2 RBD image and check its detail:
    # rbd create rbd2 --size 10240 --image-format 2 --name client.rbd
    # rbd info --image rbd2 --name client.rbd
    
  2. Create a snapshot of this RBD image:
    # rbd snap create rbd/rbd2@snapshot_for_cloning --name client.rbd
    
  3. To create a COW clone, protect the snapshot. This is an important step, we should protect the snapshot because if the snapshot gets deleted, all the attached COW clones will be destroyed:
    # rbd snap protect rbd/rbd2@snapshot_for_cloning --name client.rbd
    
  4. Next, we will create a cloned RBD image using this snapshot:

    Syntax: rbd clone <pool-name>/<parent-image>@<snap-name> <pool-name>/<child-image-name>

    # rbd clone rbd/rbd2@snapshot_for_cloning rbd/clone_rbd2 --name client.rbd
    
  5. Creating a clone is a quick process. Once it's completed, check the new image information. You will notice that its parent pool, image, and snapshot information will be displayed:
    # rbd info rbd/clone_rbd2 --name client.rbd
    

    At this point, we have a cloned RBD image, which is dependent upon its parent image snapshot. To make the cloned RBD image independent of its parent, we need to flatten the image, which involves copying the data from the parent snapshot to the child image. The time it takes to complete the flattening process depends on the size of the data present in the parent snapshot. Once the flattening process is completed, there is no dependency between the cloned RBD image and its parent snapshot.

  6. To initiate the flattening process, use the following:
    # rbd flatten rbd/clone_rbd2 --name client.rbd
    # rbd info --image clone_rbd2 --name client.rbd
    

    After the completion of the flattening process, if you check image information, you will notice that the parent image/snapshot name is not present and the clone is independent.

  7. You can also remove the parent image snapshot if you no longer require it. Before removing the snapshot, you first have to unprotect it:
    # rbd snap unprotect rbd/rbd2@snapshot_for_cloning --name client.rbd
    
  8. Once the snapshot is unprotected, you can remove it:
    # rbd snap rm rbd/rbd2@snapshot_for_cloning --name client.rbd
    
主站蜘蛛池模板: 阿克| 林西县| 固始县| 马龙县| 九龙坡区| 汶川县| 盐池县| 平阴县| 临邑县| 荔浦县| 尼玛县| 远安县| 汝城县| 天水市| 保德县| 奉化市| 永福县| 洪江市| 同江市| 楚雄市| 京山县| 太保市| 宁强县| 阜平县| 运城市| 札达县| 田东县| 梅河口市| 屏南县| 高清| 马龙县| 朝阳区| 红安县| 渝中区| 分宜县| 孝义市| 宁远县| 易门县| 石狮市| 宜君县| 双桥区|