cephrbd 대상 구성

31460 단어 대상metadata
/* New-style rbd image 'foo' consists of objects
 *   rbd_id.foo              - id of image
 *   rbd_header.<id>         - image metadata
 *   rbd_object_map.<id>     - optional image object map
 *   rbd_data.<id>.00000000
 *   rbd_data.<id>.00000001
 *   ...                     - data
 */

#define RBD_HEADER_PREFIX "rbd_header."
#define RBD_OBJECT_MAP_PREFIX "rbd_object_map."
#define RBD_DATA_PREFIX "rbd_data."
#define RBD_ID_PREFIX "rbd_id."

/*
 * old-style rbd image 'foo' consists of objects
 *   foo.rbd      - image metadata
 *   rb.<idhi>.<idlo>.00000000
 *   rb.<idhi>.<idlo>.00000001
 *   ...          - data
 */

#define RBD_SUFFIX ".rbd"
#define RBD_DIRECTORY "rbd_directory"
#define RBD_INFO "rbd_info"

/*
 * rbd_children object in each pool contains omap entries
 * that map parent (poolid, imageid, snapid) to a list of children
 * (imageids; snapids aren't required because we get all the snapshot
 * info from a read of the child's header object anyway).
 *
 * The clone operation writes a new item to this child list, and rm or
 * flatten removes an item, and may remove the whole entry if no children
 * exist after the rm/flatten.
 *
 * When attempting to remove a parent, all pools are searched for
 * rbd_children objects with entries referring to that parent; if any
 * exist (and those children exist), the parent removal is prevented.
 */
#define RBD_CHILDREN "rbd_children"

오래된 미러 형식: 데이터를 가져와서 미러를 만듭니다. 기본 미러 형식을 사용합니다.
[root@ceph-osd-241 ~]# rbd -p liyankun import BIOS_CR1RR_LN_2.5.4.BIN test
Importing image: 100% complete...done.
[root@ceph-osd-241 ~]# rados -p liyankun ls
rb.0.bbca0.74b0dc51.000000000007
rb.0.bbca0.74b0dc51.000000000001
rb.0.bbca0.74b0dc51.000000000008
rb.0.bbca0.74b0dc51.000000000005  //data 
test.rbd                          //   metadata
rbd_directory
rb.0.bbca0.74b0dc51.000000000004
rb.0.bbca0.74b0dc51.000000000010
rb.0.bbca0.74b0dc51.00000000000f
rb.0.bbca0.74b0dc51.000000000006
rb.0.bbca0.74b0dc51.00000000000b
rb.0.bbca0.74b0dc51.000000000003
rb.0.bbca0.74b0dc51.000000000009
rb.0.bbca0.74b0dc51.00000000000e
rb.0.bbca0.74b0dc51.00000000000d
rb.0.bbca0.74b0dc51.00000000000c
rb.0.bbca0.74b0dc51.00000000000a
rb.0.bbca0.74b0dc51.000000000002
rb.0.bbca0.74b0dc51.000000000000

미러에 대한 스냅샷 생성
[root@ceph-osd-241 ~]# rbd --pool liyankun snap create --snap testsnap test

미러 스냅샷이 생성되었습니다.
[root@ceph-osd-241 ~]# rbd -p liyankun snap ls test
SNAPID NAME         SIZE 
     4 testsnap 65553 kB

개체 개수가 변경되었는지 보기
[root@ceph-osd-241 ~]# rados -p liyankun ls
rb.0.bbca0.74b0dc51.000000000007
rb.0.bbca0.74b0dc51.000000000001
rb.0.bbca0.74b0dc51.000000000008
rb.0.bbca0.74b0dc51.000000000005
test.rbd
rbd_directory
rb.0.bbca0.74b0dc51.000000000004
rb.0.bbca0.74b0dc51.000000000010
rb.0.bbca0.74b0dc51.00000000000f
rb.0.bbca0.74b0dc51.000000000006
rb.0.bbca0.74b0dc51.00000000000b
rb.0.bbca0.74b0dc51.000000000003
rb.0.bbca0.74b0dc51.000000000009
rb.0.bbca0.74b0dc51.00000000000e
rb.0.bbca0.74b0dc51.00000000000d
rb.0.bbca0.74b0dc51.00000000000c
rb.0.bbca0.74b0dc51.00000000000a
rb.0.bbca0.74b0dc51.000000000002
rb.0.bbca0.74b0dc51.000000000000

