pg_inconsistent_之_unexpect_clone_修复方法

发布时间 2023-04-24 17:23:09作者: XU-NING

问题背景

ceph 集群 pg inconsistent,日志提示
log_channel(cluster) log [ERR] : scrub 19.15b9 19:9dac2ec3:::rbd_data.b29154238e1f29.0000000000001953:12 is an unexpected clone

解决方案

  1. 设置禁止 scrub 的维护标志位
ceph osd set noout
ceph osd set noscrub
ceph osd set nodeep-scrub
  1. 找到 pg 存放的三个 osd,并依次在三个 osd 节点执行步骤 3-9
ceph pg map [pg id]
  1. 设置禁止集群数据均衡的维护标志位
ceph osd set nobackfill
ceph osd set norebalance
ceph osd set norecover
  1. 进入其中一个 osd 节点,停止该 osd
systemctl stop ceph-osd@[osd_id]
  1. 找到有问题的快照对象并备份
cd /var/lib/ceph/osd/ceph-[osd_id]/current/[pg_id]_head
find ./ -name *data.b29154238e1f29.0000000000001953*
# cp 时使用 -a 连属性一起拷贝
# 此处注意,由于查询到的路径包含 \n 所以需要加反斜杠转移即修改 \n 为 \\n
cp -a [对象路径] /opt/


  1. 通过 ceph-objectstore-tool 列出该对象的快照。
ceph-objectstore-tool --pgid [pd_id] \
    --data-path /var/lib/ceph/osd/ceph-[osd_id]/ \
    --op list | grep [对象名称]
# 示例:
ceph-objectstore-tool --pgid 19.15b9 \
    --data-path /var/lib/ceph/osd/ceph-62/ \
    --op list | grep rbd_data.b29154238e1f29.0000000000001953


7. 移除有问题的快照

# rbd_data.b29154238e1f29.0000000000001953:12 其中 12 为十六进制的快照 id,转化为十进制之后为 18
ceph-objectstore-tool --pgid [pg_id] \
    --data-path /var/lib/ceph/osd/ceph-[osd_id]]/ \
    '[对象快照数据]' \
    remove
# 示例:
ceph-objectstore-tool --pgid 19.15b9 \
    --data-path /var/lib/ceph/osd/ceph-62/ \
    '["19.15b9",{"oid":"rbd_data.b29154238e1f29.0000000000001953","key":"","snapid":18,"hash":3279173049,"max":0,"pool":19,"namespace":"","max":0}]' \
    remove
  1. 启动该 osd
systemctl start ceph-osd@[osd_id]
  1. 取消标志位
ceph osd unset norecover
ceph osd unset norebalance
ceph osd unset nobackfill
  1. 等到 ceph 集群所有 pg 恢复 active + clean 之后,重复步骤 3-9 操作剩余的 osd
ceph -s
  1. 对该 pg 进行 deep-scrub
ceph pg deep-scrub [pg_id]
  1. 等到 pg inconsistent 修复完成之后,解除剩余的维护标志位
ceph osd unset noscrub
ceph osd unset nodeep-scrub
ceph osd unset noout