OVS + dpdk 安装与实验环境配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了OVS + dpdk 安装与实验环境配置相关的知识,希望对你有一定的参考价值。

 

***DPDK datapath的OVS的安装与实验环境配置

首先肯定是DPDK的安装
      0:安装必要的工具
           make
           gcc
           libssl
           libcap-ng0
           libtool
           autoconf
           python 2.7
           python module six(可用PIP安装)
      1:设置hugepages,host最好有4G以上的内存可用,
         共搞1024个hugepage,每个page 2M,所以光hugepages就占用2G内存
           $  grep Huge /proc/meminfo
            $ echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
                $ mkdir /mnt/huge
            $ mount -t hugetlbfs nodev /mnt/huge
      2:编译DPDK,在DPDK源代码目录中
           设置环境变量
                    DPDK_DIR = "DPDK源代码目录"
                $ export DPDK_TARGET=x86_64-native-linuxapp-gcc
                $ export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET
           编译
                $ make install T=$DPDK_TARGET DESTDIR=install
      3:安装OVS,在OVS源代码目录中
           3.1:配置configure
                $ ./boot.sh
                $ ./configure --with-dpdk=$DPDK_BUILD
           3.2:编译OVS
                $ make
           3.3:安装OVS
                $ make install
           3.4:创建OVSDB schema
                $  mkdir -p /usr/local/etc/openvswitch
                $  ovsdb-tool create /usr/local/etc/openvswitch/conf.db vswitchd/vswitch.ovsschema
           3.5:启动OVSDB
                $  mkdir  -p /usr/local/var/run/openvswitch
                $  ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \
                               --remote=db:Open_vSwitch,Open_vSwitch,manager_options \
                               --private-key=db:Open_vSwitch,SSL,private_key \
                               --certificate=db:Open_vSwitch,SSL,certificate \
                               --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \
                               --pidfile --detach --log-file=/root/log/ovsdb-server.log
      4:挂载兼容的UIO驱动模块
           $ modprobe uio_pci_generic
           或
           $ modprobe vfio-pci
           $ chmod a+x /dev/vfio
           $ chmod 0666 /dev/vfio/*
      5:把网卡绑定到兼容的UIO驱动上
      6:启动vswitchd
           $  export DB_SOCK=/usr/local/var/run/openvswitch/db.sock
           $  ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
           $  ovs-vswitchd unix:$DB_SOCK --pidfile --detach  --log-file=/root/log/ovs-vswitchd.log
      7:创建datapath为netdev类型的bridge
           $  ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev
      8:测试:添加dpdk类型的port,
           $ ovs-vsctl add-port br0 dpdk0 \
                       -- set Interface dpdk0 type=dpdk options:dpdk-devargs=00:09.0
 
 

接下来就是实验环境了
      ------------------------------[host 1]---------------------------------------
      |                                                                           |
      |                       (br-int datapath_type=netdev)                       |
      | [vm0]---------[port:vm0 type=dpdkvhostuser]                               |
      |               [port:vxlan0 type=vxlan remote_ip=10.0.0.2]                 |
      |                                                                           |
      |                                                                           |
      |       (br-phy datapath_type=netdev other_config:hwaddr=aa:aa:aa:aa:aa:aa) |
      |               [port:dpdk0 type=dpdk options:dpdk-devargs= NIC]            |
      |                                                                           |
      |                                                                           |
      ------------------------- [ NIC binding to DPDK]-----------------------------
                                   |
                                   |
                                   |
                                   |
                           [physical switch]
                                   |
                                   |
                                   |
                                   |
      ------------------------- [ NIC binding to DPDK]------------------------------
      |                                                                            |
      |                                                                            |
      |               [port:dpdk1 type=dpdk options:dpdk-devargs= NIC]             |
      |       (br-phy datapath_type=netdev other_config:hwaddr=bb:bb:bb:bb:bb:bb)  |
      |                                                                            |
      |                                                                            |
      |               [port:vxlan1 type=vxlan remote_ip=10.0.0.1]                  |
      |               [port:vm1 type=dpdkvhostuser]------------- [vm1]             |
      |                       (br-int datapath_type=netdev)                        |
      |                                                                            |
      ------------------------------[host 2]----------------------------------------
 
 
 
 
在host1与host2上安装好OVS+DPDK,然后执行如下的动作,两个host上执行的动作相同,以host1为例
      1:创建br-int
           $  ovs-vsctl --may-exist add-br br-int \
                            -- set Bridge br-int datapath_type=netdev \
                            -- br-set-external-id br-int bridge-id br-int \
                            -- set bridge br-int fail-mode=standalone
      2:向br-int中添加dpdkvhostuser型port vm0/vm1
           对于host1,如下:
           $  ovs-vsctl add-port br-int vm0 \
                       -- set Interface vm0 type=dpdkvhostuser
                对于host2,如下:
           $  ovs-vsctl add-port br-int vm1 \
                       -- set Interface vm1 type=dpdkvhostuser
      3:创建虚拟机,以virsh配合XML配置文件的形式创建虚拟机,XML文件如下:
             vm0.xml
      4:在虚拟机内,配置IP
           对于host1上的vm0
           $ ip addr add 192.168.1.1/24
           对于host2上的vm1
           $ ip addr add 192.168.1.2/24
      5:向br-int中添加vxlan tunnel
           对于host1,如下:
           $ ovs-vsctl add-port br-int vxlan0 \
                       -- set interface vxlan0 type=vxlan options:remote_ip=10.0.0.2
           对于host2,如下:
                $ ovs-vsctl add-port br-int vxlan0 \
                       -- set interface vxlan0 type=vxlan options:remote_ip=10.0.0.1
      6:创建br-phy
           对于host1,如下:
            $ ovs-vsctl --may-exist add-br br-phy \
                       -- set Bridge br-phy datapath_type=netdev \
                       -- br-set-external-id br-phy bridge-id br-phy \
                       -- set bridge br-phy fail-mode=standalone \
                          other_config:hwaddr=aa:aa:aa:aa:aa:aa
           对于host2,如下:
            $ ovs-vsctl --may-exist add-br br-phy \
                       -- set Bridge br-phy datapath_type=netdev \
                       -- br-set-external-id br-phy bridge-id br-phy \
                       -- set bridge br-phy fail-mode=standalone \
                          other_config:hwaddr=bb:bb:bb:bb:bb:bb
      7:将物理网卡绑到DPDK兼容的UIO驱动上
           略
      8:将物理网卡捅到br-phy上
           对于host1,如下:
           $ ovs-vsctl add-port br-phy dpdk0 \
                       -- set Interface dpdk0 type=dpdk options:dpdk-devargs=???????
           对于host2,如下:
            $ ovs-vsctl add-port br-phy dpdk1 \
                       -- set Interface dpdk0 type=dpdk options:dpdk-devargs=???????
      9:配置br-phy
           对于host1,如下:
           $ ip addr add 10.0.0.1/24 dev br-phy
           $ ip link set br-phy up
           $ iptables -F
           对于host2,如下:
           $ ip addr add 10.0.0.2/24 dev br-phy
           $ ip link set br-phy up
           $ iptables -F
 
 

参考文档:
      

 

以上是关于OVS + dpdk 安装与实验环境配置的主要内容,如果未能解决你的问题,请参考以下文章

如何配置mininet中的ovs交换机

Dpdk与OpenvSwitch

Neutron 集成 DPDK

原生RedHat OpenStack搭建

原生RedHat OpenStack搭建

原生RedHat OpenStack搭建