스냅샷을 보호하여 데이터 분실을 방지하고clone을 준비하여 출력 정보로부터 이 기능이 실현되지 않았음을 알 수 있습니다
[root@ceph-osd-241 ~]# rbd -p liyankun snap protect --image test --snap testsnap
rbd: protecting snap failed: (38) Function not implemented
2016-09-02 11:40:32.276782 7f44a6c0e760 -1 librbd: snap_protect: image must support layering

생성된 스냅샷에서 이미지를 복제합니다. 이미지-format 1이clone을 지원하지 않기 때문에 실패했습니다.
[root@ceph-osd-241 ~]# rbd -p liyankun  clone --image test --snap testsnap --dest-pool liyankun --dest test_child
2016-09-02 11:43:47.685116 7f6db89b1760 -1 librbd: parent image must be in new format
rbd: clone error: (22) Invalid argument

현재 이미지 포맷을 1로 지정하기
[root@ceph-osd-241 ~]# rbd -p liyankun info test
rbd image 'test':
        size 65553 kB in 17 objects
        order 22 (4096 kB objects)
        block_name_prefix: rb.0.bbca0.74b0dc51
        format: 1
[root@ceph-osd-241 ~]# 

새 미러 형식: 환경 지우기 미러를 다시 가져오고 미러 형식을 2로 지정
[root@ceph-osd-241 ~]# rbd -p liyankun import BIOS_CR1RR_LN_2.5.4.BIN test --image-format 2
Importing image: 100% complete...done.
[root@ceph-osd-241 ~]# rados -p liyankun ls
rbd_data.bbe1d74b0dc51.0000000000000010
rbd_data.bbe1d74b0dc51.0000000000000004
rbd_data.bbe1d74b0dc51.0000000000000003
rbd_data.bbe1d74b0dc51.0000000000000002
rbd_data.bbe1d74b0dc51.0000000000000006
rbd_data.bbe1d74b0dc51.000000000000000a
rbd_data.bbe1d74b0dc51.000000000000000b
rbd_data.bbe1d74b0dc51.000000000000000d
rbd_directory
rbd_data.bbe1d74b0dc51.0000000000000000
rbd_data.bbe1d74b0dc51.0000000000000007       //data
rbd_data.bbe1d74b0dc51.000000000000000e
rbd_header.bbe1d74b0dc51                     //image metadata
rbd_data.bbe1d74b0dc51.0000000000000005
rbd_data.bbe1d74b0dc51.0000000000000009
rbd_data.bbe1d74b0dc51.000000000000000f
rbd_data.bbe1d74b0dc51.0000000000000001
rbd_id.test                                  //id of image
rbd_data.bbe1d74b0dc51.000000000000000c
rbd_data.bbe1d74b0dc51.0000000000000008

미러 스냅샷 생성
[root@ceph-osd-241 ~]# rbd --pool liyankun snap create --snap testsnap test

미러 보호
[root@ceph-osd-241 ~]# rbd -p liyankun snap protect --image test --snap testsnap

미러의 스냅샷에서 새 미러 클론 생성
[root@ceph-osd-241 ~]# rbd clone -p liyankun --image test --snap testsnap --dest-pool liyankun --dest test_child
[root@ceph-osd-241 ~]# rados -p liyankun ls
rbd_data.bbe1d74b0dc51.0000000000000010
rbd_data.bbe1d74b0dc51.0000000000000004
rbd_data.bbe1d74b0dc51.0000000000000003
rbd_data.bbe1d74b0dc51.0000000000000002
rbd_data.bbe1d74b0dc51.0000000000000006
rbd_header.bb0e62ae8944a
rbd_children
rbd_data.bbe1d74b0dc51.000000000000000a
rbd_data.bbe1d74b0dc51.000000000000000b
rbd_data.bbe1d74b0dc51.000000000000000d
rbd_directory
rbd_data.bbe1d74b0dc51.0000000000000000
rbd_data.bbe1d74b0dc51.0000000000000007
rbd_data.bbe1d74b0dc51.000000000000000e
rbd_header.bbe1d74b0dc51
rbd_data.bbe1d74b0dc51.0000000000000005
rbd_data.bbe1d74b0dc51.0000000000000009
rbd_data.bbe1d74b0dc51.000000000000000f
rbd_id.test_child
rbd_data.bbe1d74b0dc51.0000000000000001
rbd_id.test
rbd_data.bbe1d74b0dc51.000000000000000c
rbd_data.bbe1d74b0dc51.0000000000000008

