CentOS 7 – Installing Openvswitch 2.3.2 LTS

Openvswitch 2.3.2 was released on June 2015 and this post explains how to quickly generate an RPM to install Openvswitch command-line tools. This is a rewrite of my old post. I’ll be using the Openvswitch’s kernel module that comes with CentOS kernel so no kernel module is compiled.

As the root user let’s install some packages and add a new user:

yum -y install wget gcc make python-devel openssl-devel kernel-devel graphviz kernel-debug-devel autoconf automake rpm-build redhat-rpm-config libtool

adduser ovs

su - ovs

Now as the ovs user we’ll generate the rpm file. In this post I’m skipping the rpmbuild tests included with openvswitch as I’m solving some dependency problems.

mkdir -p ~/rpmbuild/SOURCES

wget http://openvswitch.org/releases/openvswitch-2.3.2.tar.gz

cp openvswitch-2.3.2.tar.gz ~/rpmbuild/SOURCES/

tar xfz openvswitch-2.3.2.tar.gz

sed 's/openvswitch-kmod, //g' openvswitch-2.3.2/rhel/openvswitch.spec > openvswitch-2.3.2/rhel/openvswitch_no_kmod.spec

rpmbuild -bb --nocheck openvswitch-2.3.2/rhel/openvswitch_no_kmod.spec

exit

We’ll create the /etc/openvswitch configuration directory:

mkdir /etc/openvswitch

Let’s install the rpm package:

 yum localinstall /home/ovs/rpmbuild/RPMS/x86_64/openvswitch-2.3.2-1.x86_64.rpm

If you’re using SELinux in enfocing mode let’s change some contexts:

yum install policycoreutils-python 

semanage fcontext -a -t openvswitch_rw_t "/etc/openvswitch(/.*)?" 
restorecon -Rv /etc/openvswitch

Start the openvswitch service:

systemctl start openvswitch.service

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
ovs-vsctl (Open vSwitch) 2.3.2
Compiled Jun 28 2015 13:01:11
DB Schema 7.6.2

If you’re using SELinux in enfocing mode, if you try to start the service (systemctl start openvswitch.service) you’ll find some errors unless you execute the SELinux commands:

  • install: cannot change owner and permissions of ‘/etc/openvswitch’: No such file or directory
  • Creating empty database /etc/openvswitch/conf.db ovsdb-tool: I/O error: /etc/openvswitch/conf.db: failed to lock lockfile (No such file or directory).

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)

Done!

Advertisement