Book Image

Troubleshooting Ubuntu Server

By : Skanda Bhargav
Book Image

Troubleshooting Ubuntu Server

By: Skanda Bhargav

Overview of this book

Table of Contents (16 chapters)
Troubleshooting Ubuntu Server
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Creating a repository mirror


When there are multiple machines on your network, it makes sense to have local repository mirrored from the remote repository. The main advantage is the reduced bandwidth usage by limiting the number of machines connecting to the remote repositories and downloading huge files associated with packages. Only one system will connect to the remote repository and mirror the contents to the local system. Another advantage is that when all the machines are pointed to this repository the packages in each one of them will be of the same version.

There are three tasks that we will need to perform in order to get the local mirror repository working. First, set up the mirror on one of the machines, and then configure the machine to mirror only certain repositories. This will limit the amount of data downloaded and also keep the unwanted packages away. The third task is to point the local clients to this newly created repository so that they use only this repository to upgrade the packages.

Setting up a mirror machine

You can set up the mirroring in two ways: rsync and apt-mirror. Traditionally, rsync was being used to synchronize the local and remote files. Now, admins prefer the apt-mirror command, at least for the initial mirroring setup. First, install the apt-mirror package using the following command:

sudo apt-get install apt-mirror

Now, try running the apt-mirror command. Don't be surprised by the sheer size of download data it asks to be downloaded. Now, let's limit the repositories that we want and also set up other configuration for the mirror.

Configuring the /etc/apt/mirror.list file

You will be required to configure the /etc/apt/mirror.list file to set up the desired repositories you wish to mirror. The file looks like this:

The first section has the default configuration related to the storage of downloaded files, base mirror path, cleanscript, concurrent threads to be run when downloading, and others. By default, the files are copied to the /var/spool/apt-mirror path. The admin should ensure there is enough disk space to store the files. If all the systems are on the same architecture, then let defaultarch be same as default, which is set to <running host architecture>. If you are mirroring the repositories for any other architecture, then you need to set it explicitly. Next, comment out the lines related to the repositories in the second section. Have only those repositories active that you need and comment out the others as keeping all active will mean you are downloading a very large amount of data, somewhere close to 50 GB maybe.

After you have made the changes, run the apt-mirror command to mirror the remote repository to the local one. Once completed, you can see the directory listing similar to the one you observe on the remote servers.

Using the local mirror

This is an important task if you want to make sure the local mirror is completely functional. In each of the client machines on your network, change the repository URL to access the locally set up mirror. You will need to point to the IP of the machine acting as the mirror. Open the /etc/apt/sources.list configuration file and make the following changes:

deb http://192.168.1.8/mirror/ubuntu trusty main restricted

We are all set to use the mirror as the repository for all our local client machines.