Virtuozzo / Linux Reference: Difference between revisions
No edit summary |
No edit summary |
||
Line 221: | Line 221: | ||
= getting help = | = getting help = | ||
= adding new templates = |
Revision as of 18:21, 22 January 2013
Updating VZ
Update Virtuozzo to version 4.0.0 Apply minor updates for Virtuozzo 3.0.0
... When you get to the last screen, you will be given an option to
( ) Automatically reboot after update (*) Reboot later manually
make sure you choose to reboot later.
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 CT 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
All template files are located:
# 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
To get a template from one HN to another, it simply needs to be rsync'd over to the target HN. It's rsync'd over in this fashion:
rsync -av -e ssh /vz/template/redhat-9 root@10.1.4.65:/vz/template rsync -av -e ssh /vz/template/*rh9 root@10.1.4.65:/vz/template
Newer (>= 3.x) VZ employs "EZ" templates which are organized a little differently:
# ls /vz/template/ cache CmdTool.log debian redhat-as3-minimal-20080630.tar.gz vc centos conf redhat-as3-minimal ubuntu # ls /vz/template/ubuntu/ 10.04 11.04 9.10 # ls /vz/template/ubuntu/10.04/ x86 # ls /vz/template/ubuntu/10.04/x86/ aap_1.091-1_all aap-doc_1.091-1_all adduser_3.112ubuntu1_all anacron_2.3-13.1ubuntu11_i386 apache2_2.2.14-5ubuntu8.2_i386 apache2_2.2.14-5ubuntu8.4_i386 apache2_2.2.14-5ubuntu8.6_i386 apache2_2.2.14-5ubuntu8.7_i386 apache2_2.2.14-5ubuntu8.8_i386 apache2_2.2.14-5ubuntu8.9_i386 <...snip> # ls /vz/template/cache/ centos-5-x86.tar.gz suse-11.3-x86.tar.gz ubuntu-9.10-x86.tar.gz debian-5.0-x86.tar.gz ubuntu-10.04-x86.tar.gz fedora-core-14-x86.tar.gz ubuntu-11.04-x86.tar.gz
So what we see is the entire OS and all applications are in 1 directory, and organized by distribution and release version. So to move Ubuntu 10.04:
rsync -av -e ssh /vz/template/ubuntu/10.04 root@10.1.4.69:/vz/template/ubuntu
and you also need to move the cache:
rsync -av -e ssh /vz/template/cache/ubuntu-10.04-x86.tar.gz root@10.1.4.69:/vz/template/cache/
Once the transfer is complete, you will be able to run vzpkgls or vzpkg list -O and see the template(s) listed on the target HN.
So far, this all supposes template doesn't exist on the target- very simple, just copy it over. If the template exists already on the target HN, this requires closer inspection. With older templates, simply moving over the templates would be the end of it- you see the version listed when you do a vzplgls:
mysql-rh9 20030814 20050412
this means there are 2 versions of the mysql package for RH9: 20030814 and 20050412 As an aside, you can't copy over just 1 of them, but if you rsync'd over the mysql-rh9 directory, you'd see 20030814 and 20050412 on the target HN. As long as the versions match up, you're good to go.
With EZ templates, the versions are not as easy to decipher. When you look at the vzpkg list output, that simply tells you when a cache was created. A cache is simply a snapshot of all the data needed for the latest versions of the OS and it's applications at the time the cache was created. It is a date, and thus tells you nothing about the versions within. So for instance, if you had a cache for Ubuntu 10.04 from 2007 and you ran vzpkg create cache ubuntu-10.04-x86 it would re-download the latest version of apache, mysql and so on. And any subsequent ubuntu 10.04 CT's created thereafter would use those newer versions, whereas older CT's based on 10.04 would use older templates. You can see how this works by looking at the files under:
# ls /vz/template/ubuntu/10.04/x86/ aap_1.091-1_all aap-doc_1.091-1_all adduser_3.112ubuntu1_all anacron_2.3-13.1ubuntu11_i386 apache2_2.2.14-5ubuntu8.2_i386 apache2_2.2.14-5ubuntu8.4_i386 apache2_2.2.14-5ubuntu8.6_i386 apache2_2.2.14-5ubuntu8.7_i386 apache2_2.2.14-5ubuntu8.8_i386 apache2_2.2.14-5ubuntu8.9_i386 <...snip>
You can see that this template has in it 6 different versions of apache2. This means that this template was merged with other 10.04 templates and/or it has been cached a few times, each time a new apache was available. The unfortunate thing is it's almost impossible to know which CT's are using which version of apache so it's hard to try to prune this down and remove unwanted/unneeded applications.
So, if you see another HN has Ubuntu 10.04 on it, you need to see/confirm that it has all the exact files your CT needs. You can run a test rsync to see what would be transferred (what's missing):
rsync -avn --stats -e ssh /vz/template/ubuntu/10.04 root@10.1.4.69:/vz/template/ubuntu
Based on the amount of data you get back from the rsync, you will be able to decide whether or not to remove the -n and allow the full transfer to go through. The downside to doing the transfer is the situation described above- you've permanently joined these templates and now you may have 10 versions of apache on the target HN. There's one other potential pitfall to this kind of merging- it will also potentially copy over shared files, for which there is no particular version, most of which are in /vz/template/ubuntu/10.04/x86/config:
cat /vz/template/ubuntu/10.04/x86/config/os/default/repositories /vz/template/ubuntu/10.04/x86/config/os/default/repositories
Here are some specific things to look out for. Case: copying centos-5 on virt19 to virt12. We dumped the rsync output to a file so we could inspect:
[root@virt19 /vz/template]# rsync -an -e ssh /vz/template/centos/ root@10.1.4.62:/vz/template/centos/ > v12_c5
(note, that can be dangerous, better to add on full path /vz/template/centos/5)
So in the output file we see things like:
x86/base0/cachecookie x86/base0/primary.xml.gz x86/base0/primary.xml.gz.sqlite x86/base0/repomd.xml x86/base1/cachecookie x86/base1/filelists.xml.gz x86/base1/filelists.xml.gz.sqlite x86/base1/primary.xml.gz x86/base1/primary.xml.gz.sqlite x86/base1/repomd.xml x86/base2/cachecookie
Which make us nervous cause those are not versioned files, i.e.:
5/x86/MAKEDEV-3.23-1.2.i386/usr/sbin/mksock
So those files will replace existing files on v12 rather than the case of the latter where it's likely being added. So caution should be given and deference to whichever version is newer (which rsync should take care of, but that will depend on the date each file was created and perhaps not the actual data within).
If we look further in the file we see:
x86/psa-appvault-moodle-1.8-8202920080409011254.noarch/usr/local/psa/var/cgitory/moodle-1.
9/htdocs/lib/editor/htmlarea/plugins/TableOperations/img/cell-split.gif
and other files looking like:
5/x86/plesk-base-9.0.1-cos5.build90090127.18.i586/etc/sw/keys/info
Which means plesk is here. We don't need plesk on v12 (the CT moving over doesn't use it) so we rerun the rsync and exclude it:
[root@virt19 /vz/template]# rsync -an -e ssh --exclude="plesk*" --exclude="psa*" /vz/template/centos/ root@10.1.4.62:/vz/template/centos/ > v12_c5
and now it's much smaller:
[root@virt19 /vz/template]# cat v12_c5|wc -l 97104
Before running with excludes it was:
[root@virt19 /vz/template]# cat v12_c5|wc -l 238238
So again, look at what you're doing. Generally, combining templates is fine however.
If you're happy with the merge, run the rsync again without the "-n" to let it actually do the transfer.
Once done, don't forget to add the new template to the HN in Management -> Reference -> Templates