CentOS 7. Did you know…?

This post is just a reminder of some things that you may have not noticed when working with CentOS 7. I’ll be updating it from time to time.

  • Remember those times when you had to use nohup with a command so it could run on the background even if you closed the shell from where it was launched? That’s no longer needed with CentOS 7, if you have a background job and you close that shell, the process will run! No more nohup needed.
  • You can use yum to install locally rpm files you’ve downloaded so dependencies are installed automatically. We used to use yum localinstall but now you can use yum install right away.

OPENVSWITCH LTS IN CENTOS 6

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!

Installing NGINX on CentOS 7

This a quick note on how to install the latest NGINX server on my CentOS 7, using the pakages provided by the NGINX team.  I share this post as it may help any visitor.

The official info about the official NGINX packages is in NGINX’s site

As root you can add the repository file for mainline version:

cat << EOT > /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/\$basearch/
gpgcheck=0
enabled=1
EOT

If you want to use the stable version you’d execute:

cat << EOT > /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/\$basearch/
gpgcheck=0
enabled=1
EOT

Then just use yum:

yum install -y nginx

And manage the service as usual (start the service, enable it at boot time and check the status):

service start nginx

service enable nginx

service status nginx

If you want to check the version you’ve just installed (e.g I’m using the latest mainline version July/2016):

# nginx -v
nginx version: nginx/1.11.2

And that’s all, just a note for my reference for the future, hope it helps you too ūüôā

 

OpenShift – Deploying a Node app using a custom version

Hi,
these days I’m developing a NodeJS app. Thanks to OpenShift you can upload your NodeJS code and start playing with it on Internet for free. You also have Heroku, but OpenShift gives you three cartridges (containers like?) for free while Heroku gives you one dyno.

Unfortunately the OpenShift NodeJS cartridge is a little outdated (version 0.10) and I wanted to use the 4 LTS version.

Out there, you have several resources to run your custom Node version, they are all awesome and helpful.

The READMEs on those github repos will guide you on how to install a simple web app using an updated Node version.

Anyway, I wanted to deploy my own code directly in OpenShift so these are the steps I follow just in case it may help you somehow. I’m using the Ramr repo, so a big thank you to him for the impressive work.

I assume that you already have an OpenShift account and that you’ve added your SSH public key.

Ok, I begin creating a nodejs 0.10 app using OpenShift’s web console. Once the app is created, I copy the repo URL which will be a string like ssh://XXXXXXXXXXXXXXX@app-name-domain-name.rhcloud.com/~/git/appname.git/

openshift_web_creation

Now I clone Ramr repo inside the /tmp directory:

cd /tmp
git clone git://github.com/ramr/nodejs-custom-version-openshift.git

Then, from the directory where my code lives (which uses git, of course), I copy the .openshift folder:

cp -rf /tmp/nodejs-custom-version-openshift/.openshift/ .

I add the following line to the package.json file, change it with the name of the file launching your Node service like server, app or in my case ./bin/www:

“main”: “./bin/www”

Now I edit the .openshift/markers/NODEJS_VERSION file and add the exact version of NodeJS which I want to use e.g 4.4.2 (the icflorescu for instance creates a cartridge which updates to the latest Node version available, which is great! so have a look as well).

I add and commit the changes on my repo:

git add .
git commit -a -m “Openshift with custom node integration”

I create the remote repo for OpenShift using the URL I copied earlier, use your own git repo URL from OpenShift!

git remote add openshift ssh://blahblahblah.git/

Ok, now I’ll force the code upload to the OpenShift repo. I’ll do this the first time only, later pushes can be used without forcing it:

git push openshift master -f

If everything is good when uploading the code to OpenShift you’ll see some lines like the following, which means that your desired Node.js version is being installed.

remote: Activating deployment
remote: – Checking to see if Node.js version 4.4.2 is installed …

Hopefully you’ll finally see:

remote: Deployment completed with status: success

This ends my first ever Node.js blog post,  I hope you find it useful.

Cheers!

 

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!