apt-cacher-ng

最後更新: 2015-04-14

介紹

Apt-Cacher-NG 是 Apt-Cacher 的下一代. 它在效能上作出了很大的改善

* from scratch and is written in C++

main focus on maximizing throughput with low requirements on system resources.

 

prog:

/usr/sbin/apt-cacher-ng

usage:

apt-cacher-ng [-c confdir] [-h] [optname=optvalue ...]

 

Depends:

libbz2-1.0, libc6 (>= 2.7-1), libfuse2 (>= 2.6), libgcc1 (>= 1:4.1.1), libstdc++6 (>= 4.2.1), zlib1g (>= 1:1.1.4), adduser

 

/etc/init.d/apt-cacher-ng

DAEMON_OPTS="$DAEMON_OPTS pidfile=$PIDFILE SocketPath=$SOCKETFILE foreground=0"

 

/etc/default/apt-cacher-ng

DAEMON_OPTS=" -c /etc/apt-cacher-ng "

 

/etc/apt-cacher-ng

* acng.conf

* security.conf

# web panel 的 admin login
AdminAuth: root:?????

* backends_debian:

http://ftp.tw.debian.org/debian/
http://ftp.hk.debian.org/debian/

 


SIGNALS
      

Only few signals are handled in non-default ways.

  • SIGUSR1 closes and reopens log files.
  • SIGTERM and SIGINT close log files and stop the daemon.

 


HTML page

http://Server-IP:3142  ----- 相當於------> userinfo.html

http://Server-IP:3142/acng-report.html

 


主設定檣 acng.conf

 

CacheDir: /var/cache/apt-cacher-ng

LogDir: /var/log/apt-cacher-ng

Port:3142

BindAddress: localhost 192.168.123.12

Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu

# 0 -> store only type, time and transfer sizes
# 1 -> client IP and relative local path are logged too
VerboseLog: 1

ReportPage: acng-report.html

SocketPath:/var/run/apt-cacher-ng/socket

# Don't detach from the console
ForeGround: 0

PidFile: /var/run/apt-cacher-ng/pid

# Forbid all downloads that don't run through preconfigured backends
ForceManaged: 1

#Proxy: http://www-proxy.example.net:80

# Replace some Windows/DOS-FS incompatible chars when storing
StupidFs: 1

# Days before considering an unreferenced file expired
ExTreshold: 4

# Max. count of connection threads kept ready
MaxStandbyConThreads: 8

# Don't touch this
# MaxSpareThreadSets: 2
#VfilePattern = (^|.*?/)(Index|Packages\.gz|Packages\.bz2|Release|Release\.gpg|Sources\.gz|Sources\.bz2|release|index\.db-.*\.gz|Contents-[^/]*\.gz|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|Translation[^/]*\.bz2)$
#PfilePattern = .*(\.deb|\.rpm|\.dsc|\.tar\.gz\.gpg|\.tar\.gz|\.diff\.gz|\.diff\.bz2|\.jigdo|\.template|changelog|copyright|\.udeb|\.diff/.*\.gz|vmlinuz|initrd\.gz)$



FilePerms: 00664
DirPerms: 00755

 


Remap

 

part1                                : part2                             ; part3

Remap-<repository_name>:  [/basepath | file:list.txt]  ;  [backendhost | file:where.txt]

part1

arbitrary name  <---  identify the repository in the local cache

part2

incoming URL to activate this rule.

* No wildcards are allowed

* the last directory in the path

part3

backend

ie

Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian

backends

 

/etc/apt-cacher-ng/backends_* files

backends_debian

http://cdn.debian.net/debian/

backends_ubuntu

http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/

 

 

 


 

Client Setting:

 

Ubuntu 12.04:

deb http://192.168.123.12:3142/ubuntu precise main restricted universe multiverse

Debain:

deb http://x.x.x:3142/debian squeeze-lts main contrib non-free

 


Server Log

 

Client: apt-get update

1428996290|I|304|x.x.x.x|debrep/dists/squeeze-lts/Release.gpg
1428996290|O|265|x.x.x.x|debrep/dists/squeeze-lts/Release.gpg
1428996290|O|840|x.x.x.x|
1428996292|I|300|x.x.x.x|debrep/dists/squeeze-lts/Release
1428996292|O|257|x.x.x.x|debrep/dists/squeeze-lts/Release
1428996293|I|329|x.x.x.x|debrep/dists/squeeze-lts/main/binary-i386/Packages.diff/Index
1428996293|O|315|x.x.x.x|debrep/dists/squeeze-lts/main/binary-i386/Packages.diff/Index
1428996294|I|324|x.x.x.x|debrep/dists/squeeze-lts/contrib/binary-i386/Packages.gz
1428996294|O|305|x.x.x.x|debrep/dists/squeeze-lts/contrib/binary-i386/Packages.gz
1428996294|I|324|x.x.x.x|debrep/dists/squeeze-lts/non-free/binary-i386/Packages.gz
1428996294|O|307|x.x.x.x|debrep/dists/squeeze-lts/non-free/binary-i386/Packages.gz

Client: apt-get install bash

1428996308|I|330|x.x.x.x|debrep/pool/main/b/bash/bash_4.1-3+deb6u2_i386.deb
1428996308|O|305|x.x.x.x|debrep/pool/main/b/bash/bash_4.1-3+deb6u2_i386.deb

 

 


acng-report.html

  • Expiration
  • Import

When all conditions are met put your files into the "_import" directory,

e.g. /var/cache/apt-cacher-ng/_import/.

Subdirectories and symlinks are ok. Then run import.

 

 


OtherView

 

dpkg-statoverride:

a way to tell dpkg to use a different owner or mode for a file when a package is installed.

Creative Commons license icon Creative Commons license icon