请高手翻译如何建立Ubuntu源镜像

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
daniel
帖子: 24
注册时间: 2006-06-18 17:51

请高手翻译如何建立Ubuntu源镜像

#1

帖子 daniel » 2007-02-03 13:30

How To Create A Local Debian/Ubuntu Mirror With apt-mirror

Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 12/26/2006

This tutorial shows how to create a Debian/Ubuntu mirror for your local network with the tool apt-mirror. Having a local Debian/Ubuntu mirror is good if you have to install multiple systems in your local network because then all needed packages can be downloaded over the fast LAN connection, thus saving your internet bandwidth.

I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!


1 Preliminary Note

You can set up a Debian and Ubuntu mirror on both Debian and Ubuntu systems, i.e., a Debian system can be a Debian and a Ubuntu mirror, as well as a Ubuntu system can be a Ubuntu and a Debian mirror.
Please note that you need a fast internet connection to download all the packages to your mirror as well as a lot of hard disk space. In my tests I mirrored the main, contrib, and non-free sections of Debian Sarge and the main, restricted, and universe sections of Ubuntu Edgy Eft which took about 25GB of hard disk space and about 6 hours of download time on a 16MBit DSL line.

I will not mirror security updates in this tutorial - I think it's a good idea to always download security updates directly from the internet. That way you can be sure you get the latest ones.

I've tested this on a Debian Sarge and a Ubuntu Edgy Eft system. If you use different Debian/Ubuntu versions, the procedure might differ a little bit. You should have already set up a basic Debian Sarge system (e.g. as outlined on pages one and two of http://www.howtoforge.com/perfect_setup_debian_sarge) or a basic Ubuntu Edgy Eft system (e.g. as outlined on pages one to three of http://www.howtoforge.com/perfect_setup_ubuntu_6.10).

In this example my local mirror has the IP address 192.168.0.100.


2 Install apt-mirror
2.1 Modify /etc/apt/sources.list (Debian Sarge only)

If you are on Debian Sarge, you must modify /etc/apt/sources.list to install apt-mirror. I don't know if this is necessary on Debian Etch or Sid, please try it yourself. This step is not necessary for Ubuntu Edgy Eft.

vi /etc/apt/sources.list

Please add the following line to the file:

[...]
deb http://apt-mirror.sourceforge.net/ apt-mirror/
[...]

Then update the packages database:

apt-get update


2.2 Install apt-mirror

This step is for all systems (Debian and Ubuntu). To install apt-mirror, please run

apt-get install apt-mirror


3 Install Apache

Later on, I want to access my new local Debian/Ubuntu mirror over http, therefore I install the Apache web server now:

apt-get install apache2

The default document root is /var/www, I will create symlinks from that directory to the location of the Debian and Ubuntu repository later on.


4 Configure apt-mirror

apt-mirror's configuration file is /etc/apt/mirror.list. There should already be a default configuration in it; on Debian Sarge the file looks like this:

# apt-mirror configuration file

##
## The default configuration options (uncomment and change to override)
##
#
# 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 defaultarch
# set nthreads 20
#


##
## Example sources
##

# sarge's section
deb http://ftp.fi.debian.org/debian sarge main contrib non-free
deb-src http://ftp.fi.debian.org/debian sarge main contrib non-free

deb http://security.debian.org/debian-security sarge/updates main contrib non-free
deb-src http://security.debian.org/debian-security sarge/updates main contrib non-free

deb http://ftp.fi.debian.org/debian sarge main/debian-installer


# sarge-proposed-updates's section
deb http://ftp.fi.debian.org/debian sarge-proposed-updates main contrib non-free
deb-src http://ftp.fi.debian.org/debian sarge-proposed-updates main contrib non-free


# sid's section
deb http://ftp.fi.debian.org/debian sid main contrib non-free
deb-src http://ftp.fi.debian.org/debian sid main contrib non-free

deb http://ftp.fi.debian.org/debian sid main/debian-installer


# experimental section
deb http://ftp.fi.debian.org/debian ../project/experimental main contrib non-free
deb-src http://ftp.fi.debian.org/debian ../project/experimental main contrib non-free


##
## Cleaner configuration example
##
#
# set cleanscript $var_path/clean.sh
#

# Cleaning section
clean http://security.debian.org/
clean http://ftp.fi.debian.org/


skip-clean http://ftp.fi.debian.org/doc/
skip-clean http://ftp.fi.debian.org/tools/
skip-clean http://ftp.fi.debian.org/debian-cd/
skip-clean http://ftp.fi.debian.org/debian-minicd/
skip-clean http://ftp.fi.debian.org/debian/dists/s ... ller-i386/
skip-clean http://ftp.fi.debian.org/debian/dists/s ... ller-i386/
skip-clean http://ftp.fi.debian.org/debian/doc/
skip-clean http://ftp.fi.debian.org/debian/tools/
skip-clean http://ftp.fi.debian.org/debian/project/
skip-clean http://ftp.fi.debian.org/debian-non-US/project/

