Difference between revisions of "Using vzpkg and vzyum on x86 64"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
m (VE->container)
m (Setup glossary link for "container")
Line 7: Line 7:
  
 
There is a known problem with <b>vzpkg-2.7.0</b> and <b>vzyum-2.4.0</b> in x86_64 computers:
 
There is a known problem with <b>vzpkg-2.7.0</b> and <b>vzyum-2.4.0</b> in x86_64 computers:
Vzyum, vzpkgcache and vzrpm are broken in 64 bit systems, so we are unable to create new cache templates in a x86_64 computer or update each container using vzyum or vzrpm.
+
Vzyum, vzpkgcache and vzrpm are broken in 64 bit systems, so we are unable to create new cache templates in a x86_64 computer or update each [[container]] using vzyum or vzrpm.
 
This text describes a work around and a few hacks to get it work flawless.
 
This text describes a work around and a few hacks to get it work flawless.
  
Line 24: Line 24:
  
 
Until now there is only one <i>side effect</i> detected in this solution:
 
Until now there is only one <i>side effect</i> detected in this solution:
* The yum cache is not common to all containers. Instead, each container has it's own yum cache in the directory <code>/var/cache/yum-cache</code>.
+
* The yum cache is not common to all [[container]]s. Instead, each [[container]] has it's own yum cache in the directory <code>/var/cache/yum-cache</code>.
 
This is a consequence from using the modified vzyum.
 
This is a consequence from using the modified vzyum.
  
Line 131: Line 131:
 
<code>cachedir=/var/cache/yum-cache</code>
 
<code>cachedir=/var/cache/yum-cache</code>
  
{{Note| With this changes, vzyum is not going to be able to use a common cache directory to all containers as it was used to do. Each container will have it's own cache directory.
+
{{Note| With this changes, vzyum is not going to be able to use a common cache directory to all [[container]]s as it was used to do. Each [[container]] will have it's own cache directory.
To avoid to have a directory named /vz/template/centos/4/x86_64/yum-cache in each container, it is preferable to use the correct cache directory /var/cache/yum-cache.}}
+
To avoid to have a directory named /vz/template/centos/4/x86_64/yum-cache in each [[container]], it is preferable to use the correct cache directory /var/cache/yum-cache.}}
  
  
Line 283: Line 283:
 
===== STEP 10 =====
 
===== STEP 10 =====
  
If you want your containers to have other country locales
+
If you want your [[container]]s to have other country locales
 
edit <code>/vz/template/centos/4/x86_64/config/.rpmmacros</code> and change the line <b>%_install_langs C</b>
 
edit <code>/vz/template/centos/4/x86_64/config/.rpmmacros</code> and change the line <b>%_install_langs C</b>
 
to the language you want, for example:
 
to the language you want, for example:
Line 311: Line 311:
  
  
If you see the cache list, then you can create your first container:
+
If you see the cache list, then you can create your first [[container]]:
  
  
Line 319: Line 319:
 
To change the <i>locales</i>, copy <code>/etc/sysconfig/i18n</code> to <code>/vz/private/200/etc/sysconfig</code>, if you wish to use another language and have done STEP 10 previously.
 
To change the <i>locales</i>, copy <code>/etc/sysconfig/i18n</code> to <code>/vz/private/200/etc/sysconfig</code>, if you wish to use another language and have done STEP 10 previously.
  
Now start container 20 previously created:
+
Now start [[container]] 200 previously created:
  
 
  vzctl start 200
 
  vzctl start 200
Line 330: Line 330:
  
  
Try to use vzrpm, to list all rpm's installed in container 200:
+
Try to use vzrpm, to list all rpm's installed in [[container]] 200:
  
  

Revision as of 18:12, 25 February 2008

This document describes a way to install OpenVZ in a x86_64 computer, so that it can create cache templates, use vzyum and vzrpm. This is intended to work in a Centos-4 (tested) or a Fedora Core distribution (not tested).


THE PROBLEM

There is a known problem with vzpkg-2.7.0 and vzyum-2.4.0 in x86_64 computers: Vzyum, vzpkgcache and vzrpm are broken in 64 bit systems, so we are unable to create new cache templates in a x86_64 computer or update each container using vzyum or vzrpm. This text describes a work around and a few hacks to get it work flawless.

