<article style="box-sizing: border-box; display: block; box-shadow: rgba(0, 0, 0, 0.0470588) 0px 2px 4px 0px; background-color: rgb(255, 255, 255); padding: 20px 0px; color: rgb(51, 51, 51); font-family: "PingFang SC", "Microsoft YaHei", SimHei, Arial, SimSun; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
MQ服務(wù)消息超時或者任何其他中斷實例創(chuàng)建或者刪除的情況,都會造成“僵死”實例的存在诞外。也即是這個實例并不存在,或者即便存在也是有問題的,并且在Dashboard儀表盤上刪除不了矾兜。提示“you are not allowed to terminate this instance"之類的錯誤。即便提示刪除成功患久,實際還是在那里死趟著焕刮。命令行同樣的問題,如下
nova list /列表顯示出來/
[html] view plaincopy
<embed id="ZeroClipboardMovie_1" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="17" name="ZeroClipboardMovie_1" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=1&width=16&height=17" wmode="transparent" style="box-sizing: border-box;">
- +--------------------------------------+--------------------+--------+------------+-------------+---------------------+
- | ID | Name | Status | Task State | Power State | Networks |
- +--------------------------------------+--------------------+--------+------------+-------------+---------------------+
- | 09dca062-c577-469f-bff5-cccbe65a5b7c | instance_name | ERROR | deleting | NOSTATE | |
nova reset-state 09dca062-c577-469f-bff5-cccbe65a5b7c /重置下狀態(tài)墙杯,正在刪除任務(wù)消失/
nova delete 09dca062-c577-469f-bff5-cccbe65a5b7c /嘗試命令行刪除/
nova list /還是上面的顯示正在刪除任務(wù)的狀態(tài)/
mysql -uroot -p /在控制節(jié)點上數(shù)據(jù)庫去看看這個實例在哪個結(jié)算節(jié)點上/
MariaDB [(none)]> select node from nova.instances where uuid='09dca062-c577-469f-bff5-cccbe65a5b7c'; /得到這個實例所在的計算節(jié)點/
ll /var/lib/nova/instances/ /到該計算節(jié)點查看實例文件夾在不在/
rm -Rf 09dca062-c577-469f-bff5-cccbe65a5b7c /在的話配并,給刪除/
現(xiàn)在再次進入數(shù)據(jù)庫,進行多個表格刪除對應(yīng)實例ID的記錄高镐。
1. nova.instances表中溉旋,實例ID的字段名是uuid;
2. 其他外鏈表使用的是instance_uuid來引用嫉髓。
MariaDB [nova]> delete from table_name where instance_uuid='09dca062-c577-469f-bff5-cccbe65a5b7c'; /從下面的表格中一一刪除關(guān)聯(lián)的記錄/
table_name如下:
1. security_group_instance_association观腊,實例安全組邑闲,創(chuàng)建默認安全組是default,但不會記錄梧油,如果你已經(jīng)關(guān)聯(lián)了安全組苫耸,那就刪除下*/
2. instance_info_caches,實例緩存儡陨,刪除
3. block_device_mapping褪子,實例塊存儲,默認保存了一條volume_id為NULL的記錄骗村,刪除之*/
4. instance_actions_events嫌褪,實例操作結(jié)果,字段action_id引用下表instance_actions中的id胚股,該表沒有instance_uuid*/
5. instance_actions笼痛,實例操作,每個操作有一個id琅拌,作為上表instance_actions_events的action_id*/
這里我在想缨伊,真是蛋疼,兩個表為啥不結(jié)合為一個表进宝。所以只能首先在instance_actions中獲取操作id然后在events中再去刪
MariaDB [nova]> select id,action,instance_uuid from instance_actions where instance_uuid='09dca062-c577-469f-bff5-cccbe65a5b7c';
[html] view plaincopy
<embed id="ZeroClipboardMovie_2" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="17" name="ZeroClipboardMovie_2" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&width=16&height=17" wmode="transparent" style="box-sizing: border-box;">
- +-----+--------+--------------------------------------+
- | id | action | instance_uuid |
- +-----+--------+--------------------------------------+
- | 380 | create | 09dca062-c577-469f-bff5-cccbe65a5b7c |
- | 382 | delete | 09dca062-c577-469f-bff5-cccbe65a5b7c |
- | 383 | delete | 09dca062-c577-469f-bff5-cccbe65a5b7c |
- | 384 | delete | 09dca062-c577-469f-bff5-cccbe65a5b7c |
- | 385 | delete | 09dca062-c577-469f-bff5-cccbe65a5b7c |
- | 386 | delete | 09dca062-c577-469f-bff5-cccbe65a5b7c |
- +-----+--------+--------------------------------------+
MariaDB [nova]> delete from instance_actions_events where action_id='380'; /我在儀表盤操作了基礎(chǔ)/
MariaDB [nova]> delete from instance_actions_events where action_id='382';
MariaDB [nova]> delete from instance_actions_events where action_id='383';
MariaDB [nova]> delete from instance_actions_events where action_id='384';
MariaDB [nova]> delete from instance_actions_events where action_id='385';
MariaDB [nova]> delete from instance_actions_events where action_id='386'; /刪除instance_action_events之后再去刪除instance_action/
6. instance_faults刻坊,實例錯誤
7. instance_extra,沒有看表的內(nèi)容即彪,不知道放的啥東西紧唱,只有一條記錄
8. instance_system_metadata,實例元數(shù)據(jù)隶校,記錄蠻多的
9. instances漏益,實例表,記錄所有實例深胳,儀表盤的實例列表就是讀取這里
上面的9個表格刪除完畢止之后绰疤,不要急著去刷新儀表盤,不然會提示無法獲取實例列表信息 - 蠻嚇人的舞终!實例占用的資源依然被占用轻庆。
systemctl restart openstack-nova-api openstack-nova-conductor /重啟下服務(wù)/
nova list /實例刪掉了,資源收回/
最后如果每次都這么手動的去搞敛劝,麻煩余爆,那就寫個腳本:
vim deletevm.sh
[html] view plaincopy
<embed id="ZeroClipboardMovie_3" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="17" name="ZeroClipboardMovie_3" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&width=16&height=17" wmode="transparent" style="box-sizing: border-box;">
- mysql -uroot -p << EOF
- use nova;
- delete from security_group_instance_association where instance_uuid='$1';
- delete from instance_info_caches where instance_uuid='$1';
[html] view plaincopy
<embed id="ZeroClipboardMovie_4" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="17" name="ZeroClipboardMovie_4" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&width=16&height=17" wmode="transparent" style="box-sizing: border-box;">
- delete from block_device_mapping where instance_uuid='$1';
[html] view plaincopy
<embed id="ZeroClipboardMovie_5" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="17" name="ZeroClipboardMovie_5" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=5&width=16&height=17" wmode="transparent" style="box-sizing: border-box;">
- delete from instance_actions where instance_uuid='$1'; /這個地方可能需要手工,SQL能力不強哎/
[html] view plaincopy
<embed id="ZeroClipboardMovie_6" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="17" name="ZeroClipboardMovie_6" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=6&width=16&height=17" wmode="transparent" style="box-sizing: border-box;">
- delete from instance_faults where instance_uuid='$1';
[html] view plaincopy
<embed id="ZeroClipboardMovie_7" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="17" name="ZeroClipboardMovie_7" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=7&width=16&height=17" wmode="transparent" style="box-sizing: border-box;">
- delete from instance_extra where instance_uuid='$1';
[html] view plaincopy
<embed id="ZeroClipboardMovie_8" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="17" name="ZeroClipboardMovie_8" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=8&width=16&height=17" wmode="transparent" style="box-sizing: border-box;">
- delete from instance_system_metadata where instance_uuid='$1';
[html] view plaincopy
<embed id="ZeroClipboardMovie_9" src="http://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16" height="17" name="ZeroClipboardMovie_9" align="middle" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=9&width=16&height=17" wmode="transparent" style="box-sizing: border-box;">
- delete from instances where instance_uuid='$1';
- EOF
chmod +x deletevm.sh
./deletevm.sh instance_id /以后用這個腳本來搞就快多了/
nova list /最后可以再看看/
</article>
轉(zhuǎn)自 http://blog.csdn.net/evandeng2009/article/details/50488831