openstack的实例记录在nova数据库的instances表中,最简单的方式就是删除该记录。
1.回收浮动IP
解除绑定
nova remove-floating-ip vm_name xx.xx.xx.xx
放入ip池
nova floating-ip-delete xx.xx.xx.xx
2.删除实例记录
2.1强制删除
默认mysql会开启外键关联,直接删除被关联的数据会产生如下错误
Cannot delete or update a parent row: a foreign key constraint fails
可通过关闭(SET FOREIGN_KEY_CHECKS=0;)来消除错误,删除完毕后在开启(SET FOREIGN_KEY_CHECKS=1;)。
use nova;
select id,display_name,uuid from instances;
set FOREIGN_KEY_CHECKS=0;
delete from instances where id=‘...‘;
set FOREIGN_KEY_CHECKS=1;
2.2.关联删除
即不关闭外键关联,在删除实例记录之前,先删除所有有关的数据。
2.2.1查询实例各项信息
select id,display_name,uuid from instances;
2.2.2删除security_group_instance_association表中数据
delete from security_group_instance_association where instance_uuid=‘...‘;
2.2.3删除instance_info_caches表中数据
delete from instance_info_caches where id=...;
2.2.4删除block_device_mapping表中数据
delete from block_device_mapping where instance_uuid=‘...‘;
2.2.5删除instances表中数据
delete from where id=‘...‘;
时间: 2024-08-21 02:29:47