Yellowpin.svg Note: The basic idea is to change the code in such a way that vzyum and vzrpm use the real yum and rpm to do the job, and also create new x86_64 paths required by the system.


REQUIREMENTS

  • - A x86_64 computer
  • - Centos-4 distribution (or Fedora Core 3, 4 or 5 - not tested).
  • - Yum package installed.


SIDE EFFECTS

Until now there is only one side effect detected in this solution:

  • The yum cache is not common to all containers. Instead, each container has it's own yum cache in the directory /var/cache/yum-cache.

This is a consequence from using the modified vzyum.


INSTALL Openvz

There are two ways to install it:

  • A - AUTOMATIC INSTALL (FASTEST)
  • B - MANUAL INSTALL - STEP BY STEP


A - AUTOMATIC INSTALL (FASTEST)

General considerations

  • This is a fastest way to install openvz utilities, and template utilities, ready to use in a x86_64 system.
  • You can only use the automatic install IF YOU HAVE YUM AND RPM PACKAGES INSTALLED IN YOUR SYSTEM, and if you want to install a Centos-4 cache template.
  • This process uses a bash script that automatizes all the hard work made by hand in the manual install.
  • If something goes wrong, or if you want to install a diferent cache template, it's better to do the manual install, and try to adapt it to your needs.


Procedure

  • Read carefully the Quick installation page and install the openvz kernel, configure the bootloader, change sysctl.conf, and finally reboot your system the way it is described there.
  • Download the file setx86_64 and then untar and run the script:
tar xzvf setx86_64.tar.gz
./setx86_64

Press Enter and let the script to do all the job for you.

When it finishes with the message "END INSTALL", you can go on reading this document jumping to the undermentioned STEP 10.

Note This script will almost work for CentOS-5, however it's not quite right (you will get some errors). You will also need to:

rm /usr/share/vzpkgtools/vzrpm43/lib/python2.4/site-packages/rpmmodule.so

which will cause it to resolve a dependency using your system wide python implementation

B - MANUAL INSTALL -STEP BY STEP

If for any reason you prefer manual installation, you may start your install process the same way as described in Quick installation. In x86_64, the packages vzpkg, vzyum and vztmpl-* are broken. So, let's install them this way, to avoid problems:

yum install vzrpm*

We can't "yum install vzyum" because it breaks with an error: Error: Missing Dependency: cElementTree.so is needed by package vzyum

So we must download it first and then install it.

wget -c http://download.openvz.org/template/utils/vzyum/2.4.0-11/vzyum-2.4.0-11.noarch.rpm
rpm --nodeps -Uvh vzyum*.rpm
yum install vztmpl-centos-4 vzpkg*


TWEAKING THE CODE

Now let's tweak the code doing it step by step. You can do a copy-paste from the next command lines to your system. The example is using Centos-4 distribution (tested), but Fedore Core or other distribution with yum and rpm installed, may be tried, if you change the reference name and version in STEPS 1 to 4 (this was not tested).


STEP 1

If you didn't instal yet "vztmpl-centos-4", do it now:

yum install vztmpl-centos-4


STEP 2

The template installed is a i386 template. So, we need to create a x86_64 template from the i386.

