立即注册 登录
About云-梭伦科技 返回首页

pig2的个人空间 https://www.aboutyun.com/?61 [收藏] [复制] [分享] [RSS]

日志

openstack【juno】入门 【实例篇】二十六:创建实例(neutron)

热度 1已有 6660 次阅读2015-2-26 18:09



问题导读

1.如何创建实例?
2.openstack默认几个flavor?
3.如何查看虚拟机状态?




1.生成密钥对


大多数 cloud images支持公钥授权而不是传统的用户名密码授权。在创建公钥前,你必须使用ssh-keygen生成公/私钥对。添加公钥到openstack环境中。

1.生效demo租户凭据
  1. source admin-openrc.sh

内容如下:
  1. export OS_TENANT_NAME=admin
  2. export OS_USERNAME=admin
  3. export OS_PASSWORD=ADMIN_PASS
  4. export OS_AUTH_URL=http://controller:35357/v2.0




2.生成密钥对

  1. ssh-keygen



3.添加公玥到openstack环境

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



4.核实添加的公玥
  1. nova keypair-list



输出下列内容:
  1. root@controller:~# nova keypair-list
  2. +----------+-------------------------------------------------+
  3. | Name     | Fingerprint                                     |
  4. +----------+-------------------------------------------------+
  5. | demo-key | a1:23:cb:63:c6:0e:67:14:da:7e:89:a2:97:a4:3f:f9 |
  6. +----------+-------------------------------------------------+

 




创建一个实例


创建实例,你至少指定flavor,镜像名称, 网络,安全组, key, 和实例名称.

1.一个flavor指定一个虚拟资源分配文件包括处理器、内存、存储

列出可用flavor
  1. nova flavor-list

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


 



第一个实例,可以使用m1.tinyflavor.

2.列出可用镜像
  1. nova image-list

 



  1. +--------------------------------------+---------------------+--------+--------+
  2. | ID                                   | Name                | Status | Server |
  3. +--------------------------------------+---------------------+--------+--------+
  4. | 9ec0ceec-0629-406a-9069-159a8b59ea78 | cirros-0.3.3-x86_64 | ACTIVE |        |
  5. +--------------------------------------+---------------------+--------+--------+



第一个实例使用 cirros-0.3.3-x86_64镜像。

3.列出可用网络

  1. neutron net-list

 

  1. +--------------------------------------+----------+-----------------------------------------------------+
  2. | id                                   | name                  | subnets                                                                                                   |
  3. +--------------------------------------+----------+-----------------------------------------------------+
  4. | 0028b1d7-07c9-468c-abf2-ccd4dc17b240 | ext-net      | e6fab309-a8ff-4385-8b32-c942434414cf                             |
  5. | 299e4203-135e-4305-8a9f-cdd4f4bda185 | demo-net  | dfb5a684-e837-4556-8c29-c7e01ada590a 192.168.1.0/24 |
  6. +--------------------------------------+----------+-----------------------------------------------------+



第一个实例使用demo-net 租户网络,尽管如此,你需要使用id,而不是使用name

4.列出有效安全组

  1. nova secgroup-list

  1. +--------------------------------------+---------+-------------+
  2. | Id                                   | Name    | Description |
  3. +--------------------------------------+---------+-------------+
  4. | 177deb74-7479-40c3-a332-4811bc9326bf | default | default     |
  5. +--------------------------------------+---------+-------------+







第一个实例,使用默认安全组,这个安全组类似防火墙,阻止远程访问实例。如果拒绝远程访问实例,创建它,然后配置远程访问


5.创建实例

格式如下
  1. nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=DEMO_NET_ID \
  2.   --security-group default --key-name demo-key demo-instance1

需要替换的内容:
DEMO_NET_ID这里为: 
  1. nova boot --flavor m1.tiny --image cirros-0.3.3-x86_64 --nic net-id=6e0c30ab-1c32-4e8e-b08f-84cdf2521713 \
  2. --security-group default --key-name demo-key demo-instance1




6.检测实例状态

  1. nova list

 


这里遇到了创建实例不成功,并且ip地址也并没有显示。在后面会做一些相关说明

7.使用虚拟控制台访问实例

为实例获取一个 Virtual Network Computing (VNC) session url,并通过浏览器访问
  1. nova get-vnc-console demo-instance1 novnc


