上传的镜像无法用来启动云主机怎么办

本篇文章给大家分享的是有关上传的镜像无法用来启动云主机怎么办,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

背景

Openstack各功能正常,使用其它镜像创建云硬盘并用来启动云主机也正常,但是就是这个镜像有问题。

报错信息

dashboard页面上的错误:

No valid host was found. Exceeded max scheduling attempts 3 for instance 345339f1-0a52-42b3-904b-0d3065b5329b. Last exception: [u'Traceback (most recent call last):\n', u' File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 2248, in _do

错误描述不清晰,查找错误日志

# view nova-compute.log
 [instance: ae58a0a8-f197-4099-93db-36d76a696d63] Instance fail
 ed to spawn
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63] Traceback (most recent call last):
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 2473, in _build_resources
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     yield resources
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 2345, in _build_and_run_instance
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     block_device_info=block_device_info)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 2388, in spawn
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     write_to_disk=True)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 4175, in _get_guest_xml
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     network_info_str = str(network_info)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/network/model.py", line 480, in __str__
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     return self._sync_wrapper(fn, *args, **kwargs)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/network/model.py", line 463, in _sync_wrapper
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     self.wait()
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/network/model.py", line 495, in wait
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     self[:] = self._gt.wait()
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/eventlet/greenthread.py", line 175, in wait
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     return self._exit_event.wait()
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/eventlet/event.py", line 125, in wait
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     current.throw(*self._exc)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/eventlet/greenthread.py", line 214, in main
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     result = function(*args, **kwargs)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 1795, in _allocate_network_async
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     dhcp_options=dhcp_options)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/network/neutronv2/api.py", line 577, in allocate_for_instance
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     self._delete_ports(neutron, instance, created_port_ids)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 85, in __exit__
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     six.reraise(self.type_, self.value, self.tb)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/network/neutronv2/api.py", line 569, in allocate_for_instance
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     security_group_ids, available_macs, dhcp_opts)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/network/neutronv2/api.py", line 331, in _create_port
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     network_id, instance=instance)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/oslo_utils/excutils.py", line 85, in __exit__
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     six.reraise(self.type_, self.value, self.tb)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/nova/network/neutronv2/api.py", line 304, in _create_port
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     port_id = port_client.create_port(port_req_body)['port']['id']
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/neutronclient/v2_0/client.py", line 102, in with_params
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     ret = self.function(instance, *args, **kwargs)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/neutronclient/v2_0/client.py", line 544, in create_port
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     return self.post(self.ports_path, body=body)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/neutronclient/v2_0/client.py", line 298, in post
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     headers=headers, params=params)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/neutronclient/v2_0/client.py", line 211, in do_request
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     self._handle_fault_response(status_code, replybody)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/neutronclient/v2_0/client.py", line 185, in _handle_fault_response
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     exception_handler_v20(status_code, des_error_body)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]   File "/usr/lib/python2.7/site-packages/neutronclient/v2_0/client.py", line 83, in exception_handler_v20
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]     message=message)
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63] NeutronClientException: Authentication required
 2016-07-18 16:40:24.930 1067239 TRACE nova.compute.manager [instance: ae58a0a8-f197-4099-93db-36d76a696d63]
 2016-07-18 16:40:24.976 1067239 INFO nova.compute.manager [req-177d574f-f36e-4e99-946c-d34612ecd607 3d8b93c202a94046be24e4eee5d16fb8 c05f2d7996144cb69921e64391db4512 - - -] [instance: ae58a0a8-f197-4099-93db-36d76a696d63] Terminating in
 stance

解决

错误里提示要求neutron的认证,突然灵光一闪想起来这个虚拟机镜像cirros是一开始安装完glance服务上传测试用的,那个时候还没有对接ceph,也就是说这个镜像并不是存储在ceph里的。重新上传一个cirros的镜像,启动云主机成功。

另外因为更改了glance的存储后端,导致原先的镜像无法删除,有两种解决办法:

1、修改glance-api.conf,改回原先的配置,重启glance的相关服务,再删除,删除之后再改成新的配置重启服务

2、直接修改元数据库,在glance库中,image_locations和images表记录了镜像的存储信息。

MariaDB [glance]> select * from image_locations;
+----+--------------------------------------+--------------------------------------------------------------------+---------------------+---------------------+---------------------+---------+-----------+---------+
| id | image_id                             | value                                                              | created_at          | updated_at          | deleted_at          | deleted | meta_data | status  |
+----+--------------------------------------+--------------------------------------------------------------------+---------------------+---------------------+---------------------+---------+-----------+---------+
|  1 | de64317b-638f-401e-b6df-d0bc8d5cd18a | file:///var/lib/glance/images/de64317b-638f-401e-b6df-d0bc8d5cd18a | 2016-10-13 08:05:39 | 2016-10-17 02:07:03 | 2016-10-17 02:07:03 |       1 | {}        | deleted |
+----+--------------------------------------+--------------------------------------------------------------------+---------------------+---------------------+---------------------+---------+-----------+---------+

MariaDB [glance]> select * from images;
+--------------------------------------+--------+----------+---------+-----------+---------------------+---------------------+---------------------+---------+-------------+------------------+----------------------------------+----------------------------------+----------+---------+-----------+--------------+
| id                                   | name   | size     | status  | is_public | created_at          | updated_at          | deleted_at          | deleted | disk_format | container_format | checksum                         | owner                            | min_disk | min_ram | protected | virtual_size |
+--------------------------------------+--------+----------+---------+-----------+---------------------+---------------------+---------------------+---------+-------------+------------------+----------------------------------+----------------------------------+----------+---------+-----------+--------------+
| de64317b-638f-401e-b6df-d0bc8d5cd18a | cirros | 13287936 | deleted |         1 | 2016-10-13 08:05:38 | 2016-10-17 02:07:04 | 2016-10-17 02:07:04 |       1 | qcow2       | bare             | ee1eca47dc88f4879d8a229cc70a07c6 | 1c9b4504ff224d7f983158bfd8bec6aa |        0 |       0 |         0 |         NULL |
+--------------------------------------+--------+----------+---------+-----------+---------------------+---------------------+---------------------+---------+-------------+------------------+----------------------------------+----------------------------------+----------+---------+-----------+--------------+

以上就是上传的镜像无法用来启动云主机怎么办,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。