Virtuozzo 7 Technical Preview - Virtual Machines Templates

Virtuozzo 7 Technical Preview - Virtual Machines Templates

Chapter 2. Templates Overview

A template in Virtuozzo 7 is a set of application and configuration files installed on a server in such a way as to be usable by any container. Virtuozzo provides tools for creating templates, installing and removing them on/from servers, adding them to containers, and so on.

Using templates, you can:

• Securely share RAM among similar applications running in different containers to save hundreds of megabytes of memory

• Install applications and patches simultaneously in many containers

• Use different versions of an application on different containers (for example, perform an upgrade only in certain containers)

There are two types of templates in Virtuozzo. These are OS templates and application templates.

An OS template is an operating system and the standard set of applications to be found right after the installation. Virtuozzo uses OS templates to create new containers with a pre-installed operating system. An application template is a set of repackaged software packages optionally accompanied with configuration scripts. Virtuozzo uses application templates to add extra software to existing containers.

For example, you can create a container on the basis of the redhat OS template and add the MySQL application to it with the help of the mysql template.

In Virtuozzo, you can perform the following operations on templates:

• create new application templates

• list the templates currently installed on the Virtuozzo server

• install templates on and remove them from the Virtuozzo server

• add templates to containers

• remove templates from the Virtuozzo server and from containers

• migrate templates from one Virtuozzo server to another

All these operations are described in detail in

Chapter 3, Managing EZ Templates on page 11.

Note: The current version of Virtuozzo does not support using templates in virtual machines.

2.1. EZ Templates Basics

All OS and application EZ templates are defined by the following features:

• EZ templates do not carry the necessary package files inside themselves. They contain only the information about what packages should be installed on the Virtuozzo server to make the templates fully operational and from what network repository these packages should be downloaded.

Note: For the sake of brevity, we will be saying throughout this guide that packages are included in

EZ templates, which actually means that EZ templates contain the information on the corresponding packages without carrying the packages themselves.

• The dependencies of software packages included in an EZ template are automatically resolved during the packages installation on the Virtuozzo server. So, if the specified packages require other

Chapter 2. Templates Overview packages to be installed, these packages are also downloaded from the repository and installed on the server. In case a package has requirements that conflict with existing software on the server or any dependencies for the package being installed cannot be satisfied, the package installation process fails without making any changes to the system.

• The EZ templates technology allows you to use the original OS and application vendor’s packages and to receive the updated packages from a central repository right after their release.

One of the basic concepts in the EZ template technology is the concept of repository where software packages for the given EZ template are stored. A repository is a prepared directory or website containing the packages and index files for Linux operating systems and/or any of their applications. An example of such a repository is the repository located at the http://mirrors.usc.edu/pub/linux/distributions/fedora/ website and storing software packages for Fedora Core releases. Using repositories gives you the following advantages:

• Software packages included in the given EZ template do not contain versions, but only names (e.g.

bash

, crontabs

). So, you always update any package included in the EZ template to its latest version available in the repository.

• As a result of the fact that a list of packages does not provide their versions, EZ templates do not have versions either (e.g. centos-6-x86_64

). Thus, you install any EZ template on the Virtuozzo server only once and, after that, use the installed template to update the packages inside any container where it is applied.

• You can create several OS EZ template sets for one and the same Linux operating system. Any OS

EZ template you are provided with has the default packages set included in it and is called the base

OS EZ template. However, you can make your own OS EZ template sets (the so-called non-base OS

EZ template sets) which may differ from the corresponding base template:

• in the number of packages included in these EZ template sets

• in the number and location of repositories to be used for these EZ template sets

• in the number and kind of scripts to be executed on different EZ template sets life cycle stages

Non-base OS EZ template sets must have their own names and are created by appending a random identifier to the base OS EZ template name. For example, if you wish your container to run Red

Hat Enterprise Linux 5 and to function as a Linux-based server only, you can create the centos-6x86_64-server

OS EZ template set and include only those packages in it that are needed for performing main server tasks. So, you can specify packages to be used for setting up file and print sharing and exclude all the packages for graphical interfaces (GNOME and KDE).

Virtuozzo provides you with a vzpkg

tool allowing you to automatically locate and obtain the correct packages for your EZ templates from one or several package repositories. The packages are downloaded from the repository and installed on the Virtuozzo server in one of the following cases:

• when creating a cache for an OS EZ template

• when updating an existing OS EZ template cache (if there are new packages available in the repository)

• when adding an application EZ template or package to the first container

• when updating EZ templates or software packages inside a destination container

Note: For details on how to manage software package repositories, see Section 3.2, “Setting Up

Repositories and Proxy Servers for EZ Templates” on page 16.

7

Chapter 2. Templates Overview

2.2. EZ Template Directory Structure

All EZ templates and the software packages included in them and installed on the Virtuozzo server are located in the so-called template area the path to which is set as the value of the

TEMPLATE

variable in the

/etc/vz/vz.conf

file. By default, the

/vz/template

directory is used. The template area includes two main subdirectories:

• The cache subdirectory where the tar archive of the potential private area of a container based on the corresponding OS EZ template is stored. The tar archive is created during the OS EZ template caching. Keep in mind that the OS EZ template should be obligatorily cached before you can start creating containers on its basis.

• The template directory having the name of

<os_name>/<os_version>/<arch>

where:

<os_name>

denotes the name of the Linux distribution for which the OS EZ template is created (e.g.

redhat

, centos

).

<os_version>

is the version of the Linux distribution specified as

<os_name>

(e.g.,

6

or

7

).

