Creating a Local Repository
Along with using pre-configured repositories, you can create local repositories and configure for handling packages for your EZ templates. Organizing your own local repositories results in less bandwidth consumption and rapid software updates to Containers. You may also want to build a local repository if OS vendors or third-party software developers set up repositories that are not compatible with the vzpkg tool.
Note: The vzpkg tool supports all the repositories that can be used by the yum (version 2.4.0 and higher) and apt utilities. For detailed information on these utilities, see their man pages.
The process of setting up a local repository includes the following main steps:
- Obtaining software packages comprising the given Linux distribution. The easiest way of doing it is to copy the necessary packages from your distribution disks or the OS vendor's website.
- Creating the metadata repository from a set of the copied software packages with the
createrepo utility. This step can be omitted if you are going to create a repository which will be a mirror of a public repository. - Making your repository accessible for Containers users. You can let Container users access your repository in one of the following ways:
- By using the
http protocol. In this case the repository should represent a website containing software packages for the EZ template. - By using the
ftp protocol. In this case the repository should represent an FTP site containing software packages for the EZ template. - By using the
file protocol. In this case the repository should represent a directory path (e.g. on your local server) containing software packages for the EZ template.
While the first two protocols allow you to remotely (i.e. from servers located in other networks) access the created repository, the third one can be used within your local server only.
Example 1: Creating a Local Repository for Fedora 16
Let us assume that you want to build a local package repository for the Fedora 16 OS EZ template where the RPM packages for Fedora 16 will be downloaded and stored. The repository will be used by servers from both your local and other networks, and it will allow downloading packages through the http protocol. In our example, we presume the following:
To create a local repository for Fedora 16, do the following:
- Install the
fedora-core-16-x86 OS EZ template (if it is not already installed):# vzpkg install template fedora-core-16-x86-tmpl-4.0.0-17.sws oft.noarch.rpm
Preparing... ################################ [100%]
1:fedora-core-16-x86-tmpl ################################ [100%]
- Change to the
/vz/root/101/var/www/html directory, and create two subdirectories within it:Note: You can also log in to Container 101 and perform the operations described in Steps 2-8 from inside the Container. In this case your working directory inside Container 101 must be /var/www/html , and you will need to install the createrepo package inside the Container and grant the Container access to the CD-ROM drive on the server.
- Copy all the packages comprising the Fedora 16 distribution (e.g., from your Fedora distribution disks) to the
download/fedora/16/i386/os/Fedora/RPMS directory on the server. - Get the updates for Fedora 16, and put them to the
download/fedora-core/updates/16/i386 directory on the server. - Install the
createrepo package on the server, for example:# rpm -Uhv createrepo-0.4.3-1.2.el4.rf.noarch.rpm
Preparing... #################################### [100%]
1:createrepo #################################### [100%]
- Change to the
/vz/root/101/var/www/html directory and create the following metadata repositories:Creating the package metadata repository may take some time depending on the speed of your processor and hard disk drive.
- Create a directory for storing mirror site lists. In our case, the lists will be kept in the
/vz/root/101/var/www/html/download/mirrors directory:# mkdir -p download/mirrors
- Create the mirror list files and set the path to your local repository. For example, you can do this as follows:
The aforementioned commands create the fedora-core-16 and updates-released-fc16 files in the /vz/root/101/var/www/html/download/mirrors directory on the server and add the http://123.145.145.123/download/fedora/16/i386/os/Fedora/RPMS and http://123.145.145.123/download/fedora/updates/16/i386 strings to them, respectively.
- Open the
/vz/template/conf/vztt/url.map file on the server for editing (e.g., by using vi ), and change the value of the $FC_SERVER variable as follows:$FC_SERVER http://123.145.145.123
- Grant the
apache user and the apache group access to the created repositories inside Container 101 by executing the following command on the server:# prlctl exec 101 chown -R apache.apache /var/www/html/download
Example 2: Accessing the Repository via the file protocol
Once you set up a local repository by following the instructions in the example above, you can start using the vzpkg tool to obtain RPM packages for the Fedora 16 EZ template from this repository. You can connect to these repositories via the http protocol from both remote and local servers.
You can further speed up the process of distributing RPM packages across your repository for those Containers that reside on your local server (that is, on the server where the repositories are stored). To do this, configure your system to use the file protocol instead of http to connect to your repositories:
- Open the
/vz/template/fedora/16/x86/config/os/default/mirrorlist file on the server and comment the strings containing $FC_SERVER :#$FC_SERVER/download/mirrors/fedora-core-16
#$FC_SERVER/download/mirrors/updates-released-fc16
- Execute the following commands to create the repository files:
- To create the
/vz/template/fedora/16/x86/config/os/default/repositories file on the server and to make it point to the Fedora 16 base RPM packages from your local repository:# echo 'file:///vz/root/101/var/www/html/download/fedora/16/i386/os/Fedora/RPMS' >> /vz/template/fedora/16/x86/config/os/default/repositories
- To create the
/vz/template/fedora/16/x86/config/os/default/repositories file on the server and to make it point to the updated versions of the Fedora 16 RPM packages from your local repository:# echo 'file:///vz/root/101/var/www/html/download/fedora/updates/16/i386' >> /vz/template/fedora/16/x86/config/os/default/repositories
|