Replacing apt-mirror
apt-cacher is a utility for Debian-like distributions using apt as a package installer. It caches the files that the user downloads off. mirrors of updates and the next request returns them from its cache.
What are the advantages of apt-cacher`a before apt-mirrorʻom?
First, in saving traffic. Why download the same package several times if your colleague has already downloaded it? Thus, the traffic savings increase in proportion to the number of people in the office using * buntu.
Secondly, in saving space on the railway server, on which apt-cacher is installed. After all, why keep 22 GB of packages on the railway, if one uses a maximum of 10 GB?
Thirdly, in the speed of receiving updates. How many times do you update your mirror updates? 1 per day? Apt-cacher allows you to receive updates as they appear on the off. the mirror. When a user makes an update request (apt-get update) apt-caher climbs off. a mirror to check if there are any updates to what is in its cache.
Of course, apt-cacher has its drawbacks.
The first minus - apt-cacher distributes cached files in its structure, which is different from the structure of debian-repositories. But this problem can be solved if it is important for you to keep the repository structures, this is described below.
The second disadvantage is the availability of an Apache Web server Here, unfortunately, the problem is not so easy to solve, but I do not think that this is a significant problem :)
Install and configure apt-cacher`a
The installation itself is rather trivial for debian packages.
sudo apt-get install apt-cacher
Create a folder to store the cache (that is, the packages themselves) and assign rights to it
sudo mkdir /var/cache/apt-cacher
sudo chown www-data:www-data /var/cache/apt-cacher/*
You can create a folder anywhere
under the user and the www-data group, our apt-cacher will run, and Apache will also need to be launched under it.
With the configuration a little more difficult, to disassemble the configuration of the apt-cacher `a itself, we will use an example.
Let's open for editing the /etc/apt-cacher/apt-cacher.conf file:
sudo nano /etc/apt-cacher/apt-cacher.conf
Consider the example of conf. file:
cache_dir=/var/cache/apt-cacher # .
admin_email=root@localhost # :)
daemon_port=9999 # apt-cacher
group=www-data # apt-cacher
user=www-data # apt-cacher
allowed_hosts=* # (- )
denied_hosts= # .
generate_reports=1 # apt-cacher`a(1-, 0 - )
clean_cache=1 # ,
offline_mode=0 # 0, apt-cacher . , 1,
logdir=/var/log/apt-cacher # apt-cacher`
expire_hours=0 # apt-cacher . expire_hours , , . , - ., . , .. . 0 — , 0 — .
http_proxy= # -( )
use_proxy=1 #(1) (0) .
http_proxy_auth= # (: user:password)
use_proxy_auth= # ? (1-, 0-)
limit=0 # . 0 — . 250K — 250/, 2m — 2/
debug=0 # . 0 — , 1 — .
path_map = ubuntu archive.ubuntu.com/ubuntu ; canonical archive.canonical.com/ubuntu ; medibuntu packages.medibuntu.org/ ; # . , .. .
I think with the setting of the apt-cacher`a itself everything (well, or almost everything) is clear.
Now we are going to configure Apache. I will not describe the process of configuring Apache itself; there are many good manuals on the Web. For all of this to work, Perl must be installed and ExecCGI enabled. An example of my config (file: /etc/apt-cacher/apache.conf
Alias /apt-cacher /usr/share/apt-cacher/apt-cacher.pl
<DirectoryMatch /usr/share/apt-cacher/>
Options ExecCGI
AddHandler cgi-script .pl
AllowOverride None
order allow,deny
allow from all
')
Here it is. Config Conf. files finished. Now, I think it's time to start setting up workstations, but first I’ll describe how to convert what was in the apt-mirror’s cache to apt-cacher.
Apt-mirror> apt-cacher
Apt-cacher`a has a perl script for converting packages to apt-cacher`a format, its name is apt-cacher-import.pl, and it lies in / usr / share / apt-cacher. Use it as follows:
/usr/share/apt-cacher/apt-cacher-import.pl -r -c /etc/apt-cacher/apt-cacher.conf /var/my_repos
-r - recursive directory traversal
-c - optional parameter, which specifies the path to the conf. file.
/ var / my_repos - directory to the repository of the apt-mirror format (the usual Debian repository format).
As a result of this command, all the packages that will be found in / var / my_repos will be copied and transferred to the correct format in the / var / cache / apt-cacher folder.
If you need to leave the Debian repository, while the apt-cacher`a repository does not take up additional space, add -s to the command, then the script will simply make the SIM links to the packages. BUT! If you then delete the Debian repository, the packages for apt-cacher`a will also be unavailable (these are the usual SIM links)
If you used apt-proxy, then apt-cacher`a also has a script for translating its repository into its own. The script is: /usr/share/apt-cacher/apt-cacher/apt-proxy-to-apt-cacher.pl.
Start the daemon and configure client machines.
Starting the server as usual is simple:
sudo /etc/init.d/apt-cacher start
If you have not made syntax and other errors in apache and apt-cacher`a configurations, then the server will happily start, which will inform you with an equally good message [OK], if an error occurred, the server will make a sad face and report [FAIL] . Then you will have to re-read everything again and maybe a little bit of `google`it.
To check the launch, you can go to
localserver : 9999 (where localserver is the server on which apt-cacher is running).
Customer setup
Actually you just need to add 1 line (and comment out the rest) in the /etc/apt/sources.list file:
deb http://localserver:9999/ubuntu intrepid multiverse restricted main universe
It's all as in the usual repository, you specify what you need to update, what distribution, etc. Localserver is the server on which apt-cacher is running.
If you have included statistics, you can see it
localserver : 9999 / reports
Well, that seems to be all :)
Articles on
unix-admin.su