由于我这里有多个 demo-instance1,所以这里获取不到,使用id的方式获取。
  1. nova get-vnc-console instance-ID novnc




  1. nova get-vnc-console 29e13b8a-9105-44aa-9b24-4cd9bef9a912 novnc




  1. +-------+---------------------------------------------------------------------------------+
  2. | Type  | Url                                                                             |
  3. +-------+---------------------------------------------------------------------------------+
  4. | novnc | http://controller:6080/vnc_auto.html?token=58707002-24c3-4c3f-adc7-6ecbd1c97a53 |
  5. +-------+---------------------------------------------------------------------------------+




获取的url为 http://controller:6080/vnc_auto.html?token=58707002-24c3-4c3f-adc7-6ecbd1c97a53   ,这里需要注意本地一定要配置host
否则不能访问,获知直接使用ip为
http://10.0.0.11:6080/vnc_auto.html?token=58707002-24c3-4c3f-adc7-6ecbd1c97a53

也可以通过界面登录:
http://10.0.0.11/horizon

找到实例,如果控制台没有相应,则单击,下面图标即可

 

登录的用户名和密码都会有提示:用户名为:
cirros
密码为:
cubswin:)


验证 demo-net租户网关
  1. ping -c 4 192.168.1.1


 

  1. ping -c 203.0.113.101

 



############################################################

问题:

1.创建实例失败


Status处于BUILD状态,TASK State处于Scheduling状态,
由于实例的创建是由nova主要来完成的,因此nova的各个进程,一定要起来。
所以通过,查看有6个进程,结果好几个出了问题。
  1. nova-manage service list

这时候,就找到了问题的症结,剩下的就是到/var/log/nova下面查看日志了。
  1. service nova-api restart
  2. service nova-cert restart
  3. service nova-consoleauth restart
  4. service nova-scheduler restart
  5. service nova-conductor restart
  6. service nova-novncproxy restart

然后重启,上面的服务。下面服务都正常,才可创建实例




2.openstack创建实例,获取不到ip地址,不能ping通网关

ping -c 4 192.168.1.1
ping不通网关,这里的原因很多,通过查看日志
应该是
  1. ERROR neutron.plugins.openvswitch.agent.ovs_neutron_agent [req-54efa1c5-7808-4d75-a047-522c0e6ee052 None] Error while processing VIF ports

