Previous page

Next page

Locate page in Contents

Print this page

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:

  1. 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.
  2. 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.
  3. 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:

  • The package repository will be located inside Container 101. You can use any OS template to base the Container on.

    Note: We recommend that you always place your local repositories inside separate Containers not to compromise the server security. In particular, it is of significant importance if you are going to provide access to your repositories through the http and ftp protocols.

  • Container 101 is started. It has the IP address of 123.145.145.123 and can be accessed from other networks.
  • The apache web server is running inside Container 101 and the default document root for apache is /var/www/html, i.e. the apache web server stores its sites in the /vz/root/101/var/www/html directory on the server.
  • The apache user and group inside Container 101 are apache.

To create a local repository for Fedora 16, do the following:

  1. 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.swsoft.noarch.rpm

    Preparing... ################################ [100%]

    1:fedora-core-16-x86-tmpl ################################ [100%]

  2. 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.

    • The subdirectory where the base RPM packages for Fedora 16 will be stored:

      # mkdir -p download/fedora-core/16/i386/os/Fedora/RPMS

    • The subdirectory where the updated versions of RPM packages for Fedora 16 will be stored:

      # mkdir -p download/fedora-core/updates/16/i386

  3. 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.
  4. Get the updates for Fedora 16, and put them to the download/fedora-core/updates/16/i386 directory on the server.
  5. 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%]

  6. Change to the /vz/root/101/var/www/html directory and create the following metadata repositories:
    • For the Fedora 16 base RPM packages:

      # createrepo download/fedora/16/i386/os

    • For the updated versions of the Fedora 16 RPM packages:

      # createrepo download/fedora-core/updates/16/i386

    Creating the package metadata repository may take some time depending on the speed of your processor and hard disk drive.

  7. 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

  8. Create the mirror list files and set the path to your local repository. For example, you can do this as follows:
    • For the Fedora 16 base RPM packages:

      # echo 'http://123.145.145.123/download/fedora/16/i386/os/' >> download/mirrors/fedora-core-16

    • For the updated versions of the Fedora 16 RPM packages:

      # echo 'http://123.145.145.123/download/fedora/updates/16/i386' >> download/mirrors/updates-released-fc16

    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.

  9. 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

  10. 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:

  1. 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

  2. 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