在前面的文章中,已经完成了devstack的安装。下面,我会介绍如何使用neutron

  • 首先创建两个neutron net, vmnet1 和vmnet2
stack@ubuntu:~/devstack$ source openrc admin admin
stack@ubuntu:~/devstack$ neutron net-list
+--------------------------------------+---------+-------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+---------+-------------------------------------------------------+
| 5365b56f--40d4-b065-a9d50126b55b | private | fc3a839e-412c-4f0d-b1ed-87be1a7b0bf8 192.168.106.0/ |
| a101e11f-7bbe-4f4d-a52e-5bb312d5f8b9 | public | 570e8b64--41f7--12d9bc54f195 172.24.4.0/ |
+--------------------------------------+---------+-------------------------------------------------------+
stack@ubuntu:~/devstack$ neutron net-create vmnet1
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| id | 54028daa--4fc7-9f97-d400dc801e97 |
| name | vmnet1 |
| provider:network_type | vlan |
| provider:physical_network | physnet1 |
| provider:segmentation_id | |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | dcf6685a3e304e4c92af08bca762aa33 |
+---------------------------+--------------------------------------+
stack@ubuntu:~/devstack$ neutron net-create vmnet2
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| id | 7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9 |
| name | vmnet2 |
| provider:network_type | vlan |
| provider:physical_network | physnet1 |
| provider:segmentation_id | |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | dcf6685a3e304e4c92af08bca762aa33 |
+---------------------------+--------------------------------------+
stack@ubuntu:~/devstack$ neutron net-list
+--------------------------------------+---------+-------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+---------+-------------------------------------------------------+
| 5365b56f--40d4-b065-a9d50126b55b | private | fc3a839e-412c-4f0d-b1ed-87be1a7b0bf8 192.168.106.0/ |
| a101e11f-7bbe-4f4d-a52e-5bb312d5f8b9 | public | 570e8b64--41f7--12d9bc54f195 172.24.4.0/ |
| 54028daa--4fc7-9f97-d400dc801e97 | vmnet1 | |
| 7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9 | vmnet2 | |
+--------------------------------------+---------+-------------------------------------------------------+
  • 现在两个网络就创建好了,但现在其实这是两个独立的网络,是不互通的,接下来创建router: router-vmnet1-vmnet2
stack@ubuntu:~/devstack$ neutron router-create router-vmnet1-vmnet2
Created a new router:
+-----------------------+--------------------------------------+
| Field | Value |
+-----------------------+--------------------------------------+
| admin_state_up | True |
| distributed | False |
| external_gateway_info | |
| ha | False |
| id | 4bef86df-3b13-4b23-80f0-3a2bd8d0c746 |
| name | router-vmnet1-vmnet2 |
| routes | |
| status | ACTIVE |
| tenant_id | dcf6685a3e304e4c92af08bca762aa33 |
+-----------------------+--------------------------------------+
  • 在vmnet1和vmnet2中,分别创建subnet
stack@ubuntu:~/devstack$ neutron subnet-create 54028daa--4fc7-9f97-d400dc801e97 30.30.30.0/
Created a new subnet:
+-------------------+------------------------------------------------+
| Field | Value |
+-------------------+------------------------------------------------+
| allocation_pools | {"start": "30.30.30.2", "end": "30.30.30.254"} |
| cidr | 30.30.30.0/ |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 30.30.30.1 |
| host_routes | |
| id | c0be451f-91a1-4f9f-a29b-13adea79798e |
| ip_version | |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | |
| network_id | 54028daa--4fc7-9f97-d400dc801e97 |
| tenant_id | dcf6685a3e304e4c92af08bca762aa33 |
+-------------------+------------------------------------------------+
stack@ubuntu:~/devstack$ neutron subnet-create 7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9 40.40.40.0/
Created a new subnet:
+-------------------+------------------------------------------------+
| Field | Value |
+-------------------+------------------------------------------------+
| allocation_pools | {"start": "40.40.40.2", "end": "40.40.40.254"} |
| cidr | 40.40.40.0/ |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 40.40.40.1 |
| host_routes | |
| id | 0b9c9ad8--4c96-afda-ecb7e53dc519 |
| ip_version | |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | |
| network_id | 7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9 |
| tenant_id | dcf6685a3e304e4c92af08bca762aa33 |
+-------------------+------------------------------------------------+
  • 接下来,给router加入interface,分别连接到vmnet1的subnet和vmnet2的subnet
