2008年12月23日星期二

ubuntu搭建本地升级源

环境:
升级服务器:
ip地址:192.168.1.110
vmware虚拟机,ubuntu8.04 i386
镜像目录:/repository
镜像目录下要有足够的空间,我只是升级debian-amd64二进制包就占用了25GB的空间,对ubuntu src源没有做镜像,镜像src要多消耗20多G空间,绝大部分人不会用到src。
升级服务器可以在任何版本的ubuntu上搭建。

升级客户机:ubuntu8.10 x64
ip地址:192.168.1.100

升级源:http://mirror.lupaworld.com/ubuntu
选择升级源尽量用官方源或找口碑不错的镜像站进行镜像,而且最好先进行速度测试,选择一个速度快的升级源。


升级服务器
1. 安装需要的程序
#aptitude install apt-mirror //下载远程镜像文件
#aptitude install apache2 //安装apache2服务器,用于给本地局域网主机提供升级服务

2. 配置镜像
#gedit /etc/apt/mirror.list

############# config ##################
#
set base_path /repository //设置镜像目录
#
# if you change the base path you must create the directories below with write privlages
#
set mirror_path $base_path/mirror //设置mirror
set skel_path $base_path/skel //设置skel
set var_path $base_path/var //设置var
set cleanscript $var_path/clean.sh
set defaultarch
set nthreads 20 //设置下载镜像文件线程数
set _tilde 0
#
############# end config ##############
//设置下载镜像文件的内容
deb-amd64 http://mirror.lupaworld.com/ubuntu intrepid main restricted universe multiverse
deb-amd64 http://mirror.lupaworld.com/ubuntu intrepid-security main restricted universe multiverse
deb-amd64 http://mirror.lupaworld.com/ubuntu intrepid-updates main restricted universe multiverse
deb-amd64 http://mirror.lupaworld.com/ubuntu intrepid-backports main restricted universe multiverse
deb-amd64 http://mirror.lupaworld.com/ubuntu intrepid-proposed main restricted universe multiverse


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

//
为了镜像成功后节省空间,也可不写
clean http://mirror.lupaworld.com/ubuntu

3. 进行镜像
#apt-mirror
是网速而定需要时间,有断点续传。
如果镜像完成后相对镜像再进行升级,
#apt-mirror

4. 加入apache2
sudo ln -s /repository/mirror/mirror.lupaworld.com/ /var/www/ubuntu

5. 镜像完之后,会提示
59.5 MiB in 40 files and 0 directories can be freed.
Run /repository/var/clean.sh for this purpose.

我们运行
# /bin/bash /repository/var/clean.sh
Removing 40 unnecessary files [62435328 bytes]...
[0%]....done.

Removing 0 unnecessary directories...
done.

6. 定期升级本地源
#
gedit /etc/cron.d/apt-mirror
#
# Regular cron jobs for the apt-mirror package
#
0 4 * * * apt-mirror /usr/bin/apt-mirror > /var/spool/apt-mirror/var/cron.log
每天四点执行升级



升级客户机
1. 修改/etc/apt/sources.list
#gedit /etc/apt/sources.list
deb http://192.168.1.110/ubuntu/ubuntu/ intrepid main restricted
deb http://192.168.1.110/ubuntu/ubuntu/ intrepid-updates main restricted

deb http://192.168.1.110/ubuntu/ubuntu/ intrepid universe
deb http://192.168.1.110/ubuntu/ubuntu/ intrepid-updates universe

deb http://192.168.1.110/ubuntu/ubuntu/ intrepid multiverse
deb http://192.168.1.110/ubuntu/ubuntu/ intrepid-updates multiverse

deb http://192.168.1.110/ubuntu/ubuntu/ intrepid-backports main restricted universe multiverse

deb http://192.168.1.110/ubuntu/ubuntu/ intrepid partner

deb http://192.168.1.110/ubuntu/ubuntu/ intrepid-security main restricted
deb http://192.168.1.110/ubuntu/ubuntu/ intrepid-security universe
deb http://192.168.1.110/ubuntu/ubuntu/ intrepid-security multiverse

#如果只给自己用,或从朋友处直接拷贝过来的,在不开apache2或不装apache2情况下,要写成这样的格式
deb file:///repository/mirror/mirror.lupaworld.com/ubuntu intrepid main restricted universe multiverse

2. 可以进行升级了
#apt-get update

本地升级超快,超爽,试试吧!
本地升级源在安装时候也可以使用。

标签:


评论: 发表评论

订阅 博文评论 [Atom]





<< 主页

This page is powered by Blogger. Isn't yours?

订阅 博文 [Atom]