# source demo-openrc.sh

# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
53:fd:b1:1e:28:c5:2e:d7:e8:ef:54:a8:0e:70:38:4a root@controller1
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|           o     |
|          . + .  |
|         o o = + |
|      E S + = * .|
|     . . = = o o |
|      .   . o o  |
|           o o   |
|            ..o  |
+-----------------+

# nova keypair-add --pub-key ~/.ssh/id_rsa.pub demo-key

# nova keypair-list
+----------+-------------------------------------------------+
| Name     | Fingerprint                                     |
+----------+-------------------------------------------------+
| demo-key | 53:fd:b1:1e:28:c5:2e:d7:e8:ef:54:a8:0e:70:38:4a |
+----------+-------------------------------------------------+

# nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
| 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
| 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
| 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
| 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

# nova image-list
+--------------------------------------+--------------------------+--------+--------+
| ID                                   | Name                     | Status | Server |
+--------------------------------------+--------------------------+--------+--------+
| 89e7fa04-dc3c-426f-9752-75f4c603bcc2 | cirros-0.3.0-x86_64-disk | ACTIVE |        |
+--------------------------------------+--------------------------+--------+--------+

# neutron net-list
+--------------------------------------+----------+-----------------------------------------------------+
| id                                   | name     | subnets                                             |
+--------------------------------------+----------+-----------------------------------------------------+
| 6484c200-a3ff-437c-8749-cf83147cb0d3 | demo-net | 2b4bf426-5e0b-44da-8772-1a306f127793 192.168.1.0/24 |
+--------------------------------------+----------+-----------------------------------------------------+

# nova secgroup-list
+--------------------------------------+---------+-------------+
| Id                                   | Name    | Description |
+--------------------------------------+---------+-------------+
| 65e1f270-1073-4254-945e-86d1db4f0a30 | default | default     |
+--------------------------------------+---------+-------------+

# nova boot --flavor m1.tiny --image cirros-0.3.0-x86_64-disk --nic net-id=6484c200-a3ff-437c-8749-cf83147cb0d3 --security-group default --key-name demo-key demo-instance1
+--------------------------------------+-----------------------------------------------------------------+
| Property                             | Value                                                           |
+--------------------------------------+-----------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                          |
| OS-EXT-AZ:availability_zone          | nova                                                            |
| 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                            | 4rXi2w2radYo                                                    |
| config_drive                         |                                                                 |
| created                              | 2015-12-17T17:31:32Z                                            |
| flavor                               | m1.tiny (1)                                                     |
| hostId                               |                                                                 |
| id                                   | ddec8d7b-e829-4760-a1bf-bf1dd2995dd2                            |
| image                                | cirros-0.3.0-x86_64-disk (89e7fa04-dc3c-426f-9752-75f4c603bcc2) |
| key_name                             | demo-key                                                        |
| metadata                             | {}                                                              |
| name                                 | demo-instance1                                                  |
| os-extended-volumes:volumes_attached | []                                                              |
| progress                             | 0                                                               |
| security_groups                      | default                                                         |
| status                               | BUILD                                                           |
| tenant_id                            | 33c0fa01b2724184bc8def11443a3caa                                |
| updated                              | 2015-12-17T17:31:32Z                                            |
| user_id                              | cbdb8af1c8e9444dbd9974ad3aca66fe                                |
+--------------------------------------+-----------------------------------------------------------------+

# nova list
+--------------------------------------+----------------+--------+------------+-------------+----------------------+
| ID                                   | Name           | Status | Task State | Power State | Networks             |
+--------------------------------------+----------------+--------+------------+-------------+----------------------+
| ddec8d7b-e829-4760-a1bf-bf1dd2995dd2 | demo-instance1 | ERROR  | -          | NOSTATE     | demo-net=192.168.1.2 |
+--------------------------------------+----------------+--------+------------+-------------+----------------------+

