【rbd 刪除失敗】rbd: error: image still has watchers
背景
執行rbd 刪除操作,發現RBD被佔用,但又不知道被誰佔用,如何查詢呢?
rbd rm sfs_pool/pgsql
+ rbd rm sfs_pool/pgsql
2021-05-06 09:24:57.831 7fb0057fa700 -1 librbd::image::PreRemoveRequest: 0x55733d13d2a0 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.
解決辦法
(1)檢視rbd資訊
rbd info sfs_pool/pgsql
# rbd info sfs_pool/pgsql
rbd image 'pgsql':
size 10 GiB in 2560 objects
order 22 (4 MiB objects)
snapshot_count: 0
id: 42c7dcd2590f1f
block_name_prefix: rbd_data.42c7dcd2590f1f
format: 2
features: layering
op_features:
flags:
create_timestamp: Wed Apr 21 10:00:30 2021access_timestamp: Wed Apr 21 10:00:30 2021
modify_timestamp: Wed Apr 21 10:00:30 2021
(2)檢視watchers
rados -p sfs_pool listwatchers rbd_header.42c7dcd2590f1f
其中sfs_pool 是池子名稱,42c7dcd2590f1f是上一步查出的ID
watcher=11.50.135.132:0/2286887345 client.4376119 cookie=18446462598732841092
(3)登入到11.50.135.132這個節點,把rbd unmap掉
()
(4)再次查詢
rados -p sfs_pool listwatchers rbd_header.42c7dcd2590f1f
此時沒有任何輸出了
(5)再次執行
rbd rm sfs_pool/pgsql
+ rbd rm sfs_pool/pgsql
Removing image: 100% complete...done.
結果驗證
執行命令
rbd ls sfs_pool | grep pgsql
其中pgsql為image名稱
執行該命令,找不到該rbd,認為刪除成功