参考:
http://docs.openvswitch.org/en/latest/intro/install/distributions/#red-hat
https://github.com/openvswitch/ovs/blob/master/rhel/README.RHEL.rst
http://www.chelsio.com/ovs-kernel-datapath-offload/
http://docs.openvswitch.org/en/latest/intro/install/fedora/#fedora-rhel-7-x-packaging-for-open-vswitch
Red Hat¶
RHEL 发行的 openvswitch
rpm 包支持kernel datapath。
Open vSwitch 的 DPDK 加速可以通过安装 openvswitch-dpdk
实现。
Build Requirements
yum install @'Development Tools' rpm-build yum-utils
获取源码
[root@svr ovs]# ls
ovs-master.zip
[root@svr ovs]# unzip ovs-master.zip
[root@svr ovs]# ls
ovs-master ovs-master.zip
[root@svr ovs]# cd ovs-master/
[root@svr ovs-master]#
然后安装 Open vSwitch specific 编译需要的依赖。依赖内容已经列在SPEC file中,但是首先需要替换VERSION tag这样才能得到正确的SPEC。
如下命令会创建 temporary SPEC file:
[root@svr ovs-master]# sed -e 's/@VERSION@/0.0.1/' rhel/openvswitch-fedora.spec.in > /tmp/ovs.spec
[root@svr ovs-master]# ls /tmp/ovs.spec
/tmp/ovs.spec
安装dependencies
[root@svr ovs-master]# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
[root@svr ovs-master]# yum-builddep /tmp/ovs.spec
完成后,删除 /tmp/ovs.spec
Bootstraping
如果你下载了发布的包,这个过程是不必要的。如果你从git上下载的源码,或者源码快照,需要在最上层目录执行boot.sh来build "configure" script:
执行完毕后,会发现多了些文件,比如 configure
[root@svr ovs-master]# ls
acinclude.m4 configure.ac Documentation m4 NOTICE README.rst tutorial vtep
appveyor.yml CONTRIBUTING.rst include MAINTAINERS.rst ofproto rhel utilities windows
AUTHORS.rst datapath ipsec Makefile.am ovsdb selinux Vagrantfile xenserver
boot.sh datapath-windows lib manpages.mk poc tests Vagrantfile-FreeBSD
build-aux debian LICENSE NEWS python third-party vswitchd
[root@svr ovs-master]#
[root@svr ovs-master]# ./boot.sh
[root@svr ovs-master]# ls
acinclude.m4 config.h.in Documentation Makefile.am poc tutorial xenserver
aclocal.m4 configure include Makefile.in python utilities
appveyor.yml configure.ac ipsec manpages.mk README.rst Vagrantfile
AUTHORS.rst CONTRIBUTING.rst lib NEWS rhel Vagrantfile-FreeBSD
autom4te.cache datapath LICENSE NOTICE selinux vswitchd
boot.sh datapath-windows m4 ofproto tests vtep
build-aux debian MAINTAINERS.rst ovsdb third-party windows
[root@svr ovs-master]#
Configuring
可以不带参数编译,如:
./configure
默认所有的文件是放置于 /usr/local 目录的。 Open vSwitch 默认在/usr/local/etc/openvswitch目录查找 database。
如果你想把文件部署到其他目录,比如 /usr 和 /var 而不是 /usr/local 和 /usr/local/var ,并且希望将/etc/openvswitch设置为默认数据库目录,可以参照如下选项编译:
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
Open vSwitch 通过 .rpm (e.g. via yum install or rpm -ivh) , .deb (e.g. via apt-get install or dpkg -i) 安装就使用如上的配置项。
在啥都不懂的情况下,跟大厂保持一致多好。我就是这么干的。
其他配置项范例请参考:http://docs.openvswitch.org/en/latest/intro/install/general/#general-bootstrapping
实际编译过程:
- 错误一
[root@svr ovs-master]# ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
...
checking for capng_clear in -lcap-ng... yes
checking for Python 3 (version 3.4 or later)... /usr/bin/python3
checking where Python six library is available... configure: error: Missing Python six library.
[root@svr ovs-master]#
应该是要安装Python3
[root@svr ovs-master]# yum list |grep python3 |grep six
python34-six.noarch 1.11.0-3.el7 epel
python36-six.noarch 1.11.0-3.el7 epel
[root@svr ovs-master]# yum install python36-six -y
- 正常进行了
[root@svr ovs-master]# ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
...
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing include/openflow/openflow.h.stamp commands
config.status: executing utilities/bugtool/dummy commands
config.status: executing ipsec/dummy commands
[root@svr ovs-master]#
configure完毕
Building
方式一 直接编译安装
参考:http://docs.openvswitch.org/en/latest/intro/install/general/#general-bootstrapping
make && make install
具体过程跳过,着重方式二
方式二 编译成RPMs,然后rpm / yum 方式安装
User Space RPMs (使用user space 方式)
要编译user-space RPMs,在执行./configure的目录执行如下命令:
make rpm-fedora
这会创建RPMs
openvswitch
,python3-openvswitch
,openvswitch-test
,openvswitch-devel
andopenvswitch-debuginfo
。
要开启DPDK的支持,加上 --with dpdk :
make rpm-fedora RPMBUILD_OPT="--with dpdk --without check"
还可以自动执行 unit tests。需要花几分钟。
make rpm-fedora RPMBUILD_OPT="--with check"
实际编译过程:
[root@svr ovs-master]# make rpm-fedora
...
Wrote: /opt/ovs/ovs-master/rpm/rpmbuild/SRPMS/openvswitch-2.12.90-1.el7.src.rpm
Wrote: /opt/ovs/ovs-master/rpm/rpmbuild/RPMS/x86_64/openvswitch-2.12.90-1.el7.x86_64.rpm
Wrote: /opt/ovs/ovs-master/rpm/rpmbuild/RPMS/noarch/openvswitch-selinux-policy-2.12.90-1.el7.noarch.rpm
Wrote: /opt/ovs/ovs-master/rpm/rpmbuild/RPMS/noarch/python3-openvswitch-2.12.90-1.el7.noarch.rpm
Wrote: /opt/ovs/ovs-master/rpm/rpmbuild/RPMS/noarch/openvswitch-test-2.12.90-1.el7.noarch.rpm
Wrote: /opt/ovs/ovs-master/rpm/rpmbuild/RPMS/x86_64/openvswitch-devel-2.12.90-1.el7.x86_64.rpm
Wrote: /opt/ovs/ovs-master/rpm/rpmbuild/RPMS/x86_64/openvswitch-ipsec-2.12.90-1.el7.x86_64.rpm
Wrote: /opt/ovs/ovs-master/rpm/rpmbuild/RPMS/x86_64/openvswitch-debuginfo-2.12.90-1.el7.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.irypnw
+ umask 022
+ cd /opt/ovs/ovs-master/rpm/rpmbuild/BUILD
+ cd openvswitch-2.12.90
+ rm -rf /opt/ovs/ovs-master/rpm/rpmbuild/BUILDROOT/openvswitch-2.12.90-1.el7.x86_64
+ exit 0
[root@svr ovs-master]#
[root@svr ovs-master]# ls rpm/rpmbuild/RPMS/x86_64/
openvswitch-2.12.90-1.el7.x86_64.rpm openvswitch-devel-2.12.90-1.el7.x86_64.rpm
openvswitch-debuginfo-2.12.90-1.el7.x86_64.rpm openvswitch-ipsec-2.12.90-1.el7.x86_64.rpm
Kernel OVS Tree Datapath RPM (集成内核方式)
要给当前运行的kernel版本编译 Open vSwitch kernel module,执行:
make rpm-fedora-kmod
如果是给其他kernel版本编译,可以指定参数。比如:
$ make rpm-fedora-kmod \
RPMBUILD_OPT='-D "kversion 4.3.4-300.fc23.x86_64"'
Installing
RPM 可以通过 rpm -i
命令安装。安装需要superuser权限。
如果要使用Linux OVS tree datapath module,那么需要先安装openvswitch-kmod
RPM 。如果使用in-tree Linux datapath或user-space datapath,openvswitch-kmod
RPM 就不要安装。 参考 Open vSwitch FAQ 来查看更多 Open vSwitch datapath 选项。
大多数情况下,仅openvswitch
RPM 需要被安装。python3-openvswitch
, openvswitch-test
, openvswitch-devel
, and openvswitch-debuginfo
RPMs 是可选安装以满足特殊需要。
参考RHEL README获得相关使用和配置的文档。
实际安装过程:
[root@svr x86_64]# rpm -qa |grep openvswitch
[root@svr x86_64]#
[root@svr x86_64]# pwd
/opt/ovs/ovs-master/rpm/rpmbuild/RPMS/x86_64
[root@svr x86_64]#
[root@svr x86_64]# ls
openvswitch-2.12.90-1.el7.x86_64.rpm openvswitch-devel-2.12.90-1.el7.x86_64.rpm
openvswitch-debuginfo-2.12.90-1.el7.x86_64.rpm openvswitch-ipsec-2.12.90-1.el7.x86_64.rpm
[root@svr x86_64]#
[root@svr x86_64]# rpm -ivh openvswitch-2.12.90-1.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:openvswitch-2.12.90-1.el7 ################################# [100%]
[root@svr x86_64]#
[root@svr x86_64]# rpm -qa |grep openvswitch
openvswitch-2.12.90-1.el7.x86_64
[root@svr x86_64]#
[root@svr x86_64]# rpm -ql openvswitch-2.12.90-1.el7.x86_64
/etc/bash_completion.d/ovs-appctl-bashcomp.bash
/etc/bash_completion.d/ovs-vsctl-bashcomp.bash
/etc/logrotate.d/openvswitch
/etc/openvswitch
/etc/openvswitch/.conf.db.~lock~
/etc/openvswitch/conf.db
/etc/openvswitch/default.conf
/etc/openvswitch/system-id.conf
/etc/sysconfig/network-scripts/ifdown-ovs
/etc/sysconfig/network-scripts/ifup-ovs
/etc/sysconfig/openvswitch
/run/openvswitch
/run/openvswitch.useropts
/usr/bin/ovs-appctl
/usr/bin/ovs-docker
/usr/bin/ovs-dpctl
/usr/bin/ovs-dpctl-top
/usr/bin/ovs-ofctl
/usr/bin/ovs-pki
/usr/bin/ovs-testcontroller
/usr/bin/ovs-vsctl
/usr/bin/ovsdb-client
/usr/bin/ovsdb-tool
/usr/bin/vtep-ctl
/usr/lib/systemd/system/openvswitch.service
/usr/lib/systemd/system/ovs-delete-transient-ports.service
/usr/lib/systemd/system/ovs-vswitchd.service
/usr/lib/systemd/system/ovsdb-server.service
/usr/lib64/libofproto-2.12.so.0
/usr/lib64/libofproto-2.12.so.0.0.90
/usr/lib64/libopenvswitch-2.12.so.0
/usr/lib64/libopenvswitch-2.12.so.0.0.90
/usr/lib64/libovsdb-2.12.so.0
/usr/lib64/libovsdb-2.12.so.0.0.90
/usr/lib64/libsflow-2.12.so.0
/usr/lib64/libsflow-2.12.so.0.0.90
/usr/lib64/libvtep-2.12.so.0
/usr/lib64/libvtep-2.12.so.0.0.90
/usr/sbin/ovs-bugtool
/usr/sbin/ovs-vswitchd
/usr/sbin/ovsdb-server
/usr/share/doc/openvswitch-2.12.90
/usr/share/doc/openvswitch-2.12.90/NEWS
/usr/share/doc/openvswitch-2.12.90/NOTICE
/usr/share/doc/openvswitch-2.12.90/README.RHEL.rst
/usr/share/doc/openvswitch-2.12.90/README.rst
/usr/share/man/man1/ovsdb-client.1.gz
/usr/share/man/man1/ovsdb-server.1.gz
/usr/share/man/man1/ovsdb-tool.1.gz
/usr/share/man/man5/ovs-vswitchd.conf.db.5.gz
/usr/share/man/man5/ovsdb-server.5.gz
/usr/share/man/man5/ovsdb.5.gz
/usr/share/man/man5/vtep.5.gz
/usr/share/man/man7/ovs-actions.7.gz
/usr/share/man/man7/ovs-fields.7.gz
/usr/share/man/man7/ovsdb-server.7.gz
/usr/share/man/man7/ovsdb.7.gz
/usr/share/man/man8/ovs-appctl.8.gz
/usr/share/man/man8/ovs-bugtool.8.gz
/usr/share/man/man8/ovs-ctl.8.gz
/usr/share/man/man8/ovs-dpctl-top.8.gz
/usr/share/man/man8/ovs-dpctl.8.gz
/usr/share/man/man8/ovs-kmod-ctl.8.gz
/usr/share/man/man8/ovs-ofctl.8.gz
/usr/share/man/man8/ovs-parse-backtrace.8.gz
/usr/share/man/man8/ovs-pki.8.gz
/usr/share/man/man8/ovs-testcontroller.8.gz
/usr/share/man/man8/ovs-vsctl.8.gz
/usr/share/man/man8/ovs-vswitchd.8.gz
/usr/share/man/man8/vtep-ctl.8.gz
/usr/share/openvswitch/bugtool-plugins
/usr/share/openvswitch/bugtool-plugins/kernel-info
/usr/share/openvswitch/bugtool-plugins/kernel-info/openvswitch.xml
/usr/share/openvswitch/bugtool-plugins/network-status
/usr/share/openvswitch/bugtool-plugins/network-status/openvswitch.xml
/usr/share/openvswitch/bugtool-plugins/system-configuration
/usr/share/openvswitch/bugtool-plugins/system-configuration.xml
/usr/share/openvswitch/bugtool-plugins/system-configuration/openvswitch.xml
/usr/share/openvswitch/bugtool-plugins/system-logs
/usr/share/openvswitch/bugtool-plugins/system-logs/openvswitch.xml
/usr/share/openvswitch/scripts/openvswitch.init
/usr/share/openvswitch/scripts/ovs-bugtool-daemons-ver
/usr/share/openvswitch/scripts/ovs-bugtool-fdb-show
/usr/share/openvswitch/scripts/ovs-bugtool-get-dpdk-nic-numa
/usr/share/openvswitch/scripts/ovs-bugtool-ovs-appctl-dpif
/usr/share/openvswitch/scripts/ovs-bugtool-ovs-bridge-datapath-type
/usr/share/openvswitch/scripts/ovs-bugtool-ovs-ofctl-loop-over-bridges
/usr/share/openvswitch/scripts/ovs-bugtool-ovs-vswitchd-threads-affinity
/usr/share/openvswitch/scripts/ovs-bugtool-qos-configs
/usr/share/openvswitch/scripts/ovs-bugtool-tc-class-show
/usr/share/openvswitch/scripts/ovs-check-dead-ifs
/usr/share/openvswitch/scripts/ovs-ctl
/usr/share/openvswitch/scripts/ovs-kmod-ctl
/usr/share/openvswitch/scripts/ovs-lib
/usr/share/openvswitch/scripts/ovs-save
/usr/share/openvswitch/scripts/ovs-systemd-reload
/usr/share/openvswitch/scripts/ovs-vtep
/usr/share/openvswitch/vswitch.ovsschema
/usr/share/openvswitch/vtep.ovsschema
/var/lib/openvswitch
/var/lib/openvswitch/pki
/var/log/openvswitch
[root@svr x86_64]#
测试
[root@svr x86_64]# ovs
ovs-appctl ovsdb-server ovs-dpctl ovs-pki ovs-vswitchd
ovs-bugtool ovsdb-tool ovs-dpctl-top ovs-testcontroller
ovsdb-client ovs-docker ovs-ofctl ovs-vsctl
[root@svr x86_64]# ovs-vsctl -V
ovs-vsctl (Open vSwitch) 2.12.90
DB Schema 8.2.0
[root@svr x86_64]#