stack@ubuntu:~/devstack$ neutron router-interface-add 4bef86df-3b13-4b23-80f0-3a2bd8d0c746 subnet=c0be451f-91a1-4f9f-a29b-13adea79798e
Added interface 8fc6f138-150c-47de-8c88-fa924ce2302d to router 4bef86df-3b13-4b23-80f0-3a2bd8d0c746.
stack@ubuntu:~/devstack$ neutron router-interface-add 4bef86df-3b13-4b23-80f0-3a2bd8d0c746 subnet=0b9c9ad8--4c96-afda-ecb7e53dc519
Added interface 4e830e98-e24b-45dd-bc6e-338e47b31b1b to router 4bef86df-3b13-4b23-80f0-3a2bd8d0c746.
  • 然后,我们看,Linux 网络配置上的变化,首先是network namespace, 你会发现名为qrouter-4bef86df-3b13-4b23-80f0-3a2bd8d0c746 的Linux Namespace创建成功
stack@ubuntu:~/devstack$ sudo ip netns exec qrouter-4bef86df-3b13-4b23-80f0-3a2bd8d0c746  ip addr
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN group default
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
valid_lft forever preferred_lft forever
inet6 ::/ scope host
valid_lft forever preferred_lft forever
: qr-4e830e98-e2: <BROADCAST,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN group default
link/ether fa::3e:8c:4d:c7 brd ff:ff:ff:ff:ff:ff
inet 40.40.40.1/ brd 40.40.40.255 scope global qr-4e830e98-e2
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe8c:4dc7/ scope link
valid_lft forever preferred_lft forever
: qr-8fc6f138-: <BROADCAST,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN group default
link/ether fa::3e::b5: brd ff:ff:ff:ff:ff:ff
inet 30.30.30.1/ brd 30.30.30.255 scope global qr-8fc6f138-
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe67:b514/ scope link
valid_lft forever preferred_lft forever
  • 上图的qr-4e830e98-e2和qr-8fc6f138-15,可以理解为vmnet1和vmnet2的gateway, 同时它们也都连接在ovs的br-int bridge上,如下:
stack@ubuntu:~/devstack$ sudo ovs-vsctl show
.......
Bridge br-int
fail_mode: secure
Port patch-tun
Interface patch-tun
type: patch
options: {peer=patch-int}
Port "qr-4e830e98-e2"
tag:
Interface "qr-4e830e98-e2"
type: internal
Port br-int
Interface br-int
type: internal
Port "int-br-eth1"
Interface "int-br-eth1"
type: patch
options: {peer="phy-br-eth1"}
Port "qr-8fc6f138-15"
tag:
Interface "qr-8fc6f138-15"
type: internal
Port "qr-a6466103-17"
tag:
Interface "qr-a6466103-17"
type: internal

从上面的输出可以看出"qr-4e830e98-e2" is tagged with 3, "qr-8fc6f138-15"is tagged with 2

  • 接下来,我要在vmnet1和vmnet2上分别创建一个virtual machine instance,看看openstack neutron中发生了什么!