On Ubuntu Edgy Eft, the file looks like this:

############# config ##################
#
# set base_path /var/spool/apt-mirror
#
# if you change the base path you must create the directories below with write privlages
#
# 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
set nthreads 20
set tilde 0
#
############# end config ##############

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

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

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

If you compare the file with /etc/apt/sources.list, you will see that it's very similar. /etc/apt/mirror.list mainly lists the repositories that should be mirrored, plus a few other options.

Now we modify /etc/apt/mirror.list. As I said before, I want to mirror the main, contrib, and non-free sections of Debian Sarge and the main, restricted, and universe sections of Ubuntu Edgy Eft, but I don't want to mirror the security updates as these should be downloaded directly from the internet. Also, I don't want to mirror the source packages because in 95% of all installations you don't need source packages, and they need a lot of space on the hard disk. So my /etc/apt/mirror.list looks like this:

vi /etc/apt/mirror.list

# apt-mirror configuration file

##
## The default configuration options (uncomment and change to override)
##
#
# 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 defaultarch
# set nthreads 20
#


##
## Example sources
##

# sarge's section
deb http://ftp.de.debian.org/debian sarge main contrib non-free

# Ubuntu Edgy Eft
deb http://de.archive.ubuntu.com/ubuntu/ edgy main restricted universe

##
## Cleaner configuration example
##
#
# set cleanscript $var_path/clean.sh
#

# Cleaning section
clean http://ftp.de.debian.org/
clean http://de.archive.ubuntu.com/

Please note that I used ftp.de.debian.org instead of ftp.fi.debian.org and de.archive.ubuntu.com instead of archive.ubuntu.com. You should use mirrors that are close to you, so if you are in the U.S., for example, replace de with us, and so on.

The cleaning section at the end tells apt-mirror in which directories on the local hard disk it should check to see if hard disk space can be freed. I want to check the whole local repositories for both Debian and Ubuntu, therefore I specify

clean http://ftp.de.debian.org/
clean http://de.archive.ubuntu.com/

If you want to use other Debian/Ubuntu versions, simply replace sarge with etch or sid and edgy with breezy, dapper, etc.
5 Create The Local Repositories

Now that apt-mirror is configured, it's time to run it for the first time and download all the packages that form the local Debian and Ubuntu repository. All we have to do is type

su - apt-mirror -c apt-mirror

apt-mirror tells you how many GB it must download. This can take a few hours, so be patient. The packages will be stored in subdirectories of the /var/spool/apt-mirror/mirror directory, so make sure the partition that holds that directory has enough disk space left.
The Debian repository will be in /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian, and the Ubuntu repository will be in /var/spool/apt-mirror/mirror/de.archive.ubuntu.com/ubuntu. If you used different mirrors in chapter 4, the paths will be a little bit different for you.


6 Clean Up The Local Repositories

After apt-mirror has finished downloading all packages, it will most likely tell you can free up some disk space with the /var/spool/apt-mirror/var/clean.sh script. That's what we do now:

/bin/bash /var/spool/apt-mirror/var/clean.sh

The output will look like this:

server1:~# /bin/bash /var/spool/apt-mirror/var/clean.sh
Removing 157 unnecessary files [13316096 bytes]...
[0%]................done.

Removing 18 unnecessary directories...
[0%]..................done.

As you see, some MB have been freed.


7 Update The Local Repositories / Create A Daily Cron Job

Updating the local mirror is easy. Simply run

su - apt-mirror -c apt-mirror

again.

If you don't want to do it manually, you can create a daily cron job for it. Simply edit /etc/cron.d/apt-mirror and uncomment the last line in it so that it looks like this:

vi /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

This will make apt-mirror run at 4.00h each day, and it will log to /var/spool/apt-mirror/var/cron.log.


8 Make The Local Mirrors Accessible Over HTTP

The default Apache document root under Debian and Ubuntu is /var/www, but our repositories are stored in /var/spool/apt-mirror/mirror. In order to make our repositories accessible by http://192.168.0.100/debian and http://192.168.0.100/ubuntu (in this tutorial 192.168.0.100 is the IP address of our local mirror), we create the symlinks /var/www/debian and /var/www/ubuntu that point to the real repositories:

ln -s /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian /var/www/debian
ln -s /var/spool/apt-mirror/mirror/de.archive.ubuntu.com/ubuntu /var/www/ubuntu

Remember to adjust these commands if you use different mirrors than ftp.de.debian.org and de.archive.ubuntu.com.

