Openvswitch LTS in CentOS 7

The new long-term support version for Openvswitch has been published. As openvswitch RPMs seems to be available for EPEL 6 and Fedora EPEL and other precompiled binaries can be found at rpm.bone.com, I’m sure we’ll soon have openvwitch in the EPEL 7 repository, but in the meantime I hope this post it’s still useful to get the LTS RPM.

Current stable version: 2.5.0 – Openvswitch NEWS

Notes:

  • In order to help you to create a RPM package and install it for the latest LTS release, I’ve created this post which I’ll update as soon as a new version is ready so, for your reference, from now on this is going to be the only post on Openvswitch LTS installation.
  • I’ll be using the Openvswitch’s kernel module that comes with CentOS kernel so no kernel module is compiled.
  • I’m skipping the rpmbuild tests included with openvswitch so building the RPM is faster. However if you have time run the tests to check that everything will work fine.
  • LTS 2.3.X versions will be supported by Openvswitch team until August 2016.
  • From now on I’m using the fedora.spec file as it seems that it manages to build RPMs for CentOS 7 as well.
  • New packages are found like: openvswitch-selinux-policy, python-openvswitch,
    openvswitch-test, openvswitch-ovn, openvswitch-devel and openvswitch-debuginfo. So if you need any of them you’ll have them under /home/ovs/rpmbuild/RPMS (noarch and x86_64).
  • I’ve updated the post with corrections kindly suggested by Riki Cook.

Instructions:

  • As the root user let’s install 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
  • Add a new user and switch to that user:
adduser ovs

su - ovs
  • Download source code and prepare the build environment.
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
  • Build the RPM package (no testing) and exit.
rpmbuild -bb --nocheck openvswitch-2.5.0/rhel/openvswitch-fedora.spec

exit
  • As root, we’ll install the RPM package.
yum localinstall /home/ovs/rpmbuild/RPMS/x86_64/openvswitch-2.5.0-1.el7.centos.x86_64.rpm -y

Finally start the openvswitch service and check that it’s running

systemctl start openvswitch.service

systemctl is-active openvswitch
active --> Ok, it's running fine.

If you want the openvswitch service to start at boot time:

systemctl enable openvswitch

Let’s check that the command-line tools are ready:

ovs-vsctl -V
ovs-vsctl (Open vSwitch) 2.5.0
Compiled Mar 2 2016 11:51:35
DB Schema 7.12.1

Troubleshooting:

This post changes the way I create the RPM so, if you find any error, please let me know and in the meantime use the old method.

If you run the ovs-vsctl show command and you receive the following error, please check that your Openvswitch service has been started (systemctl start openvswitch.service)

  • ovs-vsctl: unix:/var/run/openvswitch/db.sock: database connection failed (No such file or directory)

 

Thanks to Nicira and the Openvswitch team!