#注意,这个一定要先增加这个,不然,后面的vm启动无法得到IP, 参见我的异常处理部分
stack@ubuntu:~/devstack$ nova secgroup-add-rule default icmp - - 0.0.0.0/
stack@ubuntu:~/devstack$ nova secgroup-add-rule default tcp 0.0.0.0/0
#创建两个vm
stack@ubuntu:~/devstack$ nova boot --image 54bdfba1-27f7-4fae-99f1-cfbbca78c9bd --flavor m1.tiny --nic net-id=54028daa-9158-4fc7-9f97-d400dc801e97 vm1
stack@ubuntu:~/devstack$ nova boot --image 54bdfba1-27f7-4fae-99f1-cfbbca78c9bd --flavor m1.tiny --nic net-id=7b0394ec-34c0-48d3-a17d-82ef9bbc2cd9 vm2
#查看vm是否ready
stack@ubuntu:~/devstack$ nova list
+--------------------------------------+------+--------+------------+-------------+-------------------+
| ID                                   | Name | Status | Task State | Power State | Networks          |
+--------------------------------------+------+--------+------------+-------------+-------------------+
| b22e706b-a1aa-4f73-9bd5-5f70bbf7e299 | vm1  | ACTIVE | -          | Running     | vmnet1=30.30.30.2 |
| 1f4fad7d-8eb9-4011-b196-337dea3d7d66 | vm2  | ACTIVE | -          | Running     | vmnet2=40.40.40.2 |
+--------------------------------------+------+--------+------------+-------------+-------------------+

现在这两个ip 30.30.30.2 和40.40.40.2是无法直接ping同的,因为是被Linux Namespace隔离的

stack@ubuntu:~/devstack$ ping 30.30.30.2
PING 30.30.30.2 (30.30.30.2) () bytes of data.
^C
--- 30.30.30.2 ping statistics ---
packets transmitted, received, % packet loss, time 3000ms stack@ubuntu:~/devstack$ ping 40.40.40.2
PING 40.40.40.2 (40.40.40.2) () bytes of data.
^C
--- 40.40.40.2 ping statistics ---
packets transmitted, received, % packet loss, time 3000ms
  • 你可以这样在主机上ssh到vm上,这里我们以ssh到vm1为例:首先确定vm1所在的network为vmnet1, vmnet1对应的namespace为qdhcp-54028daa-9158-4fc7-9f97-d400dc801e97,然后
ip netns exec qqdhcp-54028daa-9158-4fc7-9f97-d400dc801e97 ssh cirros@30.30.30.2

密码为   cubswin:)

这样一个基于neutron network的devstack环境就搭建好了,大家有兴趣的话,可以一起探讨关于neutron跟多的东西,推荐大家几篇oracle上的文章,讲的深入浅出的,很不错

https://blogs.oracle.com/ronen/entry/diving_into_openstack_network_architecture

https://blogs.oracle.com/ronen/entry/diving_into_openstack_network_architecture1

https://blogs.oracle.com/ronen/entry/diving_into_openstack_network_architecture2

https://blogs.oracle.com/ronen/entry/diving_into_openstack_network_architecture3

https://blogs.oracle.com/ronen/entry/running_openstack_icehouse_with_zfs

