#!/bin/sh
# 注意:极端操作
# 本脚本将会把正常运行的osd全部删除,并且将硬盘从lvm恢复为普通单盘(删除记忆),数据将不可恢复;用于极端情况下释放硬盘操作
# 注意:极端操作
#
osd_id=`ceph osd tree | grep up| awk '{print $3}'`
for var in ${osd_id}
do
echo "deleting $var"
# 从crush中移除节点
ceph osd crush remove ${var}
# 删除节点认证(不删除编号会占住)
ceph auth del ${var}
# 使osd down
ceph osd down ${var}
sleep 10
# 防止down失败,再次down
ceph osd down ${var}
# 删除osd节点
ceph osd rm ${var}
done
sleep 30
# 卸载ceph挂载
osd_id=`df -h |grep 'var/lib/ceph/osd'| awk '{print $6}'`
for var in ${osd_id}
do
umount ${var}
done
# 删除lv
ces=`fdisk -l | grep 'Disk /dev/mapper' | awk '{print $2}'|awk -F ':' '{print $1}'`
for ce in ${ces}
do
lvremove ${ce} -y
done
# 删除lg
ces=`vgs|awk '{print $1}'| grep -v VG`
for ce in ${ces}
do
vgremove ${ce} -y
done
# 可以尝试格式化硬盘了
# mkfs.xfs -f /dev/sdxx
|