目的

清理环境所有的数据,删除并恢复到初始状态

脚本

#! /bin/sh
for host in lab101 lab102
do
ssh $host  hostname
ssh $host systemctl stop ceph-radosgw.target
ssh $host systemctl stop ceph-osd.target
ssh $host systemctl stop ceph-mgr.target
ssh $host systemctl stop ceph-mon.target
ssh $host "for vgname in \`vgs --separator : --noheadings --units k --unbuffered --nosuffix --options 'vg_name'|grep ceph\`;do echo \$vgname;vgremove -y \$vgname;done;"
ssh $host "for osddir in \`df -h|grep osd|grep ceph|awk '{print \$6}'\`;do umount \$osddir;done;"
ssh $host "rm -rf /var/lib/ceph/osd/*"
ssh $host "rm -rf /var/lib/ceph/mon/*"
ssh $host "rm -rf /var/lib/ceph/mgr/*"
ssh $host "rm -rf /var/lib/ceph/mds/*"
ssh $host "rm -rf /etc/ceph/*"
ssh $host "for pvdisk in \`pvdisplay -c|grep new|awk '{print \$1}'|sed 's/\"//g'\`;do echo \$pvdisk;pvremove \$pvdisk;done"

done

非脚本命令行清理lvm

for vgname in `vgs --separator : --noheadings --units k --unbuffered --nosuffix --options 'vg_name'|grep ceph`;do echo $vgname;vgremove -y $vgname;done;


for pvdisk in `pvdisplay -c|grep new|awk '{print \$1}'|sed 's/"//g'`;do echo $pvdisk;pvremove $pvdisk;done