openstack上建立vm例項後,狀態為ERROR問題解決

散盡浮華發表於2016-10-31

 

問題說明:
在openstack上建立虛擬機器,之前已順利建立了n個centos6.8映象的vm
現在用ubuntu14.04映象建立vm,發現vm建立後的狀態為ERROR!

1)終端命令列操作vm建立

[root@linux-node2 src]# nova boot --flavor kvm002 --image ubuntu-14.04 --nic net-id=3a5cef6e-2c12-4f26-938c-5d343edc91b3 --security-group default --key-name mykey kvm-ubuntu01
+--------------------------------------+-----------------------------------------------------+
| Property | Value |
+--------------------------------------+-----------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | - |
| OS-EXT-SRV-ATTR:hypervisor_hostname | - |
| OS-EXT-SRV-ATTR:instance_name | instance-00000006 |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | - |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | 97FNEj25qDHw |
| config_drive | |
| created | 2016-10-31T06:01:15Z |
| flavor | kvm002 (38d2c062-3fc5-4fc8-9bef-3cf16a7cf6d0) |
| hostId | |
| id | 898363d4-b5df-4603-80f3-299bba76f79c |
| image | ubuntu-14.04 (25fa5e72-5e10-4500-905a-82eda30dca21) |
| key_name | mykey |
| metadata | {} |
| name | kvm-ubuntu01 |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | BUILD |
| tenant_id | 0cd3632df93d48d6b2c24c67f70e56b8 |
| updated | 2016-10-31T06:01:15Z |
| user_id | 52ba7917bb284af7ad6ac313b7e8e948 |
+--------------------------------------+-----------------------------------------------------+

建立後,發現vm的狀態是ERROR

[root@linux-node2 src]# nova list
+--------------------------------------+--------------+--------+------------+-------------+----------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+--------------+--------+------------+-------------+----------+
| 898363d4-b5df-4603-80f3-299bba76f79c | kvm-ubuntu01 | ERROR | - | NOSTATE | |
+--------------------------------------+--------------+--------+------------+-------------+----------+

