miércoles, 8 de agosto de 2012

Repositorio Ubuntu 12.04 LTS crear mirror local

Seguramente más de un administrador ha encontrado en las estadísticas de trafico en el servidor de acceso a internet que gran parte del ancho de banda, tasa de download, etc. esta siendo usado para actualizar los ubuntu de escritorio.
Si tenemos espacio en nuestro disco rígido en el servidor lo ideal es crear un repositorio local con lo que obtenemos un uso optimizado de internet y le damos a nuestros usuarios actualizaciones a velocidad full-cache.
fuente

si tenemos nuestro servidor basado en debian es tan sencillo como instalar apt-mirror
#apt.get install apt-mirror

editamos /etc/apt/mirror.list
y cambiamos para que quede algo asi:

############# config ##################
#
 set base_path    /var/spool/apt-mirror
#
 set mirror_path  $base_path/mirror
 set skel_path    $base_path/skel
 set var_path     $base_path/var
 set cleanscript $var_path/clean.sh
 set defaultarch  i386
 set postmirror_script $var_path/postmirror.sh
 set run_postmirror 0
set nthreads     20
set _tilde 0
#
############# end config ##############

deb http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
#deb http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse

deb-src http://archive.ubuntu.com/ubuntu precise main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu precise-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu precise-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu precise-backports main restricted universe multiverse

clean http://archive.ubuntu.com/ubuntu

grabamos y ejecutamos apt-mirror

root@champitas:~# apt-mirror
Downloading 84 index files using 20 threads...
Begin time: Wed Aug  8 12:18:46 2012
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4]... [3]... [2]... [1]... [0]... 
End time: Wed Aug  8 12:19:26 2012

Proceed indexes: [SSSPPP]

71.6 MiB will be downloaded into archive.
Downloading 21 archive files using 20 threads...
Begin time: Wed Aug  8 12:19:37 2012
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4]... [3]... [2]... [1]... [0]... 
End time: Wed Aug  8 12:34:18 2012

34.1 MiB in 67 files and 0 directories can be freed.
Run /var/spool/apt-mirror/var/clean.sh for this purpose.
la primera vez se bajaran cerca de 90GB (en la cita se muestra una actualización manual).

 Para crear el mirror en un no-debian based linux debemos instalar debootstrap. una breve guia para hacerlo

creamos un enlace de nuestro mirror a la raiz de documentos de apache
#ln -s /var/spool/apt-mirror/mirror/archive.ubuntu.com/ubuntu /var/www/

finalmente, le pasamos a nuestros usuarios el nuevo sources.list que debera contener algo parecido a esto:
root@champitas:/etc/apt# cat sources.list
# deb cdrom:[Ubuntu 12.04 LTS _Precise Pangolin_ - Release i386 (20120423)]/ precise main restricted

deb http://192.168.31.8/ubuntu/ precise main restricted
deb-src http://192.168.31.8/ubuntu/ precise main restricted
deb http://192.168.31.8/ubuntu/ precise-updates main restricted
deb-src http://192.168.31.8/ubuntu/ precise-updates main restricted
deb http://192.168.31.8/ubuntu/ precise universe
deb-src http://192.168.31.8/ubuntu/ precise universe
deb http://192.168.31.8/ubuntu/ precise-updates universe
deb-src http://192.168.31.8/ubuntu/ precise-updates universe
deb http://192.168.31.8/ubuntu/ precise multiverse
deb-src http://192.168.31.8/ubuntu/ precise multiverse
deb http://192.168.31.8/ubuntu/ precise-updates multiverse
deb-src http://192.168.31.8/ubuntu/ precise-updates multiverse
cambiando la IP privada por la propia o , en caso de tenerlo, por el FQDN

