Difference between revisions of "Using vzpkg and vzyum on x86 64"
(create page) |
|||
(27 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{Warning|These are not official installation instructions. Do not follow this article, use [[Quick installation]] instead! | ||
+ | |||
+ | '''Please also note that template tools (vzpkg/vzyum) are unsupported and obsoleted.'''}} | ||
+ | |||
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 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 | + | This is intended to work in a host with Centos-4, Centos-5, Fedora Core 5, Fedora Core 6, RHEL 4 or any other RPM based system with python 2.2, 2.3 or 2.4 version. |
− | |||
+ | Last Revision: [[User:Mcarreira|Mcarreira]] 18:07, 30 January 2011 (UTC) | ||
== THE PROBLEM == | == THE PROBLEM == | ||
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 | + | 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 16: | Line 20: | ||
* - A x86_64 computer | * - A x86_64 computer | ||
− | * - Centos | + | * - A host with x86_64 Centos, Fedora Core or RHEL, or other Redhat based systems with python 2.2, 2.3 or 2.4 version (vzrpm is unable to run with python 2.5 version) |
* - Yum package installed. | * - Yum package installed. | ||
+ | == TESTED HOSTS == | ||
+ | |||
+ | * - Centos 4 | ||
+ | * - Centos 5 | ||
+ | * - Fedora Core 5 | ||
+ | * - Fedora Core 6 | ||
+ | |||
+ | |||
+ | == HOSTS PROBABLY WORKING (not tested) == | ||
+ | |||
+ | * - RHEL 4 | ||
+ | * - RHEL 5 | ||
+ | |||
+ | |||
+ | == HOSTS NOT WORKING == | ||
+ | |||
+ | * - Older distros with yum version less then 2.4, python version less then 2.2, rpm version less then 4.3 | ||
+ | * - Fedora 7 | ||
+ | * - Fedora 8 | ||
+ | * - Or any other system with python 2.5 or above. | ||
== SIDE EFFECTS == | == SIDE EFFECTS == | ||
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 | + | * The yum cache is not common to all [[container]]s. Instead, each [[container]] has its 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. | ||
− | |||
== INSTALL Openvz == | == INSTALL Openvz == | ||
Line 41: | Line 64: | ||
* This is a fastest way to install openvz utilities, and template utilities, ready to use in a x86_64 system. | * 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 | + | * You can only use the automatic install IF YOU HAVE <b>YUM</b> AND <b>RPM</b> PACKAGES INSTALLED IN YOUR SYSTEM. |
− | * This process uses a bash script | + | * This process uses a bash script which automates all the hard work made by hand in the manual install. It was successfully tested in several systems. |
− | * If something goes wrong, or if you want to install a diferent | + | * If something goes wrong, or if you want to understand the way it works to install a diferent distribution, it's better to do the manual install, and try to adapt it to your needs. |
Line 49: | Line 72: | ||
* 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. | * 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 [http://linux.carreira.com.pt/ovzutils/setx86_64.tar.gz setx86_64] and then untar and run the script: | + | * Download the file [http://linux.carreira.com.pt/ovzutils/setx86_64-0.6.tar.gz setx86_64-0.6] and then untar and run the script: |
<pre> | <pre> | ||
− | tar xzvf setx86_64.tar.gz | + | tar xzvf setx86_64-0.6.tar.gz |
− | + | sh setx86_64 | |
</pre> | </pre> | ||
− | + | Press Enter and some tests are made to know if you can go on with the installation. | |
− | + | If you choose to go on with it, the script will download and patch everything for you. | |
− | + | All the vztemplates metadata available in openvz.org site are also installed and fixed for x86_64 system. | |
− | |||
− | |||
+ | When it finishes with the message "END INSTALL", you can go on reading this document jumping to the undermentioned <b>[[#STEP_11|STEP 11]]</b>. | ||
=== B - MANUAL INSTALL -STEP BY STEP === | === B - MANUAL INSTALL -STEP BY STEP === | ||
Line 73: | Line 95: | ||
</code> | </code> | ||
− | We can't "yum install vzyum" because it breaks with an error: | + | We can't "yum install vzyum" because it breaks with an error:<br> |
− | Error: Missing Dependency: cElementTree.so is needed by package vzyum | + | <b>Error: Missing Dependency: cElementTree.so is needed by package vzyum</b> |
So we must download it first and then install it. | So we must download it first and then install it. | ||
Line 81: | Line 103: | ||
wget -c http://download.openvz.org/template/utils/vzyum/2.4.0-11/vzyum-2.4.0-11.noarch.rpm | 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 | rpm --nodeps -Uvh vzyum*.rpm | ||
− | yum install | + | yum install vzpkg* |
</code> | </code> | ||
Line 89: | Line 111: | ||
Now let's tweak the code doing it step by step. | 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. | You can do a copy-paste from the next command lines to your system. | ||
− | The example is using <b>Centos-4</b> distribution, but <b> | + | The example is using <b>Centos-4</b> distribution, but <b>Fedora</b> or other distribution with yum, rpm and python (version 2.2, 2.3 or 2.4) installed, may be tried. You only have to change the reference name and version in STEPS 1 to 4. |
===== STEP 1 ===== | ===== STEP 1 ===== | ||
− | + | Install "vztmpl-centos-4": | |
<code> | <code> | ||
yum install vztmpl-centos-4 | yum install vztmpl-centos-4 | ||
</code> | </code> | ||
+ | |||
+ | {{ Note |In setx86_64 script, all the vztemplates available in openvz.org site are downloaded and used to build x86_64 templates, ready to be used.}} | ||
Line 104: | Line 128: | ||
The template installed is a i386 template. So, we need to create a x86_64 template from the i386. | The template installed is a i386 template. So, we need to create a x86_64 template from the i386. | ||
+ | We only have to replace i386 references with x86_64 in all files. | ||
<code> | <code> | ||
cd /vz/template/centos/4/ | cd /vz/template/centos/4/ | ||
− | + | cp -a i386 x86_64 | |
− | cp -a | ||
cd /vz/template/centos/4/x86_64/config | cd /vz/template/centos/4/x86_64/config | ||
sed -i.tmp 's/i386/x86_64/g' yum.conf | sed -i.tmp 's/i386/x86_64/g' yum.conf | ||
Line 114: | Line 138: | ||
</code> | </code> | ||
− | Now we have a x86_64 centos template installed. | + | Now we have a x86_64 centos template installed.<br> |
+ | You can do the same procedure to other distro templates. | ||
Line 122: | Line 147: | ||
Change the line: | Change the line: | ||
− | <code>cachedir=/vz/template/centos/4/x86_64/yum-cache</code> | + | :<code>cachedir=/vz/template/centos/4/x86_64/yum-cache</code> |
− | to | + | :to |
+ | |||
+ | :<code>cachedir=/var/cache/yum-cache</code> | ||
− | < | + | {{Note| <b>1)</b> With these changes, vzyum won´t be able to use a common cache directory to all [[container]]s as it used to do. Each [[container]] will have its 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. | ||
− | + | <b>2)</b> To set up a common cache directory, you can use the autofs/automounter daemon together with [[Bind_mounts]] as described in <b>step 12</b>. Using a shared cache may save a lot of network traffic when installing new VPSs.}} | |
− | |||
===== STEP 4 ===== | ===== STEP 4 ===== | ||
+ | |||
+ | |||
+ | Verify the host rpm version: | ||
+ | |||
+ | :<code>rpm --version</code> | ||
+ | |||
+ | In Centos-4 rpm is version 4.3. | ||
+ | |||
+ | Edit this file /vz/template/centos/4/x86_64/config/rpm, and | ||
+ | you will see the number 43. | ||
+ | |||
+ | When the host distro is the same of the template guest, everything would be correct, and we don't need doing anything.<br> | ||
+ | But if we have a different guest template, we might have to correct the values. | ||
+ | |||
+ | We have to change the number inside /vz/template/<i>distro</i>/<i>version</i>/x86_64/config/rpm | ||
+ | according to the rpm version of the host system.<br> | ||
+ | If rpm version is 4.4 the number would be 44.<br> | ||
+ | If rpm version is 4.3 the number would be 43. | ||
+ | |||
+ | |||
+ | |||
+ | ===== STEP 5 ===== | ||
If you list the directory vz-addons like this: | If you list the directory vz-addons like this: | ||
Line 150: | Line 199: | ||
MAKEDEV-3.3.13 (or the version you saw in the "ls") | MAKEDEV-3.3.13 (or the version you saw in the "ls") | ||
</pre> | </pre> | ||
+ | This avoids the undesirable update of special MAKEDEV-swsoft to the real MAKEDEV from the distro yum repository during a vzyum action. | ||
− | ===== STEP | + | |
+ | ===== STEP 6 ===== | ||
Verify if you have <b>rpm-python</b> installed in your system, because it has 64 bit module needed: | Verify if you have <b>rpm-python</b> installed in your system, because it has 64 bit module needed: | ||
Line 165: | Line 216: | ||
yum install rpm-python | yum install rpm-python | ||
− | + | In Centos-4 version python is 2.3. So, we must replace rpmmodule.so from vzrpm43-python to the 64 bit module that rpm-python-x86_64 provides. | |
<pre> | <pre> | ||
+ | |||
cd /usr/share/vzpkgtools/vzrpm43/lib/python2.3/site-packages/ | cd /usr/share/vzpkgtools/vzrpm43/lib/python2.3/site-packages/ | ||
cp /usr/lib64/python2.3/site-packages/rpmmodule.so . | cp /usr/lib64/python2.3/site-packages/rpmmodule.so . | ||
Line 175: | Line 227: | ||
cp: overwrite `./_rpmdb.so'? y | cp: overwrite `./_rpmdb.so'? y | ||
</pre> | </pre> | ||
+ | |||
+ | In other Operating Systems or other versions, you must verify which python version is installed in the host system. | ||
+ | Depending on that, the 32 bit files to be replaced are different (read the setx86_64 script, line 334 to line 358, to understand how it is done). | ||
+ | |||
+ | |||
+ | |||
+ | <blockquote style="background: white; border: 1px solid rgb(153, 153, 153); padding: 1em;"> | ||
+ | <b>Note:</b><br> | ||
+ | Someone reported the note below, but the tests I made, <u>didn't confirm</u> it was really needed. Everything worked flawless without it.<br> | ||
+ | Nevertheless, if you find some problems, try the workaround described below:<br><br> | ||
+ | |||
+ | <i>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 | ||
+ | </i> | ||
+ | </blockquote> | ||
+ | |||
Now we must edit and change these 3 files described in the next steps: | Now we must edit and change these 3 files described in the next steps: | ||
Line 184: | Line 252: | ||
/usr/bin/<b>vzyum</b> | /usr/bin/<b>vzyum</b> | ||
+ | ===== STEP 7 ===== | ||
− | + | Edit the file /usr/share/vzpkg/<b>cache-os</b><br> | |
+ | Change the next lines: | ||
− | + | <b> -Line 97:</b> | |
− | + | {{Note| '''ve-vps.basic.conf-sample''' is now renamed '''ve-basic.conf-sample''' }} | |
+ | (see [http://bugzilla.openvz.org/show_bug.cgi?id=1694 bug 1694] ) | ||
+ | <pre> | ||
+ | change: VECFGSAMPLE=$VECFGDIR/ve-vps.basic.conf-sample | ||
+ | to: VECFGSAMPLE=$VECFGDIR/ve-basic.conf-sample | ||
+ | append: if ! [ -f "$VECFGSAMPLE" ]; then VECFGSAMPLE="$VECGFDIR/ve-vps.basic.conf-sample"; fi | ||
+ | </pre> | ||
<b> -Line 136:</b> | <b> -Line 136:</b> | ||
Line 197: | Line 273: | ||
</pre> | </pre> | ||
+ | <b> -Line 154:</b> | ||
+ | <pre> | ||
+ | append: mkdir -p $VE_ROOT/var/lib/yum/ || abort "Can't create /var/lib/yum" | ||
+ | </pre> | ||
<b> -Line 185:</b> | <b> -Line 185:</b> | ||
Line 205: | Line 285: | ||
− | ===== STEP | + | ===== STEP 8 ===== |
− | Edit the file /usr/share/vzpkg/<b>functions</b> | + | Edit the file /usr/share/vzpkg/<b>functions</b><br> |
Change the next lines: | Change the next lines: | ||
+ | |||
+ | |||
+ | <b> -Line 20:</b> | ||
+ | <pre> | ||
+ | change: VZLIB_SCRIPTDIR=/usr/lib/vzctl/scripts | ||
+ | to: VZLIB_SCRIPTDIR=/usr/lib64/vzctl/scripts | ||
+ | </pre> | ||
Line 239: | Line 326: | ||
− | ===== STEP | + | ===== STEP 9 ===== |
− | Edit the file /usr/bin/<b>vzyum</b> | + | Edit the file /usr/bin/<b>vzyum</b><br> |
Change the next line: | Change the next line: | ||
Line 252: | Line 339: | ||
− | ===== STEP | + | The next piece of code fixed the vzyum bug described in [http://bugzilla.openvz.org/show_bug.cgi?id=488#c0 bugzilla #488].<br> |
+ | It was impossible to install a package group with spaces in his name.<br> | ||
+ | Now we can use e.g. <b>vzyum groupinstall \"GNOME Desktop Environment\"</b>, | ||
+ | or other group name listed in vzyum grouplist.<br> | ||
+ | (Don't forget the backslash before each doublequote) | ||
+ | |||
+ | <b> -Line 56:</b> | ||
+ | <pre> | ||
+ | comment the line 56: | ||
+ | #exec $YUM $YUM_ARGS $USER_ARGS | ||
+ | </pre> | ||
+ | |||
+ | <b> -Last Line (57):</b><br> | ||
+ | |||
+ | <pre> | ||
+ | add this code: | ||
+ | |||
+ | TMPVZY=/tmp/tmpvzy.$$ | ||
+ | echo $YUM $YUM_ARGS $USER_ARGS > $TMPVZY | ||
+ | sh $TMPVZY | ||
+ | exec rm -f $TMPVZY | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | ===== STEP 10 ===== | ||
Edit file /usr/bin/<b>vzrpm</b> | Edit file /usr/bin/<b>vzrpm</b> | ||
− | Change | + | Change next line: |
Line 272: | Line 383: | ||
− | ===== STEP | + | ===== STEP 11 ===== |
− | If you want your | + | 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 281: | Line 392: | ||
+ | ===== STEP 12 ===== | ||
+ | |||
+ | To share the vzyum cache directory between various [[containers]], <b>after all is set up</b>, edit your /etc/auto.master to include the following: | ||
+ | :<code>/vz/root/{vpsid}/var/cache/yum-cache /etc/auto.vzyum</code> | ||
+ | Include one line for each installed or planned VPS, replacing {vpsid} with the adequate value. | ||
+ | |||
+ | Then, create a /etc/auto.vzyum file with only this line: | ||
+ | :<code>* -bind,ro,nosuid,nodev :/var/cache/yum-cache/&</code> | ||
+ | This file won´t need to be changed, even after you add more containers. | ||
+ | Restart the automounter daemon. | ||
+ | |||
+ | {{Note| Make sure these changes won´t interfere with other automounts you may already have set up. If you don´t already use autofs/automount, it is safe to comment out other settings in auto.master.}} | ||
== TESTING THE NEW CODE == | == TESTING THE NEW CODE == | ||
− | Now you can create your own | + | Now you can create your own template caches from your own templates. |
Let's test it! | Let's test it! | ||
− | + | List all x86_64 templates available: | |
+ | vzpkgls | grep x86_64 | ||
+ | |||
+ | |||
+ | Choose one of them to create the first cache template (this can be time consuming): | ||
− | |||
vzpkgcache -f centos-4-x86_64-minimal | vzpkgcache -f centos-4-x86_64-minimal | ||
− | + | It finishes with complaints about <i>cron.daily</i>, but don't worry about it. | |
− | Now <b>minimal | + | Now <b>minimal</b> cache is created. Confirm if they were created: |
− | |||
vzpkgls -c | vzpkgls -c | ||
− | If you see the cache list, then you can create your first | + | If you see it in the cache list, then you can create your first [[container]]: |
− | |||
vzctl create 200 --ostemplate centos-4-x86_64-minimal | vzctl create 200 --ostemplate centos-4-x86_64-minimal | ||
Line 310: | Line 434: | ||
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 | + | Now start [[container]] 200 previously created: |
vzctl start 200 | vzctl start 200 | ||
Line 316: | Line 440: | ||
Then test also "vzyum" and see if it works. Try to install "nano editor": | Then test also "vzyum" and see if it works. Try to install "nano editor": | ||
− | |||
vzyum 200 install nano | vzyum 200 install nano | ||
− | Try to use vzrpm, to list all rpm's installed in | + | Try to use vzrpm, to list all rpm's installed in [[container]] 200: |
− | |||
vzrpm 200 -qa | vzrpm 200 -qa | ||
Line 331: | Line 453: | ||
If something went wrong, probably you made a mistake in those previous steps. | If something went wrong, probably you made a mistake in those previous steps. | ||
Carefully verify if you did it well, step by step. | Carefully verify if you did it well, step by step. | ||
− | |||
Latest revision as of 19:53, 19 March 2012
Warning: These are not official installation instructions. Do not follow this article, use Quick installation instead!
Please also note that template tools (vzpkg/vzyum) are unsupported and obsoleted. |
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 host with Centos-4, Centos-5, Fedora Core 5, Fedora Core 6, RHEL 4 or any other RPM based system with python 2.2, 2.3 or 2.4 version.
Last Revision: Mcarreira 18:07, 30 January 2011 (UTC)
Contents
THE PROBLEM[edit]
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.
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[edit]
- - A x86_64 computer
- - A host with x86_64 Centos, Fedora Core or RHEL, or other Redhat based systems with python 2.2, 2.3 or 2.4 version (vzrpm is unable to run with python 2.5 version)
- - Yum package installed.
TESTED HOSTS[edit]
- - Centos 4
- - Centos 5
- - Fedora Core 5
- - Fedora Core 6
HOSTS PROBABLY WORKING (not tested)[edit]
- - RHEL 4
- - RHEL 5
HOSTS NOT WORKING[edit]
- - Older distros with yum version less then 2.4, python version less then 2.2, rpm version less then 4.3
- - Fedora 7
- - Fedora 8
- - Or any other system with python 2.5 or above.
SIDE EFFECTS[edit]
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 its own yum cache in the directory
/var/cache/yum-cache
.
This is a consequence from using the modified vzyum.
INSTALL Openvz[edit]
There are two ways to install it:
- A - AUTOMATIC INSTALL (FASTEST)
- B - MANUAL INSTALL - STEP BY STEP
A - AUTOMATIC INSTALL (FASTEST)[edit]
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.
- This process uses a bash script which automates all the hard work made by hand in the manual install. It was successfully tested in several systems.
- If something goes wrong, or if you want to understand the way it works to install a diferent distribution, 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-0.6 and then untar and run the script:
tar xzvf setx86_64-0.6.tar.gz sh setx86_64
Press Enter and some tests are made to know if you can go on with the installation.
If you choose to go on with it, the script will download and patch everything for you.
All the vztemplates metadata available in openvz.org site are also installed and fixed for x86_64 system.
When it finishes with the message "END INSTALL", you can go on reading this document jumping to the undermentioned STEP 11.
B - MANUAL INSTALL -STEP BY STEP[edit]
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 vzpkg*
TWEAKING THE CODE[edit]
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, but Fedora or other distribution with yum, rpm and python (version 2.2, 2.3 or 2.4) installed, may be tried. You only have to change the reference name and version in STEPS 1 to 4.
STEP 1[edit]
Install "vztmpl-centos-4":
yum install vztmpl-centos-4
Note: In setx86_64 script, all the vztemplates available in openvz.org site are downloaded and used to build x86_64 templates, ready to be used. |
STEP 2[edit]
The template installed is a i386 template. So, we need to create a x86_64 template from the i386. We only have to replace i386 references with x86_64 in all files.
cd /vz/template/centos/4/
cp -a i386 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.
You can do the same procedure to other distro templates.
STEP 3[edit]
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
Note: 1) With these changes, vzyum won´t be able to use a common cache directory to all containers as it used to do. Each container will have its 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. 2) To set up a common cache directory, you can use the autofs/automounter daemon together with Bind_mounts as described in step 12. Using a shared cache may save a lot of network traffic when installing new VPSs. |
STEP 4[edit]
Verify the host rpm version:
rpm --version
In Centos-4 rpm is version 4.3.
Edit this file /vz/template/centos/4/x86_64/config/rpm, and you will see the number 43.
When the host distro is the same of the template guest, everything would be correct, and we don't need doing anything.
But if we have a different guest template, we might have to correct the values.
We have to change the number inside /vz/template/distro/version/x86_64/config/rpm
according to the rpm version of the host system.
If rpm version is 4.4 the number would be 44.
If rpm version is 4.3 the number would be 43.
STEP 5[edit]
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")
This avoids the undesirable update of special MAKEDEV-swsoft to the real MAKEDEV from the distro yum repository during a vzyum action.
STEP 6[edit]
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
In Centos-4 version python is 2.3. So, we must replace rpmmodule.so from vzrpm43-python to the 64 bit module that rpm-python-x86_64 provides.
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
In other Operating Systems or other versions, you must verify which python version is installed in the host system. Depending on that, the 32 bit files to be replaced are different (read the setx86_64 script, line 334 to line 358, to understand how it is done).
Note:
Someone reported the note below, but the tests I made, didn't confirm it was really needed. Everything worked flawless without it.
Nevertheless, if you find some problems, try the workaround described below:
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 7[edit]
Edit the file /usr/share/vzpkg/cache-os
Change the next lines:
-Line 97:
Note: ve-vps.basic.conf-sample is now renamed ve-basic.conf-sample |
(see bug 1694 )
change: VECFGSAMPLE=$VECFGDIR/ve-vps.basic.conf-sample to: VECFGSAMPLE=$VECFGDIR/ve-basic.conf-sample append: if ! [ -f "$VECFGSAMPLE" ]; then VECFGSAMPLE="$VECGFDIR/ve-vps.basic.conf-sample"; fi
-Line 136:
change: --vps=$VEID check-update to: check-update
-Line 154:
append: mkdir -p $VE_ROOT/var/lib/yum/ || abort "Can't create /var/lib/yum"
-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 8[edit]
Edit the file /usr/share/vzpkg/functions
Change the next lines:
-Line 20:
change: VZLIB_SCRIPTDIR=/usr/lib/vzctl/scripts to: VZLIB_SCRIPTDIR=/usr/lib64/vzctl/scripts
-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 9[edit]
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"
The next piece of code fixed the vzyum bug described in bugzilla #488.
It was impossible to install a package group with spaces in his name.
Now we can use e.g. vzyum groupinstall \"GNOME Desktop Environment\",
or other group name listed in vzyum grouplist.
(Don't forget the backslash before each doublequote)
-Line 56:
comment the line 56: #exec $YUM $YUM_ARGS $USER_ARGS
-Last Line (57):
add this code: TMPVZY=/tmp/tmpvzy.$$ echo $YUM $YUM_ARGS $USER_ARGS > $TMPVZY sh $TMPVZY exec rm -f $TMPVZY
STEP 10[edit]
Edit file /usr/bin/vzrpm Change 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 11[edit]
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
STEP 12[edit]
To share the vzyum cache directory between various containers, after all is set up, edit your /etc/auto.master to include the following:
/vz/root/{vpsid}/var/cache/yum-cache /etc/auto.vzyum
Include one line for each installed or planned VPS, replacing {vpsid} with the adequate value.
Then, create a /etc/auto.vzyum file with only this line:
* -bind,ro,nosuid,nodev :/var/cache/yum-cache/&
This file won´t need to be changed, even after you add more containers. Restart the automounter daemon.
Note: Make sure these changes won´t interfere with other automounts you may already have set up. If you don´t already use autofs/automount, it is safe to comment out other settings in auto.master. |
TESTING THE NEW CODE[edit]
Now you can create your own template caches from your own templates. Let's test it!
List all x86_64 templates available:
vzpkgls | grep x86_64
Choose one of them to create the first cache template (this can be time consuming):
vzpkgcache -f centos-4-x86_64-minimal
It finishes with complaints about cron.daily, but don't worry about it.
Now minimal cache is created. Confirm if they were created:
vzpkgls -c
If you see it in 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.