sisimi的点点滴滴

你若盛开,清风自来

导航

批量删除osd的shell脚本

cluster环境:

# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 
# ceph -v
ceph version 12.2.1 (3e7492b9ada8bdc9a5cd0feafd42fbca27f9c38e) luminous (stable)

创建脚本:

# touch del_osd.sh
# chmod +x del_osd.sh

编辑脚本:

# vi del_osd.sh

输入以下内容:

#!/bin/sh

osd_id=`ceph osd tree | grep down| awk '{print $1}'`
for var in ${osd_id}
do
	echo "deleting osd.$var"
	ceph osd out osd.$var 
	ceph osd rm osd.$var 
	ceph osd crush rm osd.$var 
	ceph auth del osd.$var 
	sleep 5
	echo "umount /var/lib/ceph/osd/ceph-$var "
	umount /var/lib/ceph/osd/ceph-$var 
done

因为如果不sleep执行umount,umount非常容易失败,所以睡5秒执行就好咯
需要说明的是umount只能在osd所在的host上进行,如果仍然umount失败参考:
[umount: /var/lib/ceph/osd/ceph-1:目标忙解决办法] 1

运行脚本:

# ./del_osd.sh

参考文档:

http://www.cnblogs.com/suyang/archive/2008/05/18/1201990.html
http://blog.sina.com.cn/s/blog_69a636860102vgdq.html
http://bbs.chinaunix.net/thread-2018059-1-1.html

posted on 2017-10-19 16:04  sisimi_2017  阅读(1496)  评论(0编辑  收藏  举报