本文主要介绍如何使用 DPDK datapath 编译并安装 Open vSwitch,以及在 OVS-DPDK 基础上,进行 6wind 包转发性能测试实验。
使用了 DPDK 库的 OVS 运行在用户空间,可以直接将用户态的数据,不经过内核直接转发到网卡,从而实现加速目的。
一、OVS + DPDK 编译部署
在部署过程中,各个组件版本之间有一些依赖,版本不对很有可能会出现安装失败或者虚拟机无法开机,推荐使用以下版本组合。
[root@pod23-clu02-h005 ~]# ovs-vswitchd --version
ovs-vswitchd (Open vSwitch) 2.9.0
DPDK 17.11.3
[root@pod23-clu02-h005 ~]# libvirtd --version
libvirtd (libvirt) 4.0.0
- 下载 DPDK
# wget http://fast.dpdk.org/rel/dpdk-17.11.3.tar.xz
2. 添加相关环境变量并安装依赖组件
# cat /root/.bashrc
...
export DPDK_DIR=<DPDK_DIR> # dpdk-17.11.3安装目录
export DPDK_TARGET=x86_64-native-linuxapp-gcc
export DPDK_BUILD=$DPDK_DIR/$DPDK_TARGET
export LD_LIBRARY_PATH=$DPDK_DIR/x86_64-native-linuxapp-gcc/lib
export PATH=$PATH:/usr/local/ovs/share/openvswitch/scripts
export DB_SOCK=/usr/local/ovs/var/run/openvswitch/db.sock
...
# yum install autoconf automake libtool numactl numactl-devel -y
3. 编译 DPDK
# cd dpdk-17.11.3
# make install T=$DPDK_TARGET DESTDIR=install
4. 下载 ovs,我使用的版本是2.9.0
# git clone https://github.com/openvswitch/ovs.git
# git checkout -b v2.9.0 v2.9.0
5. 编译 ovs-dpdk
# cd ovs
# ./boot.sh
# ./configure --prefix=/usr/local/ovs --with-dpdk=$DPDK_BUILD
# make && make install
6. 配置 hugepages
# cat /etc/sysctl.d/hugepages.conf
# vm.nr_hugepages=8192
# sysctl -p /etc/sysctl.d/hugepages.conf
# mount -t hugetlbfs none /dev/hugepages
9. 加载驱动模块,配置 dpdk 网卡
# modprobe vfio-pci
# lsmod | grep vfio
# /usr/bin/chmod a+x /dev/vfio
# /usr/bin/chmod 0666 /dev/vfio/*
# dpdk-devbind.py -b vfio-pci ens10f1
10. 启动 ovsdb-server
# mkdir -p /usr/local/ovs/var/run/openvswitch
# /usr/local/ovs/bin/ovsdb-tool create /usr/local/ovs/etc/openvswitch/conf.db /usr/local/ovs/share/openvswitch/vswitch.ovsschema
# /usr/local/ovs/sbin/ovsdb-server --remote=punix:/usr/local/ovs/var/run/openvswitch/db.sock --remote=db:Open_vSwitch,Open_vSwitch,manager_options --pidfile --detach --monitor
# 增加 dpdk 相关配置参数
# ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
# ovs-vsctl --no-wait set Open_vSwitch . other_config:vhost-iommu-support=true
# ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-socket-mem="1024,1024"
11. ovs 进程核绑定,提升性能
查看cpu_layout:
[root@pod23-clu02-h005 ~]# ./dpdk-stable-17.11.3/usertools/cpu_layout.py
======================&#