Install OpenVZ on a X86_64 CentOS

In wiki.openvz.org, there is an article on Install OpenVZ on a x86 64 system Centos-Fedora.

Some problems and fixes:

 

404 file not found

I kept getting random "404 file not found" when running "vzpkgcache" to install the cache template. To fix this, I found some  "yum.conf" files

# find /vz/template/ -name 'yum.conf'
/vz/template/fedora-core/4/i386/config/yum.conf
/vz/template/fedora-core/4/x86_64/config/yum.conf
/vz/template/fedora-core/6/i386/config/yum.conf
/vz/template/fedora-core/6/x86_64/config/yum.conf
/vz/template/fedora-core/3/i386/config/yum.conf
/vz/template/fedora-core/3/x86_64/config/yum.conf
/vz/template/fedora-core/5/i386/config/yum.conf
/vz/template/fedora-core/5/x86_64/config/yum.conf
/vz/template/fedora/9/i386/config/yum.conf
/vz/template/fedora/9/x86_64/config/yum.conf
/vz/template/fedora/7/i386/config/yum.conf
/vz/template/fedora/7/x86_64/config/yum.conf
/vz/template/centos/4/i386/config/yum.conf
/vz/template/centos/4/x86_64/config/yum.conf
/vz/template/centos/5/i386/config/yum.conf
/vz/template/centos/5/x86_64/config/yum.conf

Edit the one I want for installing the cache template, say /vz/template/centos/5/x86_64/config/yum.conf. Under the sections "[centos5-base]" and "[centos5-updates-released]", comment out the lines for "baseurl", add

"mirrorlist=http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=os" for "[centos5-base]", and add

"mirrorlist=http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=updates" for "[centos5-updates-released]".

Error when trying to install centos-4:

When we try to install centos-4 cache template, we got some error on "rpmmodule.so: wrong ELF class: ELFCLASS32":

# vzpkgcache centos-4-i386-minimal
Creating cache for centos-4-i386-minimal OS template
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
 
   /usr/share/vzpkgtools/vzrpm43/lib/python2.4/site-packages/rpmmodule.so: wrong ELF class: ELFCLASS32
  
Please install a package which provides this module, or
verify that the module is installed correctly.

According to this post http://forum.openvz.org/index.php?t=msg&goto=26029&, we can remove the file /usr/share/vzpkgtools/vzrpm43/lib/python2.4/site-packages/rpmmodule.so. I just simply renamed it.

"vzpkgcache centos-4-i386-minimal" not usable

The container created from the template centos-4-i386-minimal is not usable. After I created a user in the container, "su - newuser" returned "could not open session". "passwd newuser" returned "Authentication token manipulation error".

restorecon: command not found

When trying to install a centos-4-i386-default, we get:

  Installing     : samba-common                                         141/172
/var/tmp/rpm-tmp.91569: line 7: restorecon: command not found
error: %post(samba-common-3.0.33-0.18.el4_8.1.i386) scriptlet failed, exit status 127

This is due to a samba package bug. I guess the way to work around it is to add a repository that has a newer version of the package, which fixes the bug. I have not tried this yet.

vzpkgcache fails to install cache template

As shown above, I had trouble installing centos-4-i386-default using vzpkgcache. To get around this, we can install a precreated template. Go to http://download.openvz.org/template/precreated or http://download.openvz.org/template/precreated/contrib/, and find the precreated template. Then in the host, do

host# cd /vz/template/cache
host# wget -O centos-4-i386-default.tar.gz http://download.openvz.org/template/precreated/contrib/centos-4-i386-def...
host# vzpkgls -c
centos-4-i386-default

Reference: http://wiki.openvz.org/Template#Alternative:_use_precreated_template_cache

rpmdb: Program version 4.2 doesn't match environment version

After we created a centos-4 container from centos-4-i386-minimal, we installed yum into the container:

host# vzyum 100 install yum
(100 is the CTID)
host# vzctl enter 100
CT100# # yum update
rpmdb: Program version 4.2 doesn't match environment version
error: db4 error(22) from dbenv->open: Invalid argument
error: cannot open Packages index using db3 - Invalid argument (22)
error: cannot open Packages database in /var/lib/rpm

...

To fix this, just rebuild the rpm database:

CT100# rm -f /var/lib/rpm/__db*
CT100# rpm -rebuilddb