# nova show ddec8d7b-e829-4760-a1bf-bf1dd2995dd2
+--------------------------------------+------------------------------------------------------------------------------------------+
| Property                             | Value                                                                                    |
+--------------------------------------+------------------------------------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                                                   |
| OS-EXT-AZ:availability_zone          | nova                                                                                     |
| OS-EXT-STS:power_state               | 0                                                                                        |
| OS-EXT-STS:task_state                | -                                                                                        |
| OS-EXT-STS:vm_state                  | error                                                                                    |
| OS-SRV-USG:launched_at               | -                                                                                        |
| OS-SRV-USG:terminated_at             | -                                                                                        |
| accessIPv4                           |                                                                                          |
| accessIPv6                           |                                                                                          |
| config_drive                         |                                                                                          |
| created                              | 2015-12-17T17:31:32Z                                                                     |
| demo-net network                     | 192.168.1.2                                                                              |
| fault                                | {"message": "No valid host was found. ", "code": 500, "created": "2015-12-17T17:31:35Z"} |
| flavor                               | m1.tiny (1)                                                                              |
| hostId                               | 7788431710acba448fac373e02d6a8ce8c71d41f1355210071b2699e                                 |
| id                                   | ddec8d7b-e829-4760-a1bf-bf1dd2995dd2                                                     |
| image                                | cirros-0.3.0-x86_64-disk (89e7fa04-dc3c-426f-9752-75f4c603bcc2)                          |
| key_name                             | demo-key                                                                                 |
| metadata                             | {}                                                                                       |
| name                                 | demo-instance1                                                                           |
| os-extended-volumes:volumes_attached | []                                                                                       |
| security_groups                      | default                                                                                  |
| status                               | ERROR                                                                                    |
| tenant_id                            | 33c0fa01b2724184bc8def11443a3caa                                                         |
| updated                              | 2015-12-17T17:31:34Z                                                                     |
| user_id                              | cbdb8af1c8e9444dbd9974ad3aca66fe                                                         |
+--------------------------------------+------------------------------------------------------------------------------------------+
发现报错“No valid host was found”没有可用的主机。

查看comput1的服务状态:
# systemctl status libvirtd.service openstack-nova-compute.service
libvirtd.service - Virtualization daemon
Dec 16 23:20:05 compute1 libvirtd[2710]: End of file while reading data: Input/output error

先尝试重启服务:
# systemctl restart libvirtd.service
# systemctl status -l libvirtd.service
libvirtd.service - Virtualization daemon
Dec 18 17:09:35 compute1 libvirtd[22823]: Module /usr/lib64/libvirt/connection-driver/libvirt_driver_lxc.so not accessible

此次报错不同,缺少某个库文件,安装后没问题:
# yum install -y libvirt-daemon-lxc
# systemctl restart libvirtd.service
# systemctl status -l libvirtd.service

删除出问题的实例并重建:
# nova delete ddec8d7b-e829-4760-a1bf-bf1dd2995dd2
# nova boot --flavor m1.tiny --image cirros-0.3.0-x86_64-disk --nic net-id=6484c200-a3ff-437c-8749-cf83147cb0d3 --security-group default --key-name demo-key demo-instance1
# nova list
发现还是相同报错,再检查服务,服务没问题:
# systemctl status -l libvirtd.service openstack-nova-compute.service

跟踪计算节点创建实例时的日志:
# tail -f /var/log/nova/nova-compute.log

