本博客主要介绍如何在CentOS6.5
上编译OpenvSwitch
RPM
包。
基于CentOS 7编译 ovs2.12.x/2.13.x
依赖处理:
yum -y install epel-release \
&& yum -y install @'Development Tools' rpm-build yum-utils rpmdevtools \
sudo mock patch make vim install openssl openssl-devel python3 python3-devel python3-sphinx \
desktop-file-utils groff graphviz checkpolicy selinux-policy-devel \
libcap-ng-devel libpcap-devel numactl-devel dpdk-devel \
unbound unbound-devel python3-sphinx libibverbs libmnl-devel \
python-sphinx python-twisted-core python-zope-interface python-six \
&& cd /usr/lib64 \
&& ln -s ./libmlx4.so.1.0.22.4 libmlx4.so \
&& ln -s ./libmlx5.so.1.8.22.4 libmlx5.so \
&& cd /usr/lib64 \
&& ln -s ./libibverbs.so.1.5.22.4 libibverbs.so
tar xf openvswitch-2.12.3.tar.gz
cd openvswitch-2.12.3
./boot.sh
./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
make rpm-fedora RPMBUILD_OPT="--with dpdk --without check"
安装依赖包
yum install -y rpmdevtools rpm-build kernel-headers kernel-devel gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel automake autoconf redhat-rpm-config libtool git
下载ovs
下载的版本为:openvswitch-2.3.2.tar.gz
wget http://openvswitch.org/releases/openvswitch-2.3.2.tar.gz -O openvswitch-2.3.2.tar.gz
编译
关于 spec
文件,可以参考:https://github.com/rdo-common/openvswitch,也可以采用 openvswitch tar包中的文件。
[root@xiexianbin_cn ~]# rpmdev-setuptree
[root@xiexianbin_cn ~]# cp /root/openvswitch-2.3.2.tar.gz /root/rpmbuild/SOURCES/
[root@xiexianbin_cn ~]# tar -zxf openvswitch-2.3.2.tar.gz
[root@xiexianbin_cn ~]# cd openvswitch-2.3.2
[root@xiexianbin_cn ~]# rpmbuild -bb --without check rhel/openvswitch.spec
[root@xiexianbin_cn openvswitch-2.3.2]# rpmbuild -bb --without check rhel/openvswitch-kmod-rhel6.spec
[root@xiexianbin_cn openvswitch-2.3.2]# cp rhel/openvswitch-kmod.files /root/rpmbuild/SOURCES/
[root@xiexianbin_cn openvswitch-2.3.2]# rpmbuild -bb -D "kversion 2.6.32-431.23.3.el6.x86_64" -D "kflavors default" rhel/openvswitch-kmod-rhel6.spec
注释:
kversion
内核版本可通过uname -r
编译结果:
[root@xiexianbin_cn x86_64]# cd /root/rpmbuild/RPMS/x86_64
[root@xiexianbin_cn x86_64]# ll
total 11460
-rw-r--r-- 1 root root 1231464 Oct 25 18:33 kmod-openvswitch-2.3.2-1.el6.x86_64.rpm
-rw-r--r-- 1 root root 2644260 Oct 25 18:13 openvswitch-2.3.2-1.x86_64.rpm
-rw-r--r-- 1 root root 7853848 Oct 25 18:13 openvswitch-debuginfo-2.3.2-1.x86_64.rpm
[root@xiexianbin_cn x86_64]#
下载地址: http://pan.baidu.com/s/1pJKjmzh
安装
rpm -ivh openvswitch-kmod-2.3.1-1.el6.x86_64.rpm openvswitch-2.3.1-1.x86_64.rpm kmod-openvswitch-2.3.1-1.el6.x86_64.rpm
进程 & 目录
[root@xiexianbin_cn ~]# ps -ef|grep openvswitch
root 39034 39033 0 04:34 ? 00:00:00 ovsdb-server /etc/openvswitch/conf.db -vconsole:emer -vsyslog:err -vfile:info --remote=punix:/var/run/openvswitch/db.sock --private-key=db:Open_vSwitch,SSL,private_key --certificate=db:Open_vSwitch,SSL,certificate --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert --no-chdir --log-file=/var/log/openvswitch/ovsdb-server.log --pidfile=/var/run/openvswitch/ovsdb-server.pid --detach --monitor
root 39056 39055 0 04:34 ? 00:00:00 ovs-vswitchd unix:/var/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --mlockall --no-chdir --log-file=/var/log/openvswitch/ovs-vswitchd.log --pidfile=/var/run/openvswitch/ovs-vswitchd.pid --detach --monitor
$ lsmod | grep openvswitch
openvswitch 70743 0
vxlan 37584 1 openvswitch
gre 13808 1 openvswitch
libcrc32c 12644 2 xfs,openvswitch