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

实例化网络

参考文档: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通的

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

时间: 2024-10-14 22:02:16

Ubuntu搭建Openstack平台(kilo)(六.实例化网络,创建实例)的相关文章

Ubuntu搭建Openstack平台(kilo)(七.Dashboard)

安装Dashboard 参考文档:http://docs.openstack.org/mitaka/install-guide-ubuntu/horizon-install.html - 安装dashboard apt-get install openstack-dashboard 修改配置 vim /etc/openstack-dashboard/local_settings.py OPENSTACK_HOST = "controller" #允许所有的主机访问dashboard A

Ubuntu搭建Openstack平台(kilo)(五.neutron(二)网络节点与计算节点)

参考文档:http://www.aboutyun.com/thread-13116-1-1.html http://www.aboutyun.com/thread-13117-1-1.html 网络节点 一.配置参数 环境配置 vim /etc/sysctl.conf net.ipv4.ip_forward=1 net.ipv4.conf.all.rp_filter=0 net.ipv4.conf.default.rp_filter=0 使配置生效 sysctl -p 二.安装neutron组件

Ubuntu搭建Openstack平台(kilo)(二.keystone)

一.keystone安装 参考文档:http://www.aboutyun.com/thread-13080-1-1.html http://docs.openstack.org/mitaka/install-guide-ubuntu/keystone-install.html 1.创建keystone数据库并授权 mysql -u root -p 创建keystone数据库: CREATE DATABASE keystone; 授权(并设置keystone密码,此密码在后面同步数据库时会用到,

Ubuntu搭建Openstack平台(kilo)(四.nova)

一.nova环境 参考文档:http://www.aboutyun.com/thread-13089-1-1.html http://docs.openstack.org/mitaka/install-guide-ubuntu/nova-controller-install.html 1.创建nova数据库并授权 创建 mysql -u root -p CREATE DATABASE nova; 授权(自己设定密码,连接数据库时用,我的nova) GRANT ALL PRIVILEGES ON

Ubuntu搭建Openstack平台(kilo)(一.整体环境)

一.环境 OS:Ubuntu 14.04 网卡要求:每台主机最少两块网卡,网络节点最少三块 eth0作为管理网卡,eth1作为数据网卡,eth2作为外部网卡 网络类型如图: 管理网络(Management Network): 10.0.0.0/24 数据网络(Data Network): 10.0.0.1.0/24 外部网络(External Network) 203.0.113.0/24 API Network 125.220.254.** 二.网络配置(设置后使用/etc/init.d/ne

Ubuntu搭建Openstack平台(kilo)(三.glance)

一.Glance环境 参考文档:http://www.aboutyun.com/thread-13080-1-1.html http://docs.openstack.org/mitaka/install-guide-ubuntu/glance-install.html 1.创建glance的数据库并授权 创建 mysql -u root -p CREATE DATABASE glance; 授权(自己设定密码,连接数据库时用,我的glance) GRANT ALL PRIVILEGES ON

Ubuntu搭建Openstack平台(kilo)(五.neutron(一)控制节点)

一.neutron环境 参考文档:http://www.aboutyun.com/thread-13108-1-1.html http://docs.openstack.org/mitaka/install-guide-ubuntu/neutron-controller-install.html 1.创建neutron数据库并授权 创建 mysql -u root -p CREATE DATABASE neutron; 授权 GRANT ALL PRIVILEGES ON neutron.* T

Ubuntu搭建trac平台步骤

Ubuntu搭建trac平台步骤: # apt-get install apache2 # apt-get install libapache2-mod-python # apt-get install libapache2-mod-authnz-external # a2enmod authnz_ldap # apt-get install mysql-server-5.5  (设置root密码,如:123456) # apt-get install python-mysqldb # apt-

OpenStack(Kilo版本)网络服务neutron的安装部署

Openstack网络主要是和OpenStack计算交互,提供网络连接到它的实例.一.OpenStack网络服务包含的组件 图1.1. OpenStack Nova组件 二.OpenStack网络节点基本环节的搭建1.配置主机名和网络信息1.1配置主机名 [email protected]:~# vim /etc/hostname network 1.2 配置IP地址 [email protected]:~# vim  /etc/network/interfaces auto eth0 ifac