(6) ceph RBD copy

Ceph storage cluster can create a copy (COW copy) write from a snapshot of RBD, which is a snapshot of Ceph stratification. The hierarchical nature of Ceph allows clients to instantly create multiple copies of the Ceph RBD, the characteristics of cloud platforms and virtualization platform very, such as OpenStack, CloudStack and Qemu / KVM These platforms are usually 'in the form of protection contains a snapshot of OS / VM image Ceph RBD mirror, and then to create a new virtual machine / instance, through continuous snapshot copy the snapshot is read-only, but COW copy is completely writable; Ceph this feature is a huge flexible cloud platform resistance, and is useful for internet cloud, the figure shows the RADOS block device, the relationship between the snapshot and the snapshot copy RBD COW.

Each copy of the image (sub-image) contains a reference to its parent snapshots, for reading image data. Therefore, before the parent snapshot for copying it should be protected in the state. When data is written to a mirror copy of the COW, it will store the new data references for themselves. COW replication and mirroring RBD is the same.

They are very flexible, similar to RBD, that is, they can write, adjustable capacity, you can create a new snapshot, the future can also copy.
(6) ceph RBD copy

RBD mirror type defines the features it supports, in Ceph, there are two types of mirror RBD: format-l and form t-2, format-l type and format-2 RBD mirror support snapshots characteristics. However, delamination characteristics (i.e. COW characteristics) only format-2 type mirror support RBD, RBD default image type is format-l.

(1) First, create a format2 type of RBD mirror, and then create a snapshot, the snapshot protection, and finally create a copy using the snapshot COW.

[root@node140 /]# rbd create rbd_copy1 --size 10240 --image-format 2
[root@node140 /]# rbd ls 
rbd_copy1

(2) create the snapshot mirror

[root@node140 /]# rbd snap create rbd/rbd_copy1@snap_for_clone
[root@node140 /]# rbd snap ls rbd/rbd_copy1
SNAPID NAME           SIZE   PROTECTED TIMESTAMP                
     8 snap_for_clone 10 GiB           Wed Aug 28 17:27:10 2019 

(3) To create a copy of the COW, first snapshot in the protective state, this step is very important, and we should protect the snapshot, because if you delete the snapshot, all connected to it COW copies will be destroyed.
[root@node140 /]# rbd snap protect rbd/rbd_copy1@snap_for_clone

(4) the need to copy the snapshot name of the parent storage pool, RBD mirroring and snapshots.
[root@node140 /]# rbd clone rbd/rbd_copy1@snap_for_clone rbd/rbd_copy2

(5) creates a copy very quickly, to create a complete view mirrors of new information, he found his father pond, mirroring, and snapshots of information will be displayed.

[root@node140 /]# rbd --pool rbd --image rbd_copy2 info 
rbd image 'rbd_copy2':
    size 10 GiB in 2560 objects
    order 22 (4 MiB objects)
    snapshot_count: 0
    id: 1735e1f84c868
    block_name_prefix: rbd_data.1735e1f84c868
    format: 2
    features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
    op_features: 
    flags: 
    create_timestamp: Wed Aug 28 17:33:38 2019
    access_timestamp: Wed Aug 28 17:33:38 2019
    modify_timestamp: Wed Aug 28 17:33:38 2019
    parent: rbd/rbd_copy1@snap_for_clone   ##依赖父镜像
    overlap: 10 GiB

(6) have been cloned here RBD a mirror, mirror-based snapshots parent, but not independent, but also depend on the parent image, or depend on the parent image, the required flat mirror, which mirror the parent from snapshot copy data to the sub-mirror. Flattening the time domain imaging data required for the process is the same size, without any dependence flat after completely independent.

[root@node140 /]# rbd flatten rbd/rbd_copy2
Image flatten: 100% complete...done.
[root@node140 /]# rbd --pool rbd --image rbd_copy2 info 
rbd image 'rbd_copy2':
    size 10 GiB in 2560 objects
    order 22 (4 MiB objects)
    snapshot_count: 0
    id: 1735e1f84c868
    block_name_prefix: rbd_data.1735e1f84c868
    format: 2
    features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
    op_features: 
    flags: 
    create_timestamp: Wed Aug 28 17:33:38 2019
    access_timestamp: Wed Aug 28 17:33:38 2019
    modify_timestamp: Wed Aug 28 17:33:38 2019

(7) If you want to delete a parent-mirror snapshots, go to protect, and then delete

[root@node140 /]# rbd snap unprotect rbd/rbd_copy1@snap_for_clone
[root@node140 /]# rbd snap rm rbd/rbd_copy1@snap_for_clone
Removing snap: 100% complete...done.

Note: The reference to "ceph Distributed Storage Study Guide" to learn and practice

Guess you like

Origin blog.51cto.com/7603402/2433401