分享

openstack【juno】入门高级篇2:openstack的Neutron中SDN介绍

pig2 发表于 2015-6-8 03:26:01 [显示全部楼层] 只看大图 回帖奖励 阅读模式 关闭右栏 1 21874

问题导读

1.如何查看namespace?
2.如何判断VEH Pair?
3.Open vSwitch中计算节点和网络节点、网桥之间是如何连接的?




下面是SDN中一些概念
  • namespace:命名空间
  • TAP:虚拟网络设备,可以是网卡
  • VEH Pair:虚拟网络对,可以理解为虚拟网线
  • Linux Bridge:Linux网桥
  • Open vSwitch:虚拟交换机


namespace

namespace的作用主要是命名更加的规范

查看命名空间
[mw_shl_code=bash,true] ip netns[/mw_shl_code]
namespace.png





每产生一个openstack实例,就会产生四个虚拟网络设备
sige.png


TAP

什么是tap设备?TAP是操作系统内核中的虚拟网络设备



2.png


TAP设备在Neutron中出现了两个地方:

一个是实例TAP
一个是路由TAP

这两个TAP分别是什么?
如何在实例中查找tap设备

首先进入/etc/libvirt/qemu
[mw_shl_code=bash,true] cat instance-0000001a.xml[/mw_shl_code]

显示内容:[mw_shl_code=xml,true]<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh edit instance-0000001a
or other application using the libvirt API.
-->

<domain type='qemu'>
  <name>instance-0000001a</name>
  <uuid>d866d77c-5157-47ab-af3c-3a80933ce8c6</uuid>
  <metadata>
    <nova:instance xmlns:nova="http://openstack.org/xmlns/libvirt/nova/1.0">
      <nova:package version="2014.2.2"/>
      <nova:name>demo-instance1</nova:name>
      <nova:creationTime>2015-06-04 08:43:03</nova:creationTime>
      <nova:flavor name="m1.tiny">
        <nova:memory>512</nova:memory>
        <nova:disk>1</nova:disk>
        <nova:swap>0</nova:swap>
        <nova:ephemeral>0</nova:ephemeral>
        <nova:vcpus>1</nova:vcpus>
      </nova:flavor>
      <nova:owner>
        <nova:user uuid="73339fb8f0644cfe904afc7d70793fe1">demo</nova:user>
        <nova:project uuid="255f0f273f1048668c4e91550dd3c16e">demo</nova:project>
      </nova:owner>
      <nova:root type="image" uuid="daa57d75-319a-4542-9435-95df8729b114"/>
    </nova:instance>
  </metadata>
  <memory unit='KiB'>524288</memory>
  <currentMemory unit='KiB'>524288</currentMemory>
  <vcpu placement='static' cpuset='0'>1</vcpu>
  <sysinfo type='smbios'>
    <system>
      <entry name='manufacturer'>OpenStack Foundation</entry>
      <entry name='product'>OpenStack Nova</entry>
      <entry name='version'>2014.2.2</entry>
      <entry name='serial'>564ddce5-22e5-e31f-3d17-38f8e2a80daa</entry>
      <entry name='uuid'>d866d77c-5157-47ab-af3c-3a80933ce8c6</entry>
    </system>
  </sysinfo>
  <os>
    <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
    <boot dev='hd'/>
    <smbios mode='sysinfo'/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode='host-model'>
    <model fallback='allow'/>
    <topology sockets='1' cores='1' threads='1'/>
  </cpu>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none'/>
      <source file='/var/lib/nova/instances/d866d77c-5157-47ab-af3c-3a80933ce8c6/disk'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </disk>
    <controller type='usb' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'/>
    <interface type='bridge'>
      <mac address='fa:16:3e:e1:8f:cf'/>
      <source bridge='qbr16b55972-68'/>
      <target dev='tap16b55972-68'/>
      <model type='virtio'/>
      <driver name='qemu'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='file'>
      <source path='/var/lib/nova/instances/d866d77c-5157-47ab-af3c-3a80933ce8c6/console.log'/>
      <target port='0'/>
    </serial>
    <serial type='pty'>
      <target port='1'/>
    </serial>
    <console type='file'>
      <source path='/var/lib/nova/instances/d866d77c-5157-47ab-af3c-3a80933ce8c6/console.log'/>
      <target type='serial' port='0'/>
    </console>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='en-us'>
      <listen type='address' address='0.0.0.0'/>
    </graphics>
    <video>
      <model type='cirrus' vram='9216' heads='1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
      <stats period='10'/>
    </memballoon>
  </devices>
</domain>[/mw_shl_code]

其中我们比较关心的内容:
[mw_shl_code=xml,true]<interface type='bridge'>
<mac address='fa:16:3e:e1:8f:cf'/>
<source bridge='qbr16b55972-68'/>
<target dev='tap16b55972-68'/>
<model type='virtio'/>
<driver name='qemu'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>[/mw_shl_code]

qbr16b55972-68
tap16b55972-68