cd /vz/template/centos/4/
mkdir x86_64
cp -a /vz/template/centos/4/i386/* /vz/template/centos/4/x86_64
cd /vz/template/centos/4/x86_64/config
sed -i.tmp 's/i386/x86_64/g' yum.conf
rm -f yum.conf.tmp

Now we have a x86_64 centos template installed.


STEP 3

Edit the file /vz/template/centos/4/x86_64/config/yum.conf with your editor. Change the line:

cachedir=/vz/template/centos/4/x86_64/yum-cache

to

cachedir=/var/cache/yum-cache

Yellowpin.svg Note: With this changes, vzyum is not going to be able to use a common cache directory to all containers as it was used to do. Each container will have it's own cache directory.

To avoid to have a directory named /vz/template/centos/4/x86_64/yum-cache in each container, it is preferable to use the correct cache directory /var/cache/yum-cache.


STEP 4

If you list the directory vz-addons like this:

ls -l /vz/template/centos/4/x86_64/vz-addons

probably you will see the file MAKEDEV-3.3.13-1.3.swsoft.i386.rpm. This "ls" allows us to confirm which MAKEDEV version we need to use in this step.

Edit the files minimal.list and default.list in /vz/template/centos/4/x86_64/config directory, and change the line:

MAKEDEV

to

MAKEDEV-3.3.13 (or the version you saw in the "ls")


STEP 5

Verify if you have rpm-python installed in your system, because it has 64 bit module needed:

rpm -q rpm-python
rpm-python-4.3.3-18_nonptl


Install it if you didn't do it already:

yum install rpm-python

Substitute 32 bit module "rpmmodule.so" from vzrpm43-python to the 64 bit module that rpm-python-x86_64 provides, using this method:

cd /usr/share/vzpkgtools/vzrpm43/lib/python2.3/site-packages/
cp /usr/lib64/python2.3/site-packages/rpmmodule.so .
cp: overwrite `./rpmmodule.so'? y
cd /usr/share/vzpkgtools/vzrpm43/lib/python2.3/site-packages/rpmdb
cp /usr/lib64/python2.3/site-packages/rpmdb/_rpmdb.so .
cp: overwrite `./_rpmdb.so'? y

For CentOS-5, you will need to do something a bit different. "rpmmodule.so" is provided in your sitewide python distribution, so instead of copying it across, you need to:

rm /usr/share/vzpkgtools/vzrpm43/lib/python2.4/site-packages/rpmmodule.so


Now we must edit and change these 3 files described in the next steps:

/usr/share/vzpkg/cache-os

/usr/share/vzpkg/functions

/usr/bin/vzyum

STEP 6

Edit the file /usr/share/vzpkg/cache-os Change the next lines:


-Line 136:

change: --vps=$VEID check-update
to: check-update


-Line 185:

change: YUM_CMD="--installroot=$VE_ROOT --vps=$VEID $YUM_CONF_FILE -y $YUM_CMD"
to: YUM_CMD="--installroot=$VE_ROOT $YUM_CONF_FILE -y $YUM_CMD"


STEP 7

Edit the file /usr/share/vzpkg/functions Change the next lines:


-Line 21:

change: YUM=/usr/share/vzyum/bin/yum
to: YUM=`which yum`


-Line 22:

change: ARCHES="x86 i386 x86_64 ia64"
to: ARCHES="i386 x86_64 ia64 x86"


-Line 111:

change: export RPM=`get_rpm $tdir`
to: export RPM=`which rpm`


-Line 450:

change: rpm=`get_rpm $tdir`
to: rpm=`which rpm`


STEP 8

Edit the file /usr/bin/vzyum Change the next line:


-Line 51:

change: YUM_ARGS="$YUM_ARGS --installroot $VE_ROOT --vps=$VEID"
to: YUM_ARGS="$YUM_ARGS --installroot $VE_ROOT"


STEP 9

Edit file /usr/bin/vzrpm Change the next line:


-Line 40:

change: RPM_ARGS="--root $VE_ROOT --veid $VEID"
to: RPM_ARGS="--root $VE_ROOT"


-Line 52:

change: RPM=`get_rpm $TDIR`
to: RPM=`which rpm`


STEP 10

If you want your containers to have other country locales edit /vz/template/centos/4/x86_64/config/.rpmmacros and change the line %_install_langs C to the language you want, for example:

%_install_langs C:pt_PT:pt_PT.UTF-8:en_US:en_US.UTF-8


TESTING THE NEW CODE

Now you can create your own cache your own cache templates Let's test it!

Make my first two cache templates:


vzpkgcache -f centos-4-x86_64-default
vzpkgcache -f centos-4-x86_64-minimal


They finish with complaints about cron.daily, but don't worry about it. Now minimal and default cache are created. Confirm if they are created:


vzpkgls -c


If you see the cache list, then you can create your first container:


vzctl create 200 --ostemplate centos-4-x86_64-minimal


To change the locales, copy /etc/sysconfig/i18n to /vz/private/200/etc/sysconfig, if you wish to use another language and have done STEP 10 previously.

Now start container 200 previously created:

vzctl start 200


Then test also "vzyum" and see if it works. Try to install "nano editor":


vzyum 200 install nano


Try to use vzrpm, to list all rpm's installed in container 200:


vzrpm 200 -qa


If you didn't have any errors, the changes are fine.

If something went wrong, probably you made a mistake in those previous steps. Carefully verify if you did it well, step by step.