Ceph集群块设备使用-创建和使用OSD
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ceph集群块设备使用-创建和使用OSD相关的知识,希望对你有一定的参考价值。
创建Ceph块设备
[[email protected] ~]# rbd create block-device4 --size 5G --image-format 1
rbd: image format 1 is deprecated
查看块设备信息
[[email protected] ~]# rbd --image block-device4 info
rbd image ‘block-device4‘:
size 5120 MB in 1280 objects
order 22 (4096 kB objects)
block_name_prefix: rb.0.1435a.238e1f29
format: 1
映射块设备到block-device4
[[email protected] ~]# rbd map --image block-device4
/dev/rbd2
查看系统中块设备映射信息
[[email protected] ~]# rbd showmapped
id pool image snap device
0 rbd block-device1 - /dev/rbd0
1 rbd block-device3 - /dev/rbd1
2 rbd block-device4 - /dev/rbd2
要使用这个块设备,需要创建并挂载一个文件系统
[[email protected] ~]# mkfs.xfs /dev/rbd2
meta-data=/dev/rbd2 isize=256 agcount=9, agsize=162816 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=1024 swidth=1024 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
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
创建挂载点并挂载
[[email protected] ~]# mkdir /mnt/block-device4
[[email protected] ~]# mount /dev/rbd2 /mnt/block-device4
[[email protected] ~]# df -h /mnt/block-device4
Filesystem Size Used Avail Use% Mounted on
/dev/rbd2 5.0G 33M 5.0G 1% /mnt/block-device4
查看挂载情况
[[email protected] ~]# mount | grep rbd
/dev/rbd0 on /mnt/ceph-block-device1 type xfs (rw,relatime,attr2,inode64,sunit=8192,swidth=8192,noquota)
创建测试文件测试块设备
[[email protected] ~]# touch /mnt/block-device4/test
[[email protected] ~]# dd if=/dev/zero of=/mnt/block-device4/file bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.18182 s, 577 MB/s
[[email protected] ~]#
查看文件写入信息
[[email protected] ~]# ls /mnt/block-device4
file test
[[email protected] ~]# ll /mnt/block-device4
total 102400
-rw-r--r-- 1 root root 104857600 Sep 25 22:37 file
-rw-r--r-- 1 root root 0 Sep 25 22:36 test
[[email protected] ~]# df -h /mnt/block-device4
Filesystem Size Used Avail Use% Mounted on
/dev/rbd2 5.0G 133M 4.9G 3% /mnt/block-device4
设备开机自动挂载
[[email protected] ~]# echo "/dev/rbd2 /mnt/block-device4 xfs defaults,_netdev0 0" >> /etc/fstab
查看系统中rbd
[[email protected] ~]# rbd ls
block-device4
block-device2
[[email protected] ~]# rbd list
block-device4
block-device2
将刚创建的RBD块设备扩容到10G
[[email protected] ~]# rbd resize --image block-device4 --size 10G
Resizing image: 100% complete...done.
[[email protected] ~]# rbd --image block-device4 info
rbd image ‘block-device4‘:
size 10240 MB in 2560 objects
order 22 (4096 kB objects)
block_name_prefix: rb.0.1435a.238e1f29
format: 1
扩展文件系统空间
[[email protected] ~]# df -h /mnt/block-device4
Filesystem Size Used Avail Use% Mounted on
/dev/rbd2 5.0G 133M 4.9G 3% /mnt/block-device4
使用xfs_growfs命令对文件系统进行扩充
[[email protected] ~]# xfs_growfs -d /mnt/block-device4
meta-data=/dev/rbd2 isize=256 agcount=9, agsize=162816 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=1024 swidth=1024 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=8 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1310720 to 2621440
[[email protected] ~]# df -h /mnt/block-device4
Filesystem Size Used Avail Use% Mounted on
/dev/rbd2 10G 133M 9.9G 2% /mnt/block-device4
[[email protected] ~]#
本文出自 “技术成就梦想” 博客,请务必保留此出处http://andyliu.blog.51cto.com/518879/1856538
以上是关于Ceph集群块设备使用-创建和使用OSD的主要内容,如果未能解决你的问题,请参考以下文章