搭建 ubuntu 12.10 本地源

       ubuntu 带有一个非常小而且巧的创建源的工具apt-mirror.它的功能具体如下:

       A small and efficient tool that lets you mirror a part of or the whole Debian GNU/Linux distribution or any other apt sources.
       Main features:
        * It uses a config similar to apts sources.list
        * It's fully pool comply
        * It supports multithreaded downloading
        * It supports multiple architectures at the same time
        * It can automatically remove unneeded files
        * It works well on overloaded channel to internet
        * It never produces an inconsistent mirror including while mirroring
        * It works on all POSIX compliant systems with perl and wget

下面就来使用它创建本地源.

1.安装apt-mirror

root@ubuntu:~# apt-get install apt-mirror

2.配置/etc/apt/mirror.list

root@ubuntu:~# vim /etc/apt/mirror.list
############# config ##################
#
set base_path    /opt/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  <running host architecture>
set postmirror_script $var_path/postmirror.sh
set run_postmirror 0
set nthreads     20
set _tilde 0

deb-amd64 http://mirrors.sohu.com/ubuntu/  quantal  main restricted universe multiverse
deb-amd64 http://mirrors.sohu.com/ubuntu/  quantal-backports  main restricted universe multiverse
deb-amd64 http://mirrors.sohu.com/ubuntu/  quantal-proposed  main restricted universe multiverse
deb-amd64 http://mirrors.sohu.com/ubuntu/  quantal-security  main restricted universe multiverse
deb-amd64 http://mirrors.sohu.com/ubuntu/  quantal-updates  main restricted universe multiverse

deb-i386 http://mirrors.sohu.com/ubuntu/  quantal  main restricted universe multiverse
deb-i386 http://mirrors.sohu.com/ubuntu/  quantal-backports  main restricted universe multiverse
deb-i386 http://mirrors.sohu.com/ubuntu/  quantal-proposed  main restricted universe multiverse
deb-i386 http://mirrors.sohu.com/ubuntu/  quantal-security  main restricted universe multiverse
deb-i386 http://mirrors.sohu.com/ubuntu/  quantal-updates  main restricted universe multiverse

由于装完后,运行apt-get update,它会需要去找i386的包,所以这里我把64位和32位包都配置安装上.

注意默认安装目录是/var/spool/apt-mirror,下载源的空间至少要50G,所以目录空间一样要够用,这里我放在opt下。

3.运行apt-mirror,根据网速,我这500多K,跑了2天才更新下载完。

root@ubuntu:/opt# apt-mirror  /etc/apt/mirror.list 
Downloading 80 index files using 20 threads...
Begin time: Mon Mar 18 14:51:06 2013
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4]... [3]... [2]... [1]... [0]... 
End time: Mon Mar 18 14:51:25 2013

Proceed indexes: [PPPPP]

55.3 GiB will be downloaded into archive.
Downloading 42947 archive files using 20 threads...
Begin time: Mon Mar 18 14:51:32 2013
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4]... [3]... [2]... [1]... [0]... 
End time: Tue Mar 19 18:49:43 2013

0.0 bytes in 0 files and 0 directories can be freed.
Run /opt/apt-mirror/var/clean.sh for this purpose.
4.安装apache,设置link链接到ubuntu源目录(ip 10.1.6.175)
root@ubuntu:~# apt-get install apache2
root@ubuntu:/var/www# ln -s /opt/apt-mirror/mirror/mirrors.sohu.com/ubuntu ubuntu
root@ubuntu:/var/www# ll
lrwxrwxrwx  1 root root   46 Mar 19 20:19 ubuntu -> /opt/apt-mirror/mirror/mirrors.sohu.com/ubuntu/
5.定时更新

默认/etc/cron.d/apt-mirror

如果注释掉,就可以每天都更新。默认是关闭的。

6.将客户端设置本地源.更新完成.
root@10.1.1.200:~# cat /etc/apt/sources.list
deb http://10.1.6.175/ubuntu quantal main  multiverse restricted  universe
deb http://10.1.6.175/ubuntu quantal-backports main  multiverse restricted  universe
deb http://10.1.6.175/ubuntu quantal-proposed main  multiverse restricted  universe
deb http://10.1.6.175/ubuntu quantal-updates main  multiverse restricted  universe
deb http://10.1.6.175/ubuntu quantal-security main  multiverse restricted  universe
root@10.1.1.200:~# apt-get update
Ign http://10.1.6.175 quantal InRelease
Ign http://10.1.6.175 quantal-backports InRelease
Ign http://10.1.6.175 quantal-proposed InRelease
Ign http://10.1.6.175 quantal-updates InRelease
Ign http://10.1.6.175 quantal-security InRelease
Get:1 http://10.1.6.175 quantal Release.gpg [933 B]
Get:2 http://10.1.6.175 quantal-backports Release.gpg [933 B]
Get:3 http://10.1.6.175 quantal-proposed Release.gpg [933 B]
Get:4 http://10.1.6.175 quantal-updates Release.gpg [933 B]
Get:5 http://10.1.6.175 quantal-security Release.gpg [933 B]
Get:6 http://10.1.6.175 quantal Release [49.6 kB]
Get:7 http://10.1.6.175 quantal-backports Release [49.6 kB]
Get:8 http://10.1.6.175 quantal-proposed Release [49.6 kB]
Get:9 http://10.1.6.175 quantal-updates Release [49.6 kB]  
Get:10 http://10.1.6.175 quantal-security Release [49.6 kB] 
Get:11 http://10.1.6.175 quantal/main amd64 Packages [1,137 kB]
Get:12 http://10.1.6.175 quantal/multiverse amd64 Packages [131 kB]
Get:13 http://10.1.6.175 quantal/restricted amd64 Packages [8,369 B]


转载于:https://my.oschina.net/davehe/blog/115225

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值