debian: ทำแคชให้ apt ด้วย apt-proxy

 

apt-proxy เป็นซอฟต์แวร์ที่ใช้เก็บแพคเกจ apt
ใครมีเครื่องลินุกส์ที่ใช้แพคเกจ apt ในหน่วยงานตั้งแต่สองเครื่องขึ้นไป
ควรติดตั้งไว้ที่เครื่องเซิร์ฟเวอร์เป็นอย่างยิ่งครับ

เอามาจาก : ThaiLinuxCafe - ทำแคชให้เดเบียนแพคเก็จด้วย apt-proxy
โฮมเพจอยู่ที่ : http://apt-proxy.sourceforge.net/
ขอไว้อาลัยและอุทิศกุศลแด่ : คูณ Manuel Estrada Sainz (ranty) และคุณ Andrés García (ErConde) ผู้พัฒนาด้วยครับ

ที่เครื่องเซิร์ฟเวอร์
สมมุติว่าเซิร์ฟเวอร์ชื่อ server1.example.com ไอพี 192.168.1.5

เริ่มติดตั้งด้วย
# aptitude install apt-proxy

ปรับตั้งแพคเกจนิดหน่อย
# vi /etc/apt-proxy/apt-proxy-v2.conf

...
max_age = 120d        ;; อายุแพคเกจในแคช ผมใช้ 360d
...
[debian]
backends =
        http://ftp.us.debian.org/debian
        ;;http://mirror.in.th/debian
        ...
...
[security]
backends =
        http://security.debian.org/debian-security
        ...
...
[ubuntu]
backends =
        http://th.archive.ubuntu.com/ubuntu        
        http://mirror.in.th/ubuntu/archive
        ...
...
[ubuntu-security]
backends = 
        http://security.ubuntu.com/ubuntu
...

ใช้งานได้แล้ว

ที่เครื่องลูกข่าย
เวลาเรียกใช้งานจากเครื่องลูก เราแก้ไขไฟล์ /etc/apt/sources.list ให้มาใช้ของเรา
$ sudo vi /etc/apt/sources.list

ถ้าเป็นเดเบียน

deb     http://server1.example.com:9999/debian/ etch main contrib non-free
deb-src http://server1.example.com:9999/debian/ etch main contrib non-free
deb     http://server1.example.com:9999/security/ etch/updates main contrib non-free
deb-src http://server1.example.com:9999/security/ etch/updates main contrib non-free

ถ้าเป็นอูบุนตู

deb     http://server1.example.com:9999/ubuntu/ edgy main restricted universe multiverse
deb-src http://server1.example.com:9999/ubuntu/ edgy main restricted universe multiverse
deb     http://server1.example.com:9999/ubuntu/ edgy-updates main restricted universe multiverse
deb-src http://server1.example.com:9999/ubuntu/ edgy-updates main restricted universe multiverse
deb     http://server1.example.com:9999/ubuntu-security/ edgy-security main restricted universe multiverse
deb-src http://server1.example.com:9999/ubuntu-security/ edgy-security main restricted universe multiverse

หมายเหตุ

  • ตรง server1.example.com อาจใช้เป็นเลขไอพี 192.168.1.5 ก็ได้
  • สำหรับเครื่องแม่ข่ายเอง อาจใช้ของตัวเองโดยเปลี่ยน server1.example.com เป็น localhost ก็ได้
  • หากมีเครื่องที่เป็น apt-proxy ต่อกัน ให้ตั้งค่า Backend ใน /etc/apt-proxy/apt-proxy-v2.conf ให้ชี้ไปที่ apt-proxy ตัวแรก ไม่ควรออกสู่ภายนอกด้วยตัวเอง จะมีปัญหาตายบ่อย
  • แพกเกจนี้ยังมีข้อผิดพลาดอยู่ เนื่องจากผู้พัฒนาเสียชีวิตไปเสียก่อน เมื่อเครื่องลูกข่ายรอนานผิดปกติ หรือเกิดข้อผิดพลาดขึ้น อาจต้องเริ่มเซอร์วิสที่เซิร์ฟเวอร์ใหม่บ้างเป็นบางครั้ง แต่ผมว่าคุ้มค่ากับการประหยัดแบนวิธครับ
 

Syndicate

Subscribe to Syndicate

Who's online

There are currently 0 users online.