2)嘗試在openstack的dashboard介面裡建立vm(即:“計算”->“例項"->"啟動雲主機")如果vm建立失敗,則會顯示錯誤資訊

如上圖,報錯資訊:
Flavor's disk is too small for requested image. Flavor disk is 16106127360 bytes, image is 21474836480 bytes.].

說明建立vm時所使用的Flavor(雲主機型別)的磁碟空間不滿足image映象要求!本案例是說kvm002(15G)的根磁碟不滿足ubuntu-14.04(openstack介面-“映象”檢視此映象大小是25G)映象大小。

檢視建立vm所使用的Flavor的型別

解決辦法:

調整對應Flavor型別的跟磁碟大小(即:"系統"->"雲主機型別"->"編輯雲主機型別"->"主機型別資訊")。如下,由原來的15G調整到30G!

最後,再次嘗試建立vm:

[root@linux-node2 src]# nova boot --flavor kvm002 --image ubuntu-14.04 --nic net-id=3a5cef6e-2c12-4f26-938c-5d343edc91b3 --security-group default --key-name mykey kvm-ubuntu01
+--------------------------------------+-----------------------------------------------------+
| Property | Value |
+--------------------------------------+-----------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | - |
| OS-EXT-SRV-ATTR:hypervisor_hostname | - |
| OS-EXT-SRV-ATTR:instance_name | instance-00000006 |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | - |
| OS-SRV-USG:terminated_at | - |
| accessIPv4 | |
| accessIPv6 | |
| adminPass | 97FNEj25qDHw |
| config_drive | |
| created | 2016-10-31T06:01:15Z |
| flavor | kvm002 (38d2c062-3fc5-4fc8-9bef-3cf16a7cf6d0) |
| hostId | |
| id | 898363d4-b5df-4603-80f3-299bba76f79c |
| image | ubuntu-14.04 (25fa5e72-5e10-4500-905a-82eda30dca21) |
| key_name | mykey |
| metadata | {} |
| name | kvm-ubuntu01 |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| security_groups | default |
| status | BUILD |
| tenant_id | 0cd3632df93d48d6b2c24c67f70e56b8 |
| updated | 2016-10-31T06:01:15Z |
| user_id | 52ba7917bb284af7ad6ac313b7e8e948 |
+--------------------------------------+-----------------------------------------------------+

建立虛擬機器後,發現vm可以正常啟動了!

[root@linux-node2 src]# nova list
+--------------------------------------+--------------+--------+------------+-------------+--------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+--------------+--------+------------+-------------+--------------------+
| 729dd327-3447-42b9-b9cb-e7ef4a38b725 | kvm-ubuntu01 | ACTIVE | - | Running | flat=192.168.1.120 |
+--------------------------------------+--------------+--------+------------+-------------+--------------------+

------------------------------------------------------------------------------------------------------------------------------

問題:在一個計算節點上建立虛擬機器,建立前幾個虛擬機器都沒問題,但是再建立第n個虛擬機器時就失敗,報錯如下:
建立雲主機,狀態錯誤,無法啟動,提示NoValidHost: No valid host was found. There are not enough hosts available.

檢視nova-conductor.log,如下:
[root@linux-node2 nova]# pwd
/var/log/nova
[root@linux-node2 nova]# tail -100 nova-conductor.log
...................

2016-11-01 01:28:38.889 51843 WARNING nova.scheduler.utils [req-9eb2b8ec-216b-4073-95bd-1fbb51844faf 52ba7917bb284af7ad6ac313b7e8e948 0cd3632df93d48d6b2c24c67f70e56b8 - - -] Failed to compute_task_build_instances: No valid host was found. There are not enough hosts available.
Traceback (most recent call last):

File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/server.py", line 142, in inner
return func(*args, **kwargs)

File "/usr/lib/python2.7/site-packages/nova/scheduler/manager.py", line 84, in select_destinations
filter_properties)

File "/usr/lib/python2.7/site-packages/nova/scheduler/filter_scheduler.py", line 90, in select_destinations
raise exception.NoValidHost(reason=reason)

NoValidHost: No valid host was found. There are not enough hosts available.

2016-11-01 01:28:38.889 51843 WARNING nova.scheduler.utils [req-9eb2b8ec-216b-4073-95bd-1fbb51844faf 52ba7917bb284af7ad6ac313b7e8e948 0cd3632df93d48d6b2c24c67f70e56b8 - - -] [instance: 2211eeb4-9d06-4b15-ac15-69cdabe280ff] Setting instance to ERROR state.

這個問題產生的很大原因有:
1)計算節點的記憶體不足、CPU資源不夠、硬碟空間資源不足造成的;將雲主機型別規格調小點,發現就能建立成功。
2)網路配置不正確,造成建立虛擬機器的時候獲取ip失敗;網路不通或防火牆引起。
3)openstack-nova-compute服務狀態問題。可以嘗試重啟控制節點的nova相關服務和計算節點的openstack-nova-compute服務;詳細檢查控制節點和計算節點的nova.conf配置是否有不當配置。
4)這個報錯問題的原因很多,具體要檢視/var/log/nova下的日誌詳細分析。重點是nova-compute.log、nova-conductor.log日誌

----------------------------------------------------------------------------------------------------
在部署openstack虛擬機器的時候,要注意以下幾點:
(1)控制節點和計算節點在部署前,需要在/etc/hosts裡面對主機對映,並且後面不能輕易更改,否則會出問題!
(2)mysql的連線數要調大!否則在操作過程中會由於mysql連線數過多而中斷!比如設定mysql連線數為1000,mysql命令為set GLOBAL max_connections=1000; 
(3)在建立vm的時候,要保證openstack節點的記憶體夠用。
(4)所使用的Flavor雲主機型別配置的根磁碟要滿足image映象的空間。

相關文章