The next thing to consider is that you can refer to Debian Sarge as sarge, but also as stable (at the time of this writing Debian Sarge is stable and the upcoming Debian Etch still testing). When you run

ls -l /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian/dists

you will see that there is a directory called sarge, but not stable. If you use stable instead of sarge in /etc/apt/sources.list or install a new Debian system with the local mirror, this is a problem (the Debian Sarge installer also refers to stable instead of sarge). The solution is to create a symlink:

cd /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian/dists
ln -s sarge/ stable

Remember to adjust this command if you use a different mirror than ftp.de.debian.org.

At the time Debian Etch becomes stable and you decide to mirror Etch as well, don't forget to change the stable symlink, e.g. like this:

cd /var/spool/apt-mirror/mirror/ftp.de.debian.org/debian/dists
rm -f stable
ln -s etch/ stable

We don't have this problem with Ubuntu as there's no stable, only breezy, dapper, edgy, etc.
9 Configure Your Client Computers To Use The Local Mirror

Now that our local mirror is ready to be used, all we have to do is tell our Debian Sarge and Ubuntu Edgy Eft systems in our local network to use it.


9.1 Debian Sarge

On Debian Sarge systems, you can replace the main contrib non-free repository in /etc/apt/sources.list like this:
vi /etc/apt/sources.list

[...]
deb http://192.168.0.100/debian sarge main contrib non-free
[...]

Instead of sarge you could also use stable:

[...]
deb http://192.168.0.100/debian stable main contrib non-free
[...]

Afterwards, run

apt-get update


9.2 Ubuntu Edgy Eft

On Ubuntu Edgy Eft systems, you can replace the main restricted universe repository in /etc/apt/sources.list like this:

vi /etc/apt/sources.list

[...]
deb http://192.168.0.100/ubuntu/ edgy main restricted universe
[...]

Afterwards, run

apt-get update


9.3 Fresh Installation

If you install a fresh Debian Sarge or Ubuntu Edgy Eft system, specify your local mirror like this when the installer asks you which repository you'd like to use:
图片
图片
图片
图片
图片
Afterwards the installer will use your local mirror to install the system:
图片
10 Links

* apt-mirror: http://apt-mirror.sourceforge.net
* Debian: http://www.debian.org
* Ubuntu: http://www.ubuntu.com


http://www.howtoforge.com/local_debian_ubuntu_mirror
guava
帖子: 40
注册时间: 2006-11-22 16:42

#2

帖子 guava » 2007-02-03 15:47

How To Create A Local Debian/Ubuntu Mirror With apt-mirror

代码: 全选

怎样利用apt-mirror去创建一个本地的Debian/Ubuntu目录(源)
Version 1.0
Author: Falko Timme <ft [at] falkotimme [dot] com>
Last edited 12/26/2006

代码: 全选

颁布1.0
作者:Falko Timme <ft [at] falkotimme [dot] com>
最后编辑于12/26/2006
This tutorial shows how to create a Debian/Ubuntu mirror for your local network with the tool apt-mirror. Having a local Debian/Ubuntu mirror is good if you have to install multiple systems in your local network because then all needed packages can be downloaded over the fast LAN connection, thus saving your internet bandwidth.

代码: 全选

这篇文章将会告诉你如何通过apt-mirror这个工具在局域网创建一个 Debian/Ubuntu 源(目录).如果你想在
一个局域网里安装很多个系统,那么拥有一个本地的Debian/Ubuntu 源是非常good的,因为你可以通过局域网
的连接很快的下载你所需要的包,相比你的互连网带宽。
I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!

代码: 全选

我想说我所用的方法并不是唯一的设置方法,还有很多方法可以做到。我不能保证这个方法也适用于你。
后面的有点难 休息一下 大家一起来罗
头像
millenniumdark
论坛版主
帖子: 4159
注册时间: 2005-07-02 14:41
系统: Ubuntu 14.04 (Kylin)
联系:

#3

帖子 millenniumdark » 2007-02-05 18:55

有一個軟件叫deb-mirror,不知道有何區別?
头像
shaojz2005
帖子: 278
注册时间: 2006-07-13 13:01
联系:

#4

帖子 shaojz2005 » 2007-02-13 13:56

我也很需要这方面的资料阿
icyfire
帖子: 13
注册时间: 2006-07-22 8:57

#5

帖子 icyfire » 2007-02-19 22:43

已经尝试翻译了
viewtopic.php?t=41791
dvdface
帖子: 152
注册时间: 2006-08-16 22:19
来自: 湖北武汉
联系:

#6

帖子 dvdface » 2007-02-20 0:14

This article is easy to understand , but to long.
头像
shaojz2005
帖子: 278
注册时间: 2006-07-13 13:01
联系:

#7

帖子 shaojz2005 » 2007-02-22 17:34

支持辛勤翻译的工作者
回复