码迷,mamicode.com
首页 > 系统相关 > 详细

Ubuntu搭建Openstack平台(kilo)(六.实例化网络,创建实例)

时间:2016-05-13 03:32:19      阅读:320      评论:0      收藏:0      [点我收藏+]

标签:

实例化网络

参考文档:http://www.aboutyun.com/thread-13187-1-1.html
http://www.aboutyun.com/thread-14639-1-1.html
http://docs.openstack.org/mitaka/install-guide-ubuntu/launch-instance.html#create-virtual-networks
一.创建外部网络

  • 加载环境
source admin-openrc.sh
  • 创建网络
neutron net-create ext-net --shared --router:external --provider:physical_network external --provider:network_type flat
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | 0e62efcd-8cee-46c7-b163-d8df05c3c5ad |
| mtu                       | 1500                                 |
| name                      | provider                             |
| port_security_enabled     | True                                 |
| provider:network_type     | flat                                 |
| provider:physical_network | provider                             |
| provider:segmentation_id  |                                      |
| router:external           | False                                |
| shared                    | True                                 |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | d84313397390425c8ed50b2f6e18d092     |
+---------------------------+--------------------------------------+

二.创建外网上的子网

neutron subnet-create ext-net EXTERNAL_NETWORK_CIDR --name ext-subnet   --allocation-pool start=FLOATING_IP_START,end=FLOATING_IP_END  --disable-dhcp --gateway EXTERNAL_NETWORK_GATEWAY

#EXTERNAL_NETWORK_CIDR为可用上网IP网段(**一定要能上网**),如203.0.113.0/24,FLOATING_IP_START,end=FLOATING_IP_END是指floating IP的起始IP与终止IP,如203.0.113.100 203.0.113.156,EXTERNAL_NETWORK_GATEWAY为网关,一般是网段的第一个IP 如203.0.113.1

例如:

neutron subnet-create ext-net 203.0.113.0/24 --name ext-subnet  --allocation-pool start=203.0.113.100,end=203.0.113.156  --disable-dhcp --gateway 203.0.113.1
Created a new subnet:
+-------------------+----------------------------------------------------+
| Field             | Value                                              |
+-------------------+----------------------------------------------------+
| allocation_pools  | {"start": "203.0.113.101", "end": "203.0.113.250"} |
| cidr              | 203.0.113.0/24                                     |
| dns_nameservers   | 8.8.4.4                                            |
| enable_dhcp       | True                                               |
| gateway_ip        | 203.0.113.1                                        |
| host_routes       |                                                    |
| id                | 5cc70da8-4ee7-4565-be53-b9c011fca011               |
| ip_version        | 4                                                  |
| ipv6_address_mode |                                                    |
| ipv6_ra_mode      |                                                    |
| name              | provider                                           |
| network_id        | 0e62efcd-8cee-46c7-b163-d8df05c3c5ad               |
| subnetpool_id     |                                                    |
| tenant_id         | d84313397390425c8ed50b2f6e18d092                   |
+-------------------+----------------------------------------------------+

三.创建租户(project)网络

  • 加载环境(特别重要
source demo-openrc.sh
  • 创建租户(project)网络
neutron net-create demo-net
  • 创建租户(project)网络子网
neutron subnet-create demo-net TENANT_NETWORK_CIDR  --name demo-subnet --gateway TENANT_NETWORK_GATEWAY
#TENANT_NETWORK_CIDR为租户(project)网络,一般用192.168.****/24,TENANT_NETWORK_GATEWAY为网管一般为192.168.**.1,可以根据自己的需求设置。

例如:

neutron subnet-create demo-net 192.168.1.0/24 --name demo-subnet --gateway 192.168.1.1
Created a new subnet:
+-------------------+------------------------------------------------+
| Field             | Value                                          |
+-------------------+------------------------------------------------+
| allocation_pools  | {"start": "172.16.1.2", "end": "172.16.1.254"} |
| cidr              | 192.168.1.0/24                                 |
| dns_nameservers   |                                                |
| enable_dhcp       | True                                           |
| gateway_ip        | 192.168.1.1                                    |
| host_routes       |                                                |
| id                | 3482f524-8bff-4871-80d4-5774c2730728           |
| ip_version        | 4                                              |
| ipv6_address_mode |                                                |
| ipv6_ra_mode      |                                                |
| name              | demo-subnet                                    |
| network_id        | 7c6f9b37-76b4-463e-98d8-27e5686ed083           |
| tenant_id         | f5b2ccaa75ac413591f12fcaa096aa5c               |
+-------------------+------------------------------------------------+

四.创建租户路由,并附加外网和租户网络到路由

  • 创建租户路由
neutron router-create demo-router
  • 连接路由器到租户网络
neutron router-interface-add demo-router demo-subnet
#输出:Added interface bff6605d-824c-41f9-b744-21d128fc86e1 to router demo-router.
  • 连接路由器到外部网络通过设置为网关
neutron router-gateway-set demo-router ext-net

五.验证(自己成功过2次,失败过3次,已无语)

  • 控制节点ping 203.0.113.100(能ping通)
ping -c 4 203.0.113.100

创建实例

(其实早忘记,一直用web页面创建的,温故一下)
一.环境

  • 加载环境
source admin-openrc.sh
  • 生成并添加一个密钥对
nova keypair-add demo-key

二.创建实例

  • 列出flavors,镜像与网络,安全组
nova flavor-list
nova image-list
neutron net-list
nova secgroup-list
  • 创建实例(DEMO_NET_ID为上面列出的demo-net网络的ID)
nova boot --flavor m1.tiny --image cirros-0.3.4-x86_64 --nic net-id=DEMO_NET_ID --security-group default --key-name demo-key test1
  • 列出实例
nova list
+------------------------------------+---------------+--------+------------+-------------+----------------------+
|ID                                  |Name           | Status | Task State | Power State | Networks             |
+-------------------------------------+--------------+--------+------------+-------------+----------------------+
|02caa2ca-d6e6-46fd-b4a9-e432bcde2e6a|test1          | ACTIVE | -          | Running     | demo-net=192.168.1.3 |
+------------------------------------+---------------+--------+------------+-------------+----------------------+
  • 通过浏览器访问实例(将url加载到浏览器中查看)
nova get-vnc-console test1 novnc
+-------+---------------------------------------------------------------------------------+
| Field | Value                                                                           |
+-------+---------------------------------------------------------------------------------+
| type  | novnc                                                                           |
| url   | http://controller:6080/vnc_auto.html?token=5eeccb47-525c-4918-ac2a-3ad1e9f1f493 |
+-------+---------------------------------------------------------------------------------+
  • 实例的用户名:cirros,密码:cubswin:),没什么问题的话,在控制台中ping百度等外部网络是可以ping通的

    注意:以前搭建的,可以运行,如果上面写的有一些问题,谢谢指出来。

Ubuntu搭建Openstack平台(kilo)(六.实例化网络,创建实例)

标签:

原文地址:http://blog.csdn.net/svmachine/article/details/51337479

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!