As some visitors have asked me about installing Open vSwitch on CentOS 6, I’m writing the following post after my first about it almos three years ago. If you find a better way, please let me know so I update the post and remove useless info from the Internet 😉
I’ve found this repository by Alexander Evseev so you may try to use the openvswitch packages (you even have the kmod package) found there. Have a look: http://download.opensuse.org/repositories/home:/aevseev/CentOS6/x86_64/
In any case… I’ll show you what you can do to generate your own RPM packages the old way (no python api supported as it requires Python 2.7 while CentOS 6 uses Python 2.6):
Current LTS version: 2.5.0
Tested on: CentOS 6.8
Let’s start installing some packages:
yum -y install wget openssl-devel gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool python-twisted-core python-zope-interface PyQt4 desktop-file-utils libcap-ng-devel groff checkpolicy selinux-policy-devel
Let’s add a new user and switch to that user:
adduser ovs; su - ovs
Let’s prepare the build environment and download the source code:
mkdir -p ~/rpmbuild/SOURCES wget http://openvswitch.org/releases/openvswitch-2.5.0.tar.gz cp openvswitch-2.5.0.tar.gz ~/rpmbuild/SOURCES/ tar xfz openvswitch-2.5.0.tar.gz
Now go to the openvswitch directory
cd openvswitch-2.5.0
Let’s modify some lines in the old rhel6 spec file provided by Nicira (copy and paste):
sed -i "s/Requires: logrotate, python >= 2.7/Requires: logrotate/" rhel/openvswitch.spec sed -i "/$RPM_BUILD_ROOT\/usr\/bin\/ovs-test/d" rhel/openvswitch.spec sed -i "/$RPM_BUILD_ROOT\/usr\/bin\/ovs-l3ping/d" rhel/openvswitch.spec sed -i "/\/usr\/bin\/ovs-parse-backtrace/d" rhel/openvswitch.spec sed -i "/\/usr\/bin\/ovs-pcap/d" rhel/openvswitch.spec sed -i "/\/usr\/bin\/ovs-tcpundump/d" rhel/openvswitch.spec sed -i "/\/usr\/bin\/ovs-vlan-test/d" rhel/openvswitch.spec sed -i "/\/usr\/share\/man\/man8\/ovs-bugtool.8.gz/d" rhel/openvswitch.spec sed -i "/\/usr\/share\/openvswitch\/bugtool-plugins/d" rhel/openvswitch.spec sed -i "/\/usr\/share\/openvswitch\/scripts\/ovs-bugtool-*/d" rhel/openvswitch.spec sed -i "/\/usr\/share\/openvswitch\/python/d" rhel/openvswitch.spec sed -i "/\/usr\/share\/openvswitch\/scripts\/ovs-bugtool-*/d" rhel/openvswitch.spec sed -i "/\/usr\/bin\/ovs-dpctl-top/d" rhel/openvswitch.spec sed -i "/\/usr\/sbin\/ovs-bugtool/d" rhel/openvswitch.spec echo "/usr/bin/ovs-testcontroller" >> rhel/openvswitch.spec
Finally let’s build the RPM packages… and have a cup of coffee as tests are being run! At least you can tell if it works… 😛
rpmbuild -bb rhel/openvswitch.spec
Once the build is finished, type exit.
exit
CentOS 6 already provides an openvswitch kernel module, so we’ve only compiled the binary tools.
[root@localhost ~]# modinfo openvswitch filename: /lib/modules/2.6.32-642.3.1.el6.x86_64/kernel/net/openvswitch/openvswitch.ko license: GPL description: Open vSwitch switching datapath srcversion: 00938868C288DBF055E30F3 depends: libcrc32c,vxlan vermagic: 2.6.32-642.3.1.el6.x86_64 SMP mod_unload modversions
As root, we’ll install the RPM package.
 yum localinstall /home/ovs/rpmbuild/RPMS/x86_64/openvswitch-2.5.0-1.x86_64.rpm -y
Finally, start the openvswitch service and check that it’s running
service openvswitch start ...output... /etc/openvswitch/conf.db does not exist ... (warning). Creating empty database /etc/openvswitch/conf.db [ OK ] Starting ovsdb-server [ OK ] Configuring Open vSwitch system IDs [ OK ] Inserting openvswitch module [ OK ] Starting ovs-vswitchd [ OK ] Enabling remote OVSDB managers [ OK ]
service openvswitch status ...output... ovsdb-server is running with pid 3404 ovs-vswitchd is running with pid 3416
If you want the openvswitch service to start at boot time:
chkconfig openvswitch on
Let’s check that the command-line tools are ready:
ovs-vsctl -V ...output... ovs-vsctl (Open vSwitch) 2.5.0 Compiled Aug 31 2016 19:54:41 DB Schema 7.12.1
Done. I can’t be sure if it will work for you as I haven’t been using Open vSwitch with CentOS 6 for a long time… so any feedback is welcomed!
Cheers!