대칭복사 형식 보기
[root@ceph-osd-241 ~]# rbd -p liyankun info test
rbd image 'test':
        size 65553 kB in 17 objects
        order 22 (4096 kB objects)
        block_name_prefix: rbd_data.bbe1d74b0dc51
        format: 2
        features: layering
        flags: 

rbd 열거children omap 객체의 keys
[root@ceph-osd-241 ~]# rados -p liyankun listomapkeys rbd_children 
bbe1d74b0dc51

rbd 열거children omap 객체의 keys and values
[root@ceph-osd-241 ~]# rados -p liyankun listomapvals rbd_children 
key (33 bytes):
0000 : 10 00 00 00 00 00 00 00 0d 00 00 00 62 62 65 31 : ............bbe1
0010 : 64 37 34 62 30 64 63 35 31 06 00 00 00 00 00 00 : d74b0dc51.......
0020 : 00                                              : .

value (21 bytes) :
0000 : 01 00 00 00 0d 00 00 00 62 62 30 65 36 32 61 65 : ........bb0e62ae
0010 : 38 39 34 34 61                                  : 8944a

[root@ceph-osd-241 ~]# rados -p liyankun ls
rbd_data.bbe1d74b0dc51.0000000000000010
rbd_data.bbe1d74b0dc51.0000000000000004
rbd_data.bbe1d74b0dc51.0000000000000003
rbd_data.bbe1d74b0dc51.0000000000000002
rbd_data.bbe1d74b0dc51.0000000000000006
rbd_header.bb0e62ae8944a
rbd_children
rbd_data.bbe1d74b0dc51.000000000000000a
rbd_data.bbe1d74b0dc51.000000000000000b
rbd_data.bbe1d74b0dc51.000000000000000d
rbd_directory
rbd_data.bbe1d74b0dc51.0000000000000000
rbd_data.bbe1d74b0dc51.0000000000000007
rbd_data.bbe1d74b0dc51.000000000000000e
rbd_header.bbe1d74b0dc51
rbd_data.bbe1d74b0dc51.0000000000000005
rbd_data.bbe1d74b0dc51.0000000000000009
rbd_data.bbe1d74b0dc51.000000000000000f
rbd_id.test_child
rbd_data.bbe1d74b0dc51.0000000000000001
rbd_id.test
rbd_data.bbe1d74b0dc51.000000000000000c
rbd_data.bbe1d74b0dc51.0000000000000008
[root@ceph-osd-241 ~]# rados -p liyankun stat rbd_id.test_child
liyankun/rbd_id.test_child mtime 2016-09-02 13:34:00.000000, size 17

[root@ceph-osd-241 ~]# rados -p liyankun ls | grep header
rbd_header.bb0e62ae8944a
rbd_header.bbe1d74b0dc51

rbd 보기childre omap 대상 내용, 이미지 간의 부자 관계가 rbd 에서 유지되는지 확인children omap 객체
[root@ceph-osd-241 ~]# rados -p liyankun listomapvals rbd_children 
key (33 bytes):
0000 : 10 00 00 00 00 00 00 00 0d 00 00 00 62 62 65 31 : ............bbe1
0010 : 64 37 34 62 30 64 63 35 31 06 00 00 00 00 00 00 : d74b0dc51.......
0020 : 00                                              : .

value (21 bytes) :
0000 : 01 00 00 00 0d 00 00 00 62 62 30 65 36 32 61 65 : ........bb0e62ae
0010 : 38 39 34 34 61                                  : 8944a

[root@ceph-osd-241 ~]# 

미러가 클론으로 생성되면 해당 미러의 형식은 상위 미러의 형식과 일치합니다.
[root@ceph-osd-241 ~]# rbd -p liyankun info test_child
rbd image 'test_child':
        size 65553 kB in 17 objects
        order 22 (4096 kB objects)
        block_name_prefix: rbd_data.bb0e62ae8944a
        format: 2
        features: layering
        flags: 
        parent: liyankun/test@testsnap
        overlap: 65553 kB

좋은 웹페이지 즐겨찾기