错误,更多内容:


  1. 2015-02-23 18:22:12.346 1979 ERROR neutron.plugins.openvswitch.agent.ovs_neutron_agent [req-54efa1c5-7808-4d75-a047-522c0e6ee052 None] Error while processing VIF ports
  2. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent Traceback (most recent call last):
  3. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py", line 1406, in rpc_loop
  4. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     ovs_restarted)
  5. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py", line 1205, in process_network_ports
  6. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     port_info.get('updated', set()))
  7. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/agent/securitygroups_rpc.py", line 333, in setup_port_filters
  8. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     self.prepare_devices_filter(new_devices)
  9. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/agent/securitygroups_rpc.py", line 202, in decorated_function
  10. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     return func(self, *args, **kwargs)
  11. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/agent/securitygroups_rpc.py", line 210, in prepare_devices_filter
  12. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     if self.use_enhanced_rpc:
  13. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/agent/securitygroups_rpc.py", line 178, in use_enhanced_rpc
  14. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     self._check_enhanced_rpc_is_supported_by_server())
  15. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/agent/securitygroups_rpc.py", line 184, in _check_enhanced_rpc_is_supported_by_server
  16. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     self.context, devices=[])
  17. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/agent/securitygroups_rpc.py", line 103, in security_group_info_for_devices
  18. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     version='1.2')
  19. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/common/log.py", line 34, in wrapper
  20. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     return method(*args, **kwargs)
  21. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/common/rpc.py", line 161, in call
  22. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     context, msg, rpc_method='call', **kwargs)
  23. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/neutron/common/rpc.py", line 187, in __call_rpc_method
  24. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     return func(context, msg['method'], **msg['args'])
  25. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/oslo/messaging/rpc/client.py", line 152, in call
  26. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     retry=self.retry)
  27. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/oslo/messaging/transport.py", line 90, in _send
  28. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     timeout=timeout, retry=retry)
  29. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/oslo/messaging/_drivers/amqpdriver.py", line 408, in send
  30. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     retry=retry)
  31. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/oslo/messaging/_drivers/amqpdriver.py", line 397, in _send
  32. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     result = self._waiter.wait(msg_id, timeout)
  33. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/oslo/messaging/_drivers/amqpdriver.py", line 285, in wait
  34. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     reply, ending = self._poll_connection(msg_id, timeout)
  35. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent   File "/usr/lib/python2.7/dist-packages/oslo/messaging/_drivers/amqpdriver.py", line 235, in _poll_connection
  36. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent     % msg_id)
  37. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent MessagingTimeout: Timed out waiting for a reply to message ID cef18a2f5cea4036967ddef86eed4cf1
  38. 2015-02-23 18:22:12.346 1979 TRACE neutron.plugins.openvswitch.agent.ovs_neutron_agent 
  39. 2015-02-23 18:22:12.404 1979 INFO neutron.plugins.openvswitch.agent.ovs_neutron_agent [req-54efa1c5-7808-4d75-a047-522c0e6ee052 None] Agent out of sync with plugin!
  40. 2015-02-23 18:22:12.708 1979 INFO neutron.agent.securitygroups_rpc [req-54efa1c5-7808-4d75-a047-522c0e6ee052 None] Preparing filters for devices set([u'92df61ad-21b3-4697-9658-7299193ebc97'])
  41. 2015-02-23 18:22:14.019 1979 INFO neutron.plugins.openvswitch.agent.ovs_neutron_agent [req-54efa1c5-7808-4d75-a047-522c0e6ee052 None] Port 92df61ad-21b3-4697-9658-7299193ebc97 updated. Details: {u'profile': {}, u'admin_state_up': True, u'network_id': u'299e4203-135e-4305-8a9f-cdd4f4bda185', u'segmentation_id': 1, u'device_owner': u'compute:None', u'physical_network': None, u'mac_address': u'fa:16:3e:50:2d:43', u'device': u'92df61ad-21b3-4697-9658-7299193ebc97', u'port_id': u'92df61ad-21b3-4697-9658-7299193ebc97', u'fixed_ips': [{u'subnet_id': u'dfb5a684-e837-4556-8c29-c7e01ada590a', u'ip_address': u'192.168.1.2'}], u'network_type': u'gre'}
  42. 2015-02-23 18:22:14.021 1979 INFO neutron.plugins.openvswitch.agent.ovs_neutron_agent [req-54efa1c5-7808-4d75-a047-522c0e6ee052 None] Assigning 1 as local vlan for net-id=299e4203-135e-4305-8a9f-cdd4f4bda185
  43. 2015-02-23 18:22:14.467 1979 INFO neutron.plugins.openvswitch.agent.ovs_neutron_agent [req-54efa1c5-7808-4d75-a047-522c0e6ee052 None] Configuration for device 92df61ad-21b3-4697-9658-7299193ebc97 completed.
复制代码
为什么会产生上面的问题,原因真不少。
比如你的网卡ip地址是否有问题。你的dhpc agent是否有问题,RabbitMQ 是否正常。
这些都会产生获取不到ip的情况。
我这里则是dhcp agent的问题。

进行下面配置(网络节点)


1.编辑文件 /etc/neutron/dhcp_agent.ini,完成下面内容。
a.在 [DEFAULT] 部分,配置驱动,启用命名空间和启用删除废弃的命名空间
  1. [DEFAULT]
  2. ...
  3. interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
  4. dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
  5. use_namespaces = True
  6. dhcp_delete_namespaces = True

更多内容参考

openstack【juno】入门 【网络篇】十六:neutron安装部署(网络节点)



路过

雷人

握手

鲜花

鸡蛋

发表评论 评论 (3 个评论)

回复 garfield 2015-6-3 17:26
求解,我是做到了dashboard的步骤(跳过了之前的create initial network,打算的是直接在dashboard上面配置)。之后遇到的问题就如上面说的 【.创建实例失败--》Status处于BUILD状态,TASK State处于Scheduling状态,】,在system information里面把所有的services都restart成了up之后 问题还是没有解决。。。  前面的安装过程,除了在comment 掉了rpc_backend =  其他的都和原文一样,, 这个。。能找到出问题的地方吗?
回复 pig2 2015-6-3 23:45
garfield: 求解,我是做到了dashboard的步骤(跳过了之前的create initial network,打算的是直接在dashboard上面配置)。之后遇到的问题就如上面说的 【.创建实例失败--》 ...
先实例化网络
回复 garfield 2015-6-4 08:54
pig2: 先实例化网络
好的  我试试。  谢谢  ^^

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

关闭

推荐上一条 /2 下一条