• Welcome to LiuJason's Blog!

Ceph镜像无法删除rbd: error: image still has watchers解决方案

Linux笔记 Jason 1 months ago (12-06) 7 Views 0 Comments QR code of this page
文章目录[隐藏]

前言

需要删除一些Ceph镜像,遇到标题的报错,这里写一下解决方案供后续查阅。其中pool是 Ceph-SSD-Rep3,磁盘镜像是vm-29101-disk-0
使用rbd rm Ceph-SSD-Rep3/vm-29101-disk-0 -f删除时报错:

2021-12-06T10:20:50.938+0100 7f20abfff700 -1 librbd::image::PreRemoveRequest: 0x55e44013b060 check_image_watchers: image has watchers - not removing
Removing image: 0% complete...failed.
rbd: error: image still has watchers
This means the image is still open or the client using it crashed. Try again after closing/unmapping it or waiting 30s for the crashed client to timeout.

解决方案

字面意思就是有服务在占用这个镜像,所以只要找到后关闭就行,首先看磁盘信息:

[email protected] / # rbd --pool Ceph-SSD-Rep3 info vm-29101-disk-0
rbd image 'vm-29101-disk-0':
        size 8 GiB in 2048 objects
        order 22 (4 MiB objects)
        snapshot_count: 0
        id: 3abd77df337601
        block_name_prefix: rbd_data.3abd77df337601
        format: 2
        features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
        op_features:
        flags:
        create_timestamp: Sat Nov 20 20:15:39 2021
        access_timestamp: Sat Nov 20 20:15:39 2021
        modify_timestamp: Sat Nov 20 20:15:39 2021

然后确定是哪个服务在占用这个磁盘:

[email protected] / # rbd status Ceph-SSD-Rep3/vm-29101-disk-0
Watchers:
        watcher=10.2.0.112:0/1706250298 client.672648578 cookie=18446462598732841239

可以看到,这里10.2.0.112的服务器正在使用这个磁盘。

于是登录这个服务器,查看情况:

[email protected] ~ # lsblk
NAME                                                                                                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
rbd0                                                                                                    252:0    0     8G  0 disk 
rbd1                                                                                                    252:16   0    32G  0 disk 
└─rbd1p1                                                                                                252:17   0    32G  0 part /root/temp

卸载并取消映射:

[email protected] ~ # umount /root/temp
[email protected] ~ # rbd unmap /dev/rbd1
[email protected] ~ # rbd unmap /dev/rbd0

重新删除镜像:

[email protected] / # rbd --pool Ceph-SSD-Rep3 status vm-29101-disk-0
Watchers: none
[email protected] / # rbd rm Ceph-SSD-Rep3/vm-29101-disk-0 -f
Removing image: 100% complete...done.
[email protected] / # rbd rm Ceph-SSD-Rep3/vm-29101-disk-1 -f
Removing image: 100% complete...done.

This article is under CC BY-NC-SA 4.0 license.
Please quote the original link:https://www.liujason.com/article/1194.html
Like (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址