ceph rbd


  1. 创建pool 创建存储池: ceph osd pool create {pool-name} {pg-num} [{pgp-num}] [replicated] [crush-ruleset-name] [expected-num-objects] 删除存储池: ceph osd pool delete {pool-name} [{pool-name} --yes-i-really-really-mean-it] 重命名存储池: ceph osd pool rename {current-pool-name} {new-pool-name}

    ceph osd pool create test_pool 128 128 replicated

    1. 查看存储池列表 ceph osd lspools 3.创建块设备镜像 创建块设备镜像命令是rbd create --size {megabytes} {pool-name}/{image-name},如果pool_name不指定,则默认的pool是rbd。 下面的命令将创建一个10GB大小的块设备:

      rbd create --size 10240 test_image -p test_pool 删除镜像: rbd rm test_pool/test_image

    2. 查看块设备镜像 查看块设备的命令是rbd info {pool-name}/{image-name}

      hcy@admin_server:~/my-cluster$ rbd info test_pool/test_image rbd image ‘test_image‘: size 1024 MB in 256 objects order 22 (4096 kB objects) block_name_prefix: rbd_data.372674b0dc51 format: 2 features: layering flags: create_timestamp: Sat Sep 23 18:16:28 2017 注意到上面的rbd info显示的RBD镜像的format为2,Format 2的RBD镜像支持RBD分层,是实现Copy-On-Write的前提条件。

      5.将块设备映射到系统内核 块设备映射到操作系统的命令是rbd map {image-name}

      sudo rbd map test_pool/test_image 取消映射: rbd unmap test_pool/test_image 此时如果打印:

      rbd: sysfs write failed RBD image feature set mismatch. You can disable features unsupported by the kernel with "rbd feature disable". In some cases useful info is found in syslog - try "dmesg |www.bajieyy.org tail" or so. rbd: map failed: (6) No such device or address 表示当前系统不支持feature,禁用当前系统内核不支持的feature:

      rbd feature disable test_pool/test_image exclusive-lock, object-map, fast-diff, deep-flatten 重新映射:

      hcy@admin_server:~/my-cluster$ sudo rbd map test_pool/test_image /dev/rbd0

    3. 格式化块设备镜像 sudo mkfs.ext4 /dev/rbd/test_pool/test_image
    4. 挂载文件系统 sudo mkdir /mnt/ceph-block-device sudo chmod 777 /mnt/ceph-block-device sudo mount /dev/rbd/test_pool/test_image /mnt/ceph-block-device cd /mnt/ceph-block-device 8.卸载文件系统 sudo ceph unmap /dev/rbd0