如何删除 OpenStack Nova 僵尸实例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何删除 OpenStack Nova 僵尸实例相关的知识,希望对你有一定的参考价值。

参考技术A #!/bin/bash
for i in "$@"
do
mysql -uroot -pmygreatsecret << EOF
use nova;
DELETE FROM nova.virtual_interfaces where instance_uuid='$i';
DELETE FROM nova.fixed_ips where instance_uuid='$i';
DELETE FROM nova.block_device_mapping where instance_uuid='$i';
DELETE FROM nova.instance_system_metadata where instance_uuid='$i';
DELETE FROM nova.security_group_instance_association where instance_id='$i';
DELETE FROM nova.instance_info_caches WHERE instance_uuid='$i';
DELETE FROM nova.instances WHERE uuid='$i';
EOF
done
#echo "ok!,$# vm was deleted successfully!!"
#exit 0

运行脚本时后面加参数 ,参数为你要删除的实例的id,例如:
22f8d28d-d6cd-461e-911f-627e6cb8d4fe

在实例所在的计算结点上删除/var/lib/nova/instance/instance00000[这个是要删除的实例的号]本回答被提问者和网友采纳

sh 查询openstack nova实例

# CTL
source keystonerc;
function nova-show-vm() { 
nova show $(nova list --all-tenants |grep $@ | tee /dev/fd/2 |awk '{print $2}')
};

function instance-placement() { 
nova-show-vm $1 |egrep  "hypervisor|network| id" | awk  -F"|" '{print $3}'\
  | sed "s,\s*,,g" | xargs
};


# CFG
function instance-check() {
 salt $1 cmd.run "tail -n30 /var/lib/nova/instances/*-*-*/console.log;";
 salt $1 cmd.run "virsh list --all";
 ping -c3 $2;
}
instance-check $(instance-placement $IP)



function getip () 
{ 
    getent hosts $1 | awk '{ print $1 }'
}

nova-show-vm-cache() {
  TEMPCAHCE=/tmp/nova-vm-list.$(date "+%Y-%m-%d-%h")
  test -e $TEMPCAHCE || {
    nova-manage vm list | column -t > $TEMPCAHCE
  }
  egrep $@ "$TEMPCAHCE" | egrep -v deleted | awk '{print $7,$2,$1,$4}'
}

  
  
  
## associate Floating IPs by instance name
declare PORTS=($(nova list  --all-tenants|egrep -i '(gb-ss-vos-node-iyvooqnuxvqj-4jqzkrgqbcbx-r3ey62hav3ge|gb-ss-vos-node-iyvooqnuxvqj-zi3eglyjffrd-n7xcuwcgkjlg|gb-ss-.....)' |awk -F"|" '{print $2}' | xargs neutron port-list --device-id  |awk -F"|" '{print $2}'|xargs))
declare -a FFIPS=($(nova floating-ip-list |egrep egress |grep '| -                                    | -'|awk -F"|" '{print $2}'|xargs))
for i in $(seq 1 ${#PORTS[@]}); do echo neutron floatingip-associate ${FFIPS[$i]} ${PORTS[$i]};done


## get logs from stack
nova console-log $(openstack stack resource show 87dd6864-f004-467f-9725-39e67e59dbd2 mcp_salt_master -f json | jq -cr '.attributes.instance')
  

以上是关于如何删除 OpenStack Nova 僵尸实例的主要内容,如果未能解决你的问题,请参考以下文章

openstack 彻底删除nova节点

sh 查询openstack nova实例

sh 查询openstack nova实例

浅谈OpenStack T版服务组件--Nova计算服务(#^.^#)(持续更新~~~)

在OpenStack环境中创建一个VM实例

OpenStack——Nova计算服务