OpenStack/devstack with Neutron on Ubuntu 14 (2)的更多相关文章

  1. OpenStack/devstack with Neutron on Ubuntu 14 (1)

    安装前,推荐安装一个全新的Ubuntu Server14.04,如果使用之前的ubuntu, 中间可能遇到各种的python包依赖,以及软件版本不对应的问题 环境准备,新建stack用户,给予sudo ...

  2. ubuntu 14.04安装 DevStack的脚本配置文件——localrc

    本文ubuntu 14.04安装 DevStack的脚本配置文件——localrc,本文件名已经逐渐被取代,但是出于后向兼容性,使用该文件仍然可以为stack.sh安装脚本指定安装DevStack时的 ...

  3. Ubuntu 14.04 安装 DevStack与遇到的的问题记录

    本文总结Ubuntu 14.04下部署DevStack的过程以及一些可能遇到的问题. 一.安装 以下的操作最好在普通用户下进行,至少在git clone devstack的时候使用普通用户,这样可以避 ...

  4. Ubuntu 14.04 LTS 安装 Juno 版 OpenStack Keystone

    本文介绍如何在Ubuntu 14.04 LTS 上安装Juno版的Keystone, 我们采用的是手动安装的方式, 同时仅针对OpenStack的身份与访问管理系统Keystone. 事实上OpenS ...

  5. 使用Devstack部署neutron网络节点

    本文为minxihou的翻译文章,转载请注明出处Bob Hou: http://blog.csdn.net/minxihou JmilkFan:minxihou的技术博文方向是 算法&Open ...

  6. Ubuntu 14.04 正式版 12.4

    安装Ubuntu 14.04后要做的5件事情 4月17日,开源免费系统Ubuntu官方正式宣布发布Ubuntu 14.04 LTS(代号Trusty Tahr)正式版.官方声称该版本主打云计算,在云平 ...

  7. OpenStack 网络服务 Neutron 私有网络构建(十九)

    本章内容基于之前提供者网络构建的基础上进行改动,之前文章参考如下: Openstack 网络服务 Neutron介绍和控制节点部署 (九) Openstack 网络服务 Neutron计算节点部署(十 ...

  8. Openstack 网络服务 Neutron介绍和控制节点部署 (九)

    Neutron介绍 neutron是openstack重要组件之一,在以前是时候没有neutron项目. 早期的时候是没有neutron,早期所使用的网络的nova-network,经过版本改变才有个 ...

  9. Ubuntu 14.04中Elasticsearch集群配置

    Ubuntu 14.04中Elasticsearch集群配置 前言:本文可用于elasticsearch集群搭建参考.细分为elasticsearch.yml配置和系统配置 达到的目的:各台机器配置成 ...

随机推荐

  1. SuperSocket入门(五)-常用协议实现模版及FixedSizeReceiveFilter示例

             Socket里面的协议解析是Socket通讯程序设计中最复杂的地方,如果你的应用层协议设计或实现不佳,Socket通讯中常见的粘包,分包就难以避免.SuperSocket内置了命令行 ...

  2. iOS页面间传值的五种方式总结(Delegate/NSNotification/Block/NSUserDefault/单例)

    iOS页面间传值的方式(Delegate/NSNotification/Block/NSUserDefault/单例) iOS页面间传值的方式(NSUserDefault/Delegate/NSNot ...

  3. ssh配置文件及问题解决

    一 ssh的配置文鉴模板 Host AAA User gitolite3 HostName IP地址 IdentityFile ~/.ssh/key 二 下载代码的方法 1 ssh git2 git ...

  4. css3 3d变换和动画——回顾

    1.transform-style 属性指定嵌套原始是怎样在三维空间中呈现. 语法:transform-style: flat | preserve-3d flat 表示所有子元素在2D平面呈现. p ...

  5. CSS3知识点整理(三)----变形与动画

    一.CSS3中的变形 1)旋转 rotate() rotate()函数通过指定的角度参数使元素相对原点进行旋转. 它主要在二维空间内进行操作,设置一个角度值,用来指定旋转的幅度. 如果这个值为正值,元 ...

  6. 关于js 构造 onclick 方法中传递Guid参数问题

    转义字符单双引号用法:\'  与 \" 例如: $.getJSON("data.json", function(data, status, xhr) { $(" ...

  7. Node - EJS模板应用(node+express+ejs)

    准备工作: 工具:Webstorm 1. 新建一个文件夹为blogs(随意). 一个js文件app.js. 一个文件夹views,文件夹内一个index.ejs文件,文件夹asstes内style.c ...

  8. JUnit与JMock学习

    JUnit与JMock学习 测试驱动编程和持续集成部署应该说是现在软件开发者的必备武器,不过跟其他很多好东西一样,在我们公司的推广总要慢上一拍,毕竟老板看的是你能够把功能实现好让客户满意,所以能不折腾 ...

  9. 认识ionic2

    1. Ionic 2 介绍 Ionic 2专注于以标准的HTML.CSS和JavaScript来构建移动站点,并可以通过Cordova打包成移动 App,只需编写一次代码,就可以分别部署到iOS.An ...

  10. android学习7——canvas.concat(Matrix matrix)作用

    canvas.concat的作用可以理解成对matrix的变换应用到canvas上的所有对象. 看下面的代码. public class ConcatMatrixActivity extends Ac ...