我们看到上面mac地址为:
[mw_shl_code=bash,true]fa:16:3e:e1:8f:cf[/mw_shl_code]

然后进入虚拟机:
ip a 查看mac地址:
mac.png


我们看到mac地址是一致的,那么如何找到tap设备。我们进入计算节点

[mw_shl_code=bash,true]ip a[/mw_shl_code]

tap.png


这样我们就找到了实例的tap设备


1.png

——————————————————————————————

在dhcp中也有tap设备

这时候,我们通过 ip netns


ipnetns.png


然后:

[mw_shl_code=bash,true]ip netns exec qdhcp-c5820bc3-9612-407b-8f67-eaf167192c7f ip a[/mw_shl_code]

dhcpserver.png


这个其实DHCP server


VEH Pair

veth pair.png

将两个网卡连接起来,可以理解为虚拟网线(连接虚拟网桥、交换机)

我们来看看:
在实例的tap连接qbr

qvb1.png


[mw_shl_code=bash,true]qvb16b55972-68[/mw_shl_code]

通过
[mw_shl_code=bash,true] brctl show[/mw_shl_code]

                                                                     
bridge name bridge id STP enabled interfaces
qbr16b55972-68 8000.be620ce0a3f9 no  qvb16b55972-68
tap16b55972-68

brctl.png
                                                           
                                                                                                                        
通过[mw_shl_code=bash,true] ovs-vsctl show[/mw_shl_code]

1.png


我们看到上面红字部分
[mw_shl_code=bash,true]qvo16b55972-68[/mw_shl_code]
如何判断是否是虚拟网络对,通过ethtool来查看

[mw_shl_code=bash,true]ethtool -S qvo16b55972-68[/mw_shl_code]

[mw_shl_code=bash,true]NIC statistics:
     peer_ifindex: 11[/mw_shl_code]

[mw_shl_code=bash,true]ethtool -S qvb16b55972-68[/mw_shl_code]

[mw_shl_code=bash,true]NIC statistics:
     peer_ifindex: 10[/mw_shl_code]

xuhao.png


这样我们看到他们的序号是连续的


Linux Bridge

为什么

上图
qbr16b55972-68
                                                                  
bridge namebridge idSTP enabledinterfaces
qbr16b55972-68 8000.be620ce0a3f9no  qvb16b55972-68
tap16b55972-68



Open Vswitch
计算节点

[mw_shl_code=bash,true]9c0f2e03-f10c-4928-ac6f-8fbeaa171d81
    Bridge br-int
        fail_mode: secure
        Port patch-tun
            Interface patch-tun
                type: patch
                options: {peer=patch-int}
        Port "qvo16b55972-68"
            tag: 1
            Interface "qvo16b55972-68"
        Port br-int
            Interface br-int
                type: internal
        Port "tapfaf7f822-04"
            Interface "tapfaf7f822-04"
                type: internal
    Bridge br-tun
        Port patch-int
            Interface patch-int
                type: patch
                options: {peer=patch-tun}
        Port br-tun
            Interface br-tun
                type: internal
        Port "gre-0a000115"
            Interface "gre-0a000115"
                type: gre
                options: {df_default="true", in_key=flow, local_ip="10.0.1.31", out_key=flow, remote_ip="10.0.1.21"}
    ovs_version: "2.0.2"[/mw_shl_code]

jisuan.png


网络节点

[mw_shl_code=bash,true]689c0ac3-e282-4638-822c-9444333396e5
    Bridge br-int
        fail_mode: secure
        Port int-br-ex
            Interface int-br-ex
                type: patch
                options: {peer=phy-br-ex}
        Port br-int
            Interface br-int
                type: internal
        Port patch-tun
            Interface patch-tun
                type: patch
                options: {peer=patch-int}
        Port "qr-bd91f930-92"
            tag: 1
            Interface "qr-bd91f930-92"
                type: internal
        Port "tap19c5765e-d9"
            tag: 1
            Interface "tap19c5765e-d9"
                type: internal
    Bridge br-ex
        Port br-ex
            Interface br-ex
                type: internal
        Port "qg-a5a35520-41"
            Interface "qg-a5a35520-41"
                type: internal
        Port "eth2"
            Interface "eth2"
        Port phy-br-ex
            Interface phy-br-ex
                type: patch
                options: {peer=int-br-ex}
    Bridge br-tun
        Port br-tun
            Interface br-tun
                type: internal
        Port "gre-0a00011f"
            Interface "gre-0a00011f"
                type: gre
                options: {df_default="true", in_key=flow, local_ip="10.0.1.21", out_key=flow, remote_ip="10.0.1.31"}
        Port patch-int
            Interface patch-int
                type: patch
                options: {peer=patch-tun}
    ovs_version: "2.0.2"[/mw_shl_code]

network.png




相关内容:
openstack【juno】入门高级篇:为何你的实例ping不通外网【详述】

openstack【juno】入门高级篇3:openstack的Neutron中虚拟网络设备介绍

已有(1)人评论

跳转到指定楼层
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条