0
点赞
收藏
分享

微信扫一扫

ceph rbd image 管理#yyds干货盘点#

1、查看 image

  • rbd 操作,如果 没有指定数据池,则默认使用 rbd 数据池
  • 命令行中 {pool_name}/{image_name} 也可以写成 {image_name} -p {pool_name};两种格式等价


1.2 image 列表

## 查看指定池中 image 列表# rbd ls -p {pool_name}# rbd list -p {pool_name}


1.3 image 详细信息

# rbd info {image_name} -p {pool_name}


2、创建/删除 image

2.1 创建 image

# rbd create {pool_name}/{image_name} --size {size_M | G | T}


2.2 删除 image

# rbd rm {image_name} -p {pool_name}


3、image 属性管理

测试环境中,测试发现,image 属性可以在线调整,即已经映射挂载的磁盘,修改 image 属性时,不影响 读写操作


3.1 rbd feature

3.1.1 rbd feature disable

很多时候,map 时会报如下错误,需要将 rbd 某些特性关闭

# rbd feature disable {pool_name}/{image_name} fast-diff# rbd feature disable {pool_name}/{image_name} deep-flatten# rbd feature disable {pool_name}/{image_name} object-map# rbd feature disable {pool_name}/{image_name} exclusive-lock


3.1.2 rbd feature enable

# rbd feature enable {pool_name}/{image_name} {feature_name}


3.2 rbd rename

# rbd rename {pool_name}/{image_name} {pool_name}/{image_new_name}


3.3 rbd resize

3.3.1 rbd 调大

# sudo rbd resize {pool_name}/{image_name} --size {size_M | G | T}


3.3.1 rbd 调小

# sudo rbd resize {pool_name}/{image_name} --size {size_M | G | T} --allow-shrink


4、image 映射管理

4.1 映射

  • rbd 映射 到本地的磁盘(一般都是映射成 /dev/rbd{0..N} 之类的本地盘符)
  • rbd-nbd 映射磁盘(一般都是映射成 /dev/nbd{0..N} 之类的本地盘符)

# rbd map {image_name} -p {pool_name}# rbd map {pool_name}/{image_name}




4.4 映射关系 查看

# rbd showmapped


4.5 取消映射

# rbd unmap {image_name} -p {pool_name}# rbd unmap {pool_name}/{image_name}# rbd unmap {rbd_dev}


5、磁盘挂载

将 rbd 映射 到本地的磁盘(一般都是映射成 /dev/rbd{0..N} 之类的本地盘符),进行格式化、挂载


5.1 格式化

# mkfs.ext4 {rbd_dev}


5.2 挂载

mount -o discard 允许客户端和 ceph服务器之间同步删除数据;也可以不加,通过 fstrim 释放磁盘空间

# mount -o discard {rbd_dev} {mount_path}


6 导入/导出 image

6.1 初始化

暂时还没有 确定 为什么要 初始化,可以跳过初始化步骤

# rbd pool init {pool_name}


6.2 导入

{pool_image_name} 不能是已经存在的image

# rbd --dest-pool {pool_name} import {local_image_file} {pool_image_name}


6.3 导出

{local_path_file} 不能是已经存在的文件

# rbd -p volumes import {image_name} {local_path_file}



举报

相关推荐

0 条评论