Note: There is a key issue here that is not resolved, how is quota information handled? It's easy to see how many quotas a zombie instance occupies, but how do you release those quotas back?
I can only manually calculate the instance, cores, and RAM values after deletion, and then go to reservations and quota_usages table to modify.
This method is two short, and easy to make mistakes, but there is no better way, but also look at the passing of the predecessors of a recruit.
Before the operation, I also tried to find some online, many are the same source, shielding foreign keys (SET foreign_key_checks=0;), and then delete the records in the Instances table. Obviously, this is violent and leaves quite a few database spam entries.
Of course, there are some scripts, or one-by-one approach to solve, but the version is relatively early, such as the predecessor of the blog Record (portal), the associated database entries are relatively small.
Therefore, have to follow the method of their predecessors to grope to deal with ...
The following is an example of a demo1 instance to test the removal of a zombie instance
Get current state, try to delete, state is still ERROR650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" border:1px Solid RGB (221,221,221); background-position:50% 50%;background-repeat:no-repeat; "alt=" Spacer.gif "/>
[[Email Protected] ~ (Demo)]$ Nova list |grep demo1
| 38887ca5-b697-451f-8d95-36b8b64aae3e | Demo1 | ERROR | - | Nostate | |
Recycling floating IP, this example is not assigned to the floating IP, but still need to put forward to avoid more database foreign key errors
# Nova Remove-floating-ip demo1 192.168.8.101
# Nova Floating-ip-delete 192.168.8.101
Confirm the ID of the instance that needs to be deleted, in the table in the database, it may appear with the name Uuid,instance_uuid,id, etc.
# Nova List | grep demo1
From the image above you can see that the ID is 38887ca5-b697-451f-8d95-36b8b64aae3e
Confirm the information for this instance in the database
Mysql-uroot-pPASSWORD -E "Use Nova; Select UUID, Vm_state, display_name from instances WHERE uuid= '38887ca5-b697-451f-8d95-36b8b64aae3e';
Delete database table records by article
Mysql-uroot-pPASSWORD-E "Use Nova; DELETE from security_group_instance_association WHERE instance_uuid= '38887ca5-b697-451f-8d95-36b8b64aae3e‘ ;"
Mysql-uroot-pPASSWORD-E "Use Nova; DELETE from instance_info_caches WHERE instance_uuid= '38887ca5-b697-451f-8d95-36b8b64aae3e‘ ;"
Mysql-uroot-pPASSWORD-E "Use Nova; DELETE from block_device_mapping WHERE instance_uuid= '38887ca5-b697-451f-8d95-36b8b64aae3e‘ ;"
Mysql-uroot-pPASSWORD-E "Use Nova; DELETE from Instance_extra WHERE instance_uuid= '38887ca5-b697-451f-8d95-36b8b64aae3e‘ ;"
Mysql-uroot-pPASSWORD -E "Use Nova; DELETE from Instance_actions_events where action_id in (SELECT ID from instance_actions where instance_uuid= '38887ca5 -b697-451f-8d95-36b8b64aae3e'); "
Mysql-uroot-pPASSWORD-E "Use Nova; DELETE from instance_actions WHERE instance_uuid= '38887ca5-b697-451f-8d95-36b8b64aae3e‘ ;"
Mysql-uroot-pPASSWORD-E "Use Nova; DELETE from Instance_faults WHERE instance_uuid= '38887ca5-b697-451f-8d95-36b8b64aae3e‘ ;"
Mysql-uroot-pPASSWORD-E "Use Nova; DELETE from Instance_system_metadata WHERE instance_uuid= '38887ca5-b697-451f-8d95-36b8b64aae3e‘ ;"
Mysql-uroot-pPASSWORD-E "Use Nova; DELETE from instances WHERE uuid= '38887ca5-b697-451f-8d95-36b8b64aae3e‘ ;"
-
If there are other foreign keys that are prompted during the deletion, such as the following prompt,
ERROR 1451 (23000) at line 1:cannot Delete or update a parent row:a foreign key Constr Aint fails (' Nova ', ' instance_uuid ') REFERENCES ' instances ' (' uuid ')
When you execute a command, replace the position of the 3 underscore in turn. The 1th one is the table with the associated foreign key, the 2nd is the associated field in the table, and the 3rd is the corresponding field in the referenced table, which is the instance_id that was previously queried. The first two copies are copied directly, and the following instance_id are replaced by the UUID of the instance that is actually required to be removed. The actual commands executed are as follows:
Mysql-uroot-pinstance_system_metadata where instance_uuid = ' 38887ca5-b697-451f-8d95-36b8b64aae3e '; '
Next, delete the image used by the instance. By default in the/var/lib/nova/instances directory, the image file is still named instance_id, deleting the entire instance_id folder. For insurance purposes, you can back up the folder to another location for a period of time.
Finally, as mentioned earlier, the quota usage information is handled manually.
This article is from the "foolishfish" blog, make sure to keep this source http://foolishfish.blog.51cto.com/3822001/1615560
OpenStack Juno Deleting Zombie instances