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!
Hi, thank you for your post. I have just one problem – when I try to enter ‘systemctl start openvswitch.service’ my console freezes and nothing happens. I am doing everything just like you wrote. Many thanks.
LikeLike
Sorry for previous comment, that was a problemy with SELinux – I just disabled it. Many thanks.
LikeLike
Glad you found the solution. Thanks for your feedback!
LikeLike
Thanks for detail explanation. the last step should be:
$rpmbuild -bb –nocheck ~/rpmbuild/SOURCES/openvswitch-2.3.2/rhel/openvswitch_no_kmod.spec
LikeLike
Thanks for your feedback, I’ll solve the typo at once.
LikeLike
Great how-to! Thanks so much for posting this update and the previous version. The installation went effortlessly.
LikeLike
I’m glad it’s still useful and works for you, thanks for your kind words.
LikeLike
the compilation will fail if openssl is not install but there is twice openssl-devel in your list. maybe a typo ?
LikeLike
Hi!, indeed it’s a typo I’ll update it, thanks for the feedback! If Openssl it’s not installed the openssl-devel package I guess it should install openssl as a dependency.
LikeLike