可见错误500,估计又是某个配置项不对:
2015-12-18 18:55:38.627 32127 ERROR nova.compute.manager [-] [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0] Instance failed to spawn
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0] Traceback (most recent call last):
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 2246, in _build_resources
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     yield resources
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/compute/manager.py", line 2116, in _build_and_run_instance
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     block_device_info=block_device_info)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 2616, in spawn
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     admin_pass=admin_password)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 3006, in _create_image
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     project_id=instance['project_id'])
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/imagebackend.py", line 208, in cache
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     *args, **kwargs)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/imagebackend.py", line 451, in create_image
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     prepare_template(target=base, max_size=size, *args, **kwargs)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/openstack/common/lockutils.py", line 272, in inner
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     return f(*args, **kwargs)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/imagebackend.py", line 198, in fetch_func_sync
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     fetch_func(target=target, *args, **kwargs)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/virt/libvirt/utils.py", line 452, in fetch_image
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     max_size=max_size)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/virt/images.py", line 79, in fetch_to_raw
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     max_size=max_size)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/virt/images.py", line 73, in fetch
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     IMAGE_API.download(context, image_href, dest_path=path)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/image/api.py", line 178, in download
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     dst_path=dest_path)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 359, in download
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     _reraise_translated_image_exception(image_id)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 357, in download
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     image_chunks = self._client.call(context, 1, 'data', image_id)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/nova/image/glance.py", line 232, in call
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     return getattr(client.images, method)(*args, **kwargs)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/glanceclient/v1/images.py", line 142, in data
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     % urlparse.quote(str(image_id)))
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 259, in get
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     return self._request('GET', url, **kwargs)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]   File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", line 227, in _request
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]     raise exc.from_response(resp, resp.content)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0] HTTPInternalServerError: HTTPInternalServerError (HTTP 500)
2015-12-18 18:55:38.627 32127 TRACE nova.compute.manager [instance: 267a9e48-e6c9-47dc-9736-a37f2750c1c0]2015-12-18 18:55:37.188 8873 INFO nova.api.openstack.wsgi [req-27360a40-7988-4209-9ccc-aa13d64aaed1 None] HTTP exception thrown: The resource could not be found.

老外关于此问题的讨论:
https://bugs.launchpad.net/nova/+bug/1306342

从日志看,最后出问题的似乎是image,故删除旧的image,重新上传:
# glance image-create --name "cirros-0.3.0-x86_64-disk" --file cirros-0.3.0-x86_64-disk.img --disk-format qcow2 --container-format bare --is-public True --progress

# nova boot --flavor m1.tiny --image cirros-0.3.0-x86_64-disk --nic net-id=6484c200-a3ff-437c-8749-cf83147cb0d3 --security-group default --key-name demo-key demo-instance1

# nova list
+--------------------------------------+----------------+--------+------------+-------------+-----------------------+
| ID                                   | Name           | Status | Task State | Power State | Networks              |
+--------------------------------------+----------------+--------+------------+-------------+-----------------------+
| c2a0d974-4548-4f3a-a64f-85f1125001eb | demo-instance1 | ACTIVE | -          | Running     | demo-net=192.168.1.12 |
+--------------------------------------+----------------+--------+------------+-------------+-----------------------+
没问题了,颇感慨。我环境是3个控制节点,glance分别安装在3个节点上,image文件存放于/var/lib/glance/images,创建实例前,我已手动复制image到各控制节点的相同路径。
之前上传image的节点是controller2,现在调用image的节点是controller1。
看来即使3个glance使用了相同的mysql数据库,还是存在每个节点的image不同步的问题。说明glance的多节点配置我还是不得要领。

# nova get-vnc-console demo-instance1 novnc
+-------+----------------------------------------------------------------------------+
| Type  | Url                                                                        |
+-------+----------------------------------------------------------------------------+
| novnc | http://myvip:6080/vnc_auto.html?token=c1d27680-de9a-418c-acf4-4ff35f98d3fd |
+-------+----------------------------------------------------------------------------+

登录cirros,默认密码“cubswin:)”:
# ping 192.168.1.1