<arch>

denotes the microprocessor architecture where the OS EZ template is to be run ( x86

, x86-64

, ia64

).

For example, after installing the 32-bit version of the Centos 6 EZ template, the

/vz/template/ centos/6/x86

directory on the server is created.

In its turn, the

<arch>

directory contains the following subdirectories and areas:

• The template configuration subdirectory including:

• The config/os/default

directory where the appropriate configuration files for the base OS EZ template are stored.

• The config/os/_<setname>

directory where the appropriate configuration files for non-base OS EZ templates, if any, are stored.

• The config/app/<app_name>/default

directory where the appropriate configuration files for the base application EZ template are stored. This directory is created if at least one application EZ template for the given OS EZ template is installed on the Virtuozzo server.

• The config/app/<app_name>/_<setname>

directory where the appropriate configuration files for non-base application EZ templates, if any, are stored.

• The packages area containing a number of software packages downloaded from the repository and installed on the Virtuozzo server. An installed package has the following structure:

<name>-<epoch>:<version>-<release>.<arch> where:

<name>

is the package name.

<epoch>

denotes the package epoch.

<version>

indicates the package version.

<release>

is the package release.

<arch>

denotes the microprocessor architecture where the package is to be used.

• One or several subdirectories containing the packages comprising the corresponding OS EZ template.

The directories have the following names:

• base<N>

for the base OS template

8

Chapter 2. Templates Overview

9

<setname>N

for the non-base OS template with the name of <setname>, if any

<app_name>N

for the base application template

<app_name>-<setname>N

for the application template with the name of

<setname>

, if any

N

denotes the index number of the URL specified in the repositories/mirrorlist

file (see the information on the repositories/mirrorlist

file below).

As has been mentioned above, the configuration directory (i.e.

/<template_area>/<template_directory>/config

) contains a number of subdirectories storing

EZ templates-related configuration files. The contents of these subdirectories can vary depending on whether it is a base OS EZ template or a non-base one and on the EZ template type (OS or application template). The most important configuration files are listed below:

• Data files:

• packages

: contains a list of software packages names included in the corresponding EZ template.

• package_manager

: specifies the packaging system used to handle the EZ template.

• repositories

: a list of repositories where the packages comprising the EZ template are stored.

• mirrorlist

: one or several URLs to the file containing a list of repositories from where the packages comprising the EZ template are to be downloaded.

• distribution

: the name of the Linux distribution for which the EZ template is created. This file should be absent for application EZ templates.

• summary

: brief information on the EZ template.

• description

: detailed information on the EZ template. As distinct from the summary file, it can contain additional data relevant for the EZ template.

• environment

: a list of environment variables set in the form of

key=value

.

• Scripts:

• pre-cache

: this script is executed before installing the packages included in the EZ template on the

Virtuozzo server.

• post-cache

: this script is executed after installing the packages included in the EZ template on the

Virtuozzo server.

• pre-install

: this script is executed before adding the EZ template to or installing the package inside the container.

• post-install

: this script is executed after adding the EZ template to or installing the package inside the container.

• pre-upgrade

: this script is executed before updating the packages inside the container.

• post-upgrade

: this script is executed updating the packages inside the container.

• pre-remove

: this script is executed before removing the application EZ template/package from the container.

• post-remove

: this script is executed after removing the application EZ template/package from the container.

• Document files: one or several files with arbitrary names containing the information on the EZ template

(e.g.

README

).

Note: Detailed information on the files contained in the OS template configuration directory is provided in the Virtuozzo 7 Command Line Reference Guide.

While working with EZ template configuration files, keep in mind the following:

• The packages file should be specified for all EZ templates.

Chapter 2. Templates Overview

• The packages

, package_manager

, and repositories/mirrorlist

files should be specified for all base OS EZ templates.

• The package_manager

and distribution

files should be specified for all base OS EZ templates and absent for non-base OS EZ templates and all application EZ templates.

The information from the repositories/mirrorlist

files created for non-base OS and all application

EZ templates is added to that in the repositories/mirrorlist

files for the base OS EZ template.

2.3. Differences Between OS and Application EZ Templates

Listed below are the major differences between OS and application EZ templates:

• OS templates are used to create new containers, whereas application templates provide additional software for already created containers.

• OS templates may and usually do use action scripts, whereas application templates cannot use action scripts in the current version of Virtuozzo.

• You may define a list of compatible templates and a list of required templates for application templates.

2.4. EZ Template Life Cycle

An EZ template has the following development stages:

1. Any EZ template should be first installed on the server. The vzpkg install template

command enables you to install OS and application EZ templates on the server.

2. The EZ template should be cached by using the vzpkg create cache

command. This step is required for OS EZ templates only. As a result of the vzpkg create cache

execution, the necessary packages included in the OS EZ template are downloaded from the network repository, installed in the

/vz/template/<os_name>/_<os_version>

directory on the server, and a gzipped tarball for the OS

EZ template is created and put to the

/vz/template/cache

directory.

3. Either a new container is created on the basis of the cached OS EZ template with the prlctl create command or an application EZ template is added to any number of containers by using the vzpkg install

command. In the latter case, the necessary application files are downloaded from the network repository, installed on the server, and then added to the container private area.

4. An obsolete EZ template applied to the corresponding container can be updated by using the vzpkg update

command.

5. Any EZ template excluding OS EZ templates can be removed from the container with the vzpkg remove

command.

6. An EZ template that is not used by any container may be completely removed from the server with the vzpkg remove template

command.

10

Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement

Table of contents