您好,登錄后才能下訂單哦!
這篇文章主要介紹了Ceph Block Device塊設(shè)備操作的示例分析,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
使用ceph block device需要如下三個(gè)步驟:
1. 在ceph 集群的pool中創(chuàng)建一個(gè)Block Device image.
2. ceph Client使用RBD設(shè)備與ceph集群的Block Device image進(jìn)行映射(Map)。
3. ceph Client的User Space便可以掛載(Mount)該RBD設(shè)備。
首先,需要新建一個(gè)pool,如果不想新建pool,可以使用默認(rèn)pool,即rbd。
命令:ceph osd pool create <creating_pool_name> <pg_num>
參數(shù):creating_pool_name : 要?jiǎng)?chuàng)建的pool的名字
pg_num : Placement Group的個(gè)數(shù)
# ceph osd pool create testpool 512
pool testpool' created
,需要在ceph集群中創(chuàng)建一個(gè)Block Device Image。(查看rbd的命令,輸入 "man rbd"命令)
命令:rbd create --size {MegaBytes} {pool-name}/{image-name}
例如:在名為“testpool”的pool中創(chuàng)建“bar”的Image,容量是1024MB
# rbd create --size 1024 testpool/bar
查看Block Device Images
# rbd ls testpool
rbd
以及查看一個(gè)Block Device Images的詳細(xì)信息
# rbd info testpool/bar
rbd image 'bar':
size 1024 MB in 256 objects
order 22 (4096 kB objects)
block_name_prefix: rbd_data.5e3b248a65f6
format: 2
features: layering
flags:
命令: sudo rbd map rbd/myimage --id admin --keyring /path/to/keyring
例如
# sudo rbd map testpool/bar --id admin --keyring /etc/ceph/ceph.client.admin.keyring
dev/rbd0
查看已經(jīng)映射的Block Device信息
# rbd showmapped
id pool image snap device
0 testpool bar - /dev/rbd0
首先,使用該block device在client-node上創(chuàng)建一個(gè)文件系統(tǒng)。
# sudo mkfs.ext4 -m0 /dev/rbd/testpool/bar
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=1024 blocks, Stripe width=1024 blocks
65536 inodes, 262144 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
其次,掛載該文件系統(tǒng)
# sudo mkdir /mnt/ceph-block-device
# sudo mount /dev/rbd/testpool/bar /mnt/ceph-block-device
查看mount信息
# mount
...
/dev/rbd0 on /mnt/ceph-block-device type ext4 (rw,relatime,seclabel,stripe=1024,data=ordered)
To create a new rbd image that is 100 GB:
rbd create mypool/myimage --size 102400
To use a non-default object size (8 MB):
rbd create mypool/myimage --size 102400 --object-size 8M
To delete an rbd image (be careful!):
rbd rm mypool/myimage
To create a new snapshot:
rbd snap create mypool/myimage@mysnap
To create a copy-on-write clone of a protected snapshot:
rbd clone mypool/myimage@mysnap otherpool/cloneimage
To see which clones of a snapshot exist:
rbd children mypool/myimage@mysnap
To delete a snapshot:
rbd snap rm mypool/myimage@mysnap
To map an image via the kernel with cephx enabled:
rbd map mypool/myimage --id admin --keyfile secretfile
To map an image via the kernel with different cluster name other than default ceph.
rbd map mypool/myimage –cluster cluster name
To unmap an image:
rbd unmap /dev/rbd0
To create an image and a clone from it:
rbd import --image-format 2 image mypool/parent rbd snap create mypool/parent@snap rbd snap protect mypool/parent@snap rbd clone mypool/parent@snap otherpool/child
To create an image with a smaller stripe_unit (to better distribute small writes in some workloads):
rbd create mypool/myimage --size 102400 --stripe-unit 65536B --stripe-count 16
To change an image from one image format to another, export it and then import it as the desired image format:
rbd export mypool/myimage@snap /tmp/img rbd import --image-format 2 /tmp/img mypool/myimage2
To lock an image for exclusive use:
rbd lock add mypool/myimage mylockid
To release a lock:
rbd lock remove mypool/myimage mylockid client.2485
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“Ceph Block Device塊設(shè)備操作的示例分析”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。