openstack controller ha测试环境搭建记录(十五)——创建实例的更多相关文章

  1. openstack controller ha测试环境搭建记录(五)——配置rabbitmq集群

    配置rabbitmq集群的步骤非常简单,因为其本身含集群功能,参考openstack官网文档:http://docs.openstack.org/ha-guide/controller-ha-rabb ...

  2. openstack controller ha测试环境搭建记录(一)——操作系统准备

    为了初步了解openstack controller ha的工作原理,搭建测试环境进行学习. 在学习该方面知识时,当前采用的操作系统版本是centos 7.1 x64.首先在ESXi中建立2台用于测试 ...

  3. openstack controller ha测试环境搭建记录(二)——配置corosync和pacemaker

    corosync.conf请备份再编辑:# vi /etc/corosync/corosync.conf totem {        version: 2 token: 10000        t ...

  4. openstack controller ha测试环境搭建记录(十)——配置neutron(控制节点)

    创建neutron用户:mysql -u root -p CREATE DATABASE neutron;GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@ ...

  5. openstack controller ha测试环境搭建记录(十四)——配置cinder(存储节点)

    先简述cinder存储节点的配置:  1.IP地址是10.0.0.41:  2.主机名被设置为block1:  3.所有节点的hosts文件已添加相应条目:  4.已经配置了ntp时间同步:  5.已 ...

  6. openstack controller ha测试环境搭建记录(十二)——配置neutron(计算节点)

    在计算节点配置内核参数:vi /etc/sysctl.confnet.ipv4.conf.all.rp_filter=0net.ipv4.conf.default.rp_filter=0 在计算节点使 ...

  7. openstack controller ha测试环境搭建记录(十三)——配置cinder(控制节点)

    在任一控制节点创建用户:mysql -u root -pCREATE DATABASE cinder;GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'loc ...

  8. openstack controller ha测试环境搭建记录(七)——配置glance

    在所有集群安装glance软件:yum install -y openstack-glance python-glanceclient 在任一节点创建glance用户:mysql -u root -p ...

  9. openstack controller ha测试环境搭建记录(六)——配置keystone

    在所有节点的hosts文件添加:10.0.0.10 myvip 在所有节点安装# yum install -y openstack-keystone python-keystoneclient# yu ...

随机推荐

  1. TextUtils使用

    public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceS ...

  2. DotNetBar教程

    DotNetBar是一组用于.NET Framework环境下的一组组件集,利用该组件集能够打造绚丽并且实用的应用程序界面,给开发人员提供极大的便利.关于DotNetBar,详情请参考其官方网站:ht ...

  3. Hibernate 系列教程10-组成关系

    组成关系 在一个员工模型里面需要存入 员工公司所在地址的城市,街道 员工籍贯所在的城市,街道, 此时可以抽取城市,街道变成一个模型即是组成关系 Employee public class Employ ...

  4. UVA 10759 Dice Throwing

    题意为抛n个骰子凑成的点数和大于或等于x的概率,刚开始用暴力枚举,虽然AC了,但时间为2.227s,然后百度了下别人的做法,交了一遍,靠,0.000s,然后看了下思路,原来是dp,在暴力的基础上记忆化 ...

  5. 优化eclipse

    1.取消自动validation windows–>perferences–>validation 除开Manual下面的复选框全部选中之外,其他全部不选 如需验证,在要验证的文件上,单击 ...

  6. RACSignal的Subscription深入

    ReactiveCocoa是一个FRP的思想在Objective-C中的实现框架,目前在美团的项目中被广泛使用.对于ReactiveCocoa的基本用法,网上有很多相关的资料,本文不再讨论.RACSi ...

  7. %3f URL --> '?'拼接引发的问题

    转载自:https://www.reddit.com/r/swift/comments/2w19kp/how_do_you_send_a_through_nsmutableurlrequest/ ho ...

  8. 快学Scala-第三章 数组相关操作

    知识点: 1.定长数组 Array val nums = new Array[Int](10) //10个整数的数组,所有元素初始化为0 val a = new Array[String](10) / ...

  9. MyEclipse使用总结——修改MyEclipse默认的Servlet和jsp代码模板

    http://www.cnblogs.com/xdp-gacl/p/3769058.html   孤傲苍狼 只为成功找方法,不为失败找借口! MyEclipse使用总结——修改MyEclipse默认的 ...

  10. Ng-model undefined in the controller

    这个问题是我最近在项目中碰到的,暂时没找到原因,找到一个解决方法,还多请大神指教,在Stack Overflow找到解决方法: I am having some "problems" ...