Virtuozzo / Linux Reference

From JCWiki
Jump to navigation Jump to search

Migrating Templates

One nice feature VZ offers is the ability to run a virtual environment (VE or CT as it's now called) based on a particular ditribution on a host which may or may not share the same distribution. For instance, you could run a CT running Ubuntu while the host machine (Hardware Node or HN) is running CentOS. This is accomplished via the use of OS templates. As long as the HN contains the OS template on which a particular CT relies, it will run there. As such, if you want to move a VE from one HN to another, you will need to make sure the OS template exists there.

Modern versions of VZ (>= 4.x) will check for and automatically move the OS template over to the host as you're (vz)migrating the CT over to a new HN. However we like to make sure the template is in place prior to moving the CT.

The first step is to see if the template exists on the host. To see OS templates installed:

2.x (shows OS and application templates):

# vzpkgls
mod_ssl-rh9 20040624
mysql-rh9 20030814 20050412
openwebmail-rh9 20050427
php-rh9 20050506
phpBB-rh9 20041229
postgresql-rh9 20050719
sl-webalizer-rh9 20040119
spamassassin-rh9 20040127
tomcat-rh9 20040524
usermin-rh9 20040116

>= 3.x (shows just OS templates, run without -O to see application as well):

# vzpkg list -O
ubuntu-10.04-x86                   2010-06-01 11:39:05
ubuntu-11.04-x86                   2011-06-22 14:23:59
ubuntu-9.10-x86                    2010-03-11 17:39:51
centos-5-x86                       2010-03-11 17:12:27
debian-5.0-x86                     2010-03-11 17:33:34

To get a template from one HN to another, it simply needs to be rsync'd over to the target HN. All templates are located in /vz/template:

# ls /vz/template/
ColdFusion-fc1  jre-fc1               openwebmail-fc1     sl-webalizer-fc1
ColdFusion-fc2  jre-fc2               openwebmail-fc2     sl-webalizer-fc2
ColdFusion-rh9  jre-rh9               openwebmail-rh9     sl-webalizer-rh9
PostNuke-fc1    jre-suse92            openwebmail-suse92  spamassassin-fc1
PostNuke-fc2    jrun                  php-deb31           spamassassin-fc2
PostNuke-rh9    mailman-deb31         php-fc1             spamassassin-rh9
analog-fc1      mailman-fc1           php-fc2             spamassassin-suse92
analog-fc2      mailman-fc2           php-rh9             suse-9.2
analog-rh9      mailman-rh9           php-suse92          tomcat-fc1
awstats-fc1     mailman-suse92        phpBB-fc1           tomcat-fc2
awstats-rh9     mod_frontpage-fc1     phpBB-fc2           tomcat-rh9
bbClone-fc1     mod_frontpage-fc2     phpBB-rh9           tomcat-suse92
bbClone-fc2     mod_frontpage-rh9     phpmyadmin-deb31    urchin-fc1
bbClone-rh9     mod_frontpage-suse92  postgresql-deb31    usermin-fc1
conf            mod_perl-deb31        postgresql-fc1      usermin-fc2
debian-3.1      mod_perl-fc1          postgresql-fc2      usermin-rh9
devel-deb31     mod_perl-fc2          postgresql-rh9      uw-imap-fc1
devel-fc2       mod_perl-rh9          postgresql-suse92   uw-imap-fc2
devel-suse92    mod_perl-suse92       proftpd-deb31       uw-imap-rh9
fedora-core-1   mod_ssl-fc1           proftpd-fc1         vzredhat-7.3
fedora-core-2   mod_ssl-fc2           proftpd-fc2         vzredhat-8.0
jdk-deb31       mod_ssl-rh9           proftpd-rh9         webalizer-suse92
jdk-fc1         mysql-deb31           proftpd-suse92      webmin-fc1
jdk-fc2         mysql-fc1             redhat-7.2          webmin-fc2
jdk-rh9         mysql-fc2             redhat-9            webmin-rh9
jdk-suse92      mysql-rh9             redhat-as3-minimal
jre-deb31       mysql-suse92          redhat-devel-9

What we see here are the base OS templates: redhat-9, fedora-core-1 and supporting application templates: postgresql-rh9, mailman-rh9, jdk-fc1, mod_ssl-fc1. So if you wanted to copy over all of redhat 9 you'd need to copy the contents of:

# ls -d /vz/template/*rh9*
/vz/template/ColdFusion-rh9  /vz/template/mod_frontpage-rh9  /vz/template/proftpd-rh9
/vz/template/PostNuke-rh9    /vz/template/mod_perl-rh9       /vz/template/sl-webalizer-rh9
/vz/template/analog-rh9      /vz/template/mod_ssl-rh9        /vz/template/spamassassin-rh9
/vz/template/awstats-rh9     /vz/template/mysql-rh9          /vz/template/tomcat-rh9
/vz/template/bbClone-rh9     /vz/template/openwebmail-rh9    /vz/template/usermin-rh9
/vz/template/jdk-rh9         /vz/template/php-rh9            /vz/template/uw-imap-rh9
/vz/template/jre-rh9         /vz/template/phpBB-rh9          /vz/template/webmin-rh9
/vz/template/mailman-rh9     /vz/template/postgresql-rh9

# ls -d /vz/template/*redhat-9*
/vz/template/redhat-9

It's rsync'd over in this fashion:

rsync -av /vz/template/

If the template doesn't exist on the target, this is very simple.