Category Archives: Virtualization

CentOS 7 LXC container slow boot

After you have installed a CentOS 7 LXC template on a systemd supprted distro (Fedora 21/22, CentOS 7 with LXC 1.0.7), you can experience a ultra slow container boot (more than 5 minutes!). A small change can fix this issue.

In the container config (i.e. /var/lib/lxc/centos7/config) replace:

1
lxc.include = /usr/share/lxc/config/centos.common.conf

with

1
lxc.include = /usr/share/lxc/config/fedora.common.conf

This will make the container boot fast as it should be.

centos.common.conf is fine for CentOS 6 but not for CentOS 7: CentOS 7 is based on Fedora 19 and uses systemd, thus fedora.common.conf is the right config file to use.

Fedora 22 / CentOS 7 LXC fix systemd-journald process at 100%

Running a Fedora 21, Fedora 22 or a RHEL/CentOS 7 LXC container created by the lxc-create Fedora template can result in a 100% cpu loop for the systemd-journald process.

To fix this issue you must add lxc.kmsg = 0 to the container configuration. This can be done easily for all the Fedora templates in one shot:

echo "lxc.kmsg = 0" >> /usr/share/lxc/config/fedora.common.conf

See also:

OpenShift Cookbook by Packt Publishing

Author: Shekhar Gulati
Publisher: Packt Pubblications
URL: https://www.packtpub.com/virtualization-and-cloud/openshift-cookbook
GitHub: https://github.com/OpenShift-Cookbook

On Amazon: http://www.amazon.com/OpenShift-Cookbook-Shekhar-Gulati/dp/1783981202/

This great book lets you, with a very little effort, to understand the OpenShift technology. You don’t need a strong background on virtualization and container technologies, but at the same time it does not get bored a skilled user.

The overview on the OpenShift technology and its utilities (rhc) is very clear and easy to follow, also thanks to the OpenShift free profile which allows you to test and play with the rhc command while you go through with the book reading. More complex tasks like backups, snapshots, rollbacks are addressed and explained. Also the security aspects are taken into account.

Several real-world examples, with end-to-end receipts, are showed in the book: MySQL, PostgreSQL, MongoDB for database apps, Python, Java, Node.js for web oriented development.

A chapter is dedicated on how to use Jenkins CI as a Continuous Integration system for OpenShift apps; this is an aspect which is most of the times not took into account, but it’s very important nowadays.

I would consider as the “core” of the book the chapter on scaling OpenShift applications, which is a salient characteristic of OpenShift and it is not always an easy task to solve.

In conclusion a must have book if you want to start and play with OpenShift, even if you are a beginner or if you are not but you don’t have familiarity with complex and scalable application deployment.

All the code mentioned in the book is available on their GitHub repo: https://github.com/OpenShift-Cookbook.

Create a new Fedora LXC container using yum

In this tutorial we are going to install an LXC container with Fedora 21 to be run on a Fedora 21 host with libvirt. This can be used to create containers to be managed by my WebVirtMgr web panel.

Install the new filesystem

yum -y --installroot=/var/lib/libvirt/filesystems/fedora21 --releasever=21 --nogpg install systemd passwd yum fedora-release vim openssh-server procps-ng iproute net-tools dhclient less

Create the libvirt domain

virt-install --connect lxc:/// --name fedora21 --ram 512 --filesystem /var/lib/libvirt/filesystems/fedora21/,/

This command will also start the domain. Now it’s time to stop it and do some post install configurations.

Post-installation setup

Press Ctrl + ] to detach from the domain console. Than stop it:

virsh -c lxc:/// shutdown fedora21

Change root password

chroot /var/lib/libvirt/filesystems/fedora21 /bin/passwd root

Setup the hostname

echo "mynewlxc" > /var/lib/libvirt/filesystems/fedora21/etc/hostname

Setup the network

cat << EOF > /var/lib/libvirt/filesystems/fedora21/etc/sysconfig/network
NETWORKING=yes
EOF
cat << EOF > /var/lib/libvirt/filesystems/fedora21/etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=dhcp
ONBOOT=yes
DEVICE=eth0
EOF

Setup SSH

chroot /var/lib/libvirt/filesystems/fedora21/
ln -s /usr/lib/systemd/system/sshd.service /etc/systemd/system/multi-user.target.wants/
exit

Start the container

virsh -c lxc:/// start fedora21

Or, if you are using my WebVirtMgr web panel fork you can start / stop the domain using it.

The Fedora 21 LX

The Fedora 21 LXC

Source

Thanks to major.io for his original article. It contains also some important considerations about security.