openstack上创建vm实例后,状态为ERROR问题解决

2018-01-22 15:24:12 浏览数 (1)

问题说明: 在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镜像的空间。

0 人点赞