Debian Package Cacher With apt-cacher
I’m so proud of Linux world wide community, they know what people need, what Linux lack of, then they contribute a useful package for the community. Thanks to apt-cacher package, sharing debian packages in LAN is easy seamless and no longer bandwith consuming.
I suggest you check out the output of ‘apt-cache show apt-cacher’ command to get a brief description about what the package is for.
Before apt-cacher saved my life, I used to move packages found in /var/cache/archives into specific folder, create index manually, then share the directory across computers in my network. This of course forced me to edit source.list to point to the shared directory. Oh, this is inconvinient. Each time I need a specific package, I have to download to cache, reindex which is very time consuming, then apt-get update in each computers which need it.
When apt-cacher installed on a server, it works like Squid Proxy (apt-cache show squid). It intercepts apt request to it, then download packages or indexes for the requesting user while it keep a copy of them as cache in the server for later request. All client computers need to do to make this relationship works, is just by putting in /etc/apt/apt.conf:
Acquire::http::Proxy “http://192.168.1.1:3142″;
Yes, that’s all. You don’t need to change source.list. In this case, http://192.168.1.1 is the server.
Now, we’ll see how to setup the server:
1) Download the package
sudo apt-get install apt-cacher
2) Configure to make this service automatically started. Edit /etc/default/apt-cacher and please make sure you find this line
AUTOSTART=1
3) Optional. Configure main configuration /etc/apt-cacher/apt-cacher.conf
# To generate report daily
generate_reports=1
4) Start the service and verify that it is running
/etc/init.d/apt-cacher restart
Open in your browser to http://192.168.1.1:3142
5) Let apt-cacher cache your already-downloaded packages.
/usr/share/apt-cacher/apt-cacher-import.pl /var/cache/apt/archives
5) Want to see how seamless it works?
Watch it access log:
tail -f /var/log/apt-cacher/access.log
In a client computer which has a modified apt.conf, do apt-get update or apt-get install. You’ll see something in the log. If your request is already downloaded -just like Squid-, it will show HIT
Happy apt-get!
1 comment so far
Leave a reply
thanks..nice info.. i’ll try that..