Actualizamos:
root@champitas:~# apt-get update
Ign http://192.168.31.8 precise InRelease
Ign http://192.168.31.8 precise-updates InRelease
Obj http://192.168.31.8 precise Release.gpg
Obj http://192.168.31.8 precise-updates Release.gpg
Obj http://192.168.31.8 precise Release
Obj http://192.168.31.8 precise-updates Release
Obj http://192.168.31.8 precise/main Sources                                   
Obj http://192.168.31.8 precise/restricted Sources                             
Obj http://192.168.31.8 precise/universe Sources           
Obj http://192.168.31.8 precise/multiverse Sources         
Obj http://192.168.31.8 precise/main i386 Packages         
Obj http://192.168.31.8 precise/restricted i386 Packages   
Obj http://192.168.31.8 precise/universe i386 Packages     
Obj http://192.168.31.8 precise/multiverse i386 Packages   
Ign http://192.168.31.8 precise/main TranslationIndex      
Ign http://192.168.31.8 precise/multiverse TranslationIndex
Ign http://192.168.31.8 precise/restricted TranslationIndex                    
Ign http://192.168.31.8 precise/universe TranslationIndex                      
Obj http://192.168.31.8 precise-updates/main Sources          
Obj http://192.168.31.8 precise-updates/restricted Sources
Obj http://192.168.31.8 precise-updates/universe Sources
Obj http://192.168.31.8 precise-updates/multiverse Sources    
Obj http://192.168.31.8 precise-updates/main i386 Packages    
Obj http://192.168.31.8 precise-updates/restricted i386 Packages
Obj http://192.168.31.8 precise-updates/universe i386 Packages
Obj http://192.168.31.8 precise-updates/multiverse i386 Packages
Ign http://192.168.31.8 precise-updates/main TranslationIndex 
Ign http://192.168.31.8 precise-updates/multiverse TranslationIndex
Ign http://192.168.31.8 precise-updates/restricted TranslationIndex
Ign http://192.168.31.8 precise-updates/universe TranslationIndex
Ign http://192.168.31.8 precise/main Translation-es_ES        
Ign http://192.168.31.8 precise/main Translation-es
Ign http://192.168.31.8 precise/main Translation-en
Ign http://192.168.31.8 precise/multiverse Translation-es_ES
Ign http://192.168.31.8 precise/multiverse Translation-es
Ign http://192.168.31.8 precise/multiverse Translation-en
Ign http://192.168.31.8 precise/restricted Translation-es_ES
Ign http://192.168.31.8 precise/restricted Translation-es
Ign http://192.168.31.8 precise/restricted Translation-en
Ign http://192.168.31.8 precise/universe Translation-es_ES
Ign http://192.168.31.8 precise/universe Translation-es
Ign http://192.168.31.8 precise/universe Translation-en
Ign http://192.168.31.8 precise-updates/main Translation-es_ES
Ign http://192.168.31.8 precise-updates/main Translation-es
Ign http://192.168.31.8 precise-updates/main Translation-en
Ign http://192.168.31.8 precise-updates/multiverse Translation-es_ES
Ign http://192.168.31.8 precise-updates/multiverse Translation-es
Ign http://192.168.31.8 precise-updates/multiverse Translation-en
Ign http://192.168.31.8 precise-updates/restricted Translation-es_ES
Ign http://192.168.31.8 precise-updates/restricted Translation-es
Ign http://192.168.31.8 precise-updates/restricted Translation-en
Ign http://192.168.31.8 precise-updates/universe Translation-es_ES
Ign http://192.168.31.8 precise-updates/universe Translation-es
Ign http://192.168.31.8 precise-updates/universe Translation-en
Ign http://linux.dropbox.com precise InRelease     
Obj http://linux.dropbox.com precise Release.gpg   
Obj http://linux.dropbox.com precise Release
Obj http://linux.dropbox.com precise/main i386 Packages
Ign http://linux.dropbox.com precise/main TranslationIndex
Ign http://linux.dropbox.com precise/main Translation-es_ES
Ign http://linux.dropbox.com precise/main Translation-es
Ign http://linux.dropbox.com precise/main Translation-en
Leyendo lista de paquetes... Hecho

No hay comentarios: