7.Ceph块存储操作

                                            Ceph块存储操作

创建Ceph块设备

    创建一个1024MB大小的块设备


#rbd create rbd1 --size 1024 -p compute


    列出创建的块image


#rbd ls -p compute


    检查块image的细节

#rbd --image rbd1 info -p compute


rbd image 'rbd1':
    size 1024 MB in 256 objects
    order 22 (4096 kB objects)
    block_name_prefix: rbd_data.148952ae8944a
    format: 2
    features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
    flags:

注:

layering: 支持分层

striping: 支持条带化 v2

exclusive-lock: 支持独占锁

object-map: 支持对象映射(依赖 exclusive-lock )

fast-diff: 快速计算差异(依赖 object-map )

deep-flatten: 支持快照扁平化操作

journaling: 支持记录 IO 操作(依赖独占锁)


rbd image有4个 features,layering, exclusive-lock, object-map, fast-diff, deep-flatten
因为目前内核版本 3.10仅支持layering,修改默认配置
每个ceph node的/etc/ceph/ceph.conf 添加一行
rbd_default_features = 1
这样之后创建的image 只有这一个feature


format 1 - 新建 rbd 映像时使用最初的格式。此格式兼容所有版本的 librbd 和内核模块,但是不支持较新的功能,像克隆。

format 2 - 使用第二版 rbd 格式, librbd 和 3.11 版以上内核模块才支持(除非是分拆的模块)。此格式增加了克隆支持,使得扩展更容易,还允许以后增加新功能


映射Ceph块设备

映射块设备到client


[root@ceph ceph]# rbd feature disable rbd1 -p compute exclusive-lock object-map fast-diff deep-flatten
[root@ceph ceph]# rbd map --image rbd1 -p compute
/dev/rbd0

检查被映射的设备


[root@ceph ceph]# rbd showmapped
id pool    image snap device    
0  compute rbd1  -    /dev/rbd0

使用这个块设备



[root@ceph ceph]# fdisk -l /dev/rbd0

Disk /dev/rbd0: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4194304 bytes / 4194304 bytes

[root@ceph ceph]# mkfs.xfs /dev/rbd0
meta-data=/dev/rbd0              isize=512    agcount=9, agsize=31744 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=262144, imaxpct=25
         =                       sunit=1024   swidth=1024 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

[root@ceph ceph]# mkdir /mnt/ceph-disk1
[root@ceph ceph]# mount /dev/rbd0 /mnt/ceph-disk1
[root@ceph ceph]# df -h /mnt/ceph-disk1
Filesystem      Size  Used Avail Use% Mounted on
/dev/rbd0      1014M   33M  982M     4% /mnt/ceph-disk1

猜你喜欢

转载自blog.csdn.net/weixin_41515615/article/details/80943878