歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> 創建和使用本地Ubuntu Source鏡像服務器

創建和使用本地Ubuntu Source鏡像服務器

日期:2017/2/28 16:22:34   编辑:Linux教程

為什麼需要創建Ubuntu本地鏡像

Ubuntu發行版光盤中都只有少數常用軟件包。Ubuntu上要安裝的軟件,常常需要到Ubuntu源服務器上下載。

使用如下命令可以搜索和安裝可用的軟件包。

apt-cache search packageName

sudo apt-get install packageName

apt-get實際使用wget命令,從/etc/apt/sources.list配置文件指定的源上下載對應的.deb軟件包,然後使用dpkg -i packageName.deb安裝軟件。

如果Ubuntu電腦所在的環境網絡性能較差,或者不能連接互聯網,那麼就很難安裝Ubuntu Source服務器上的海量軟件包。

此時,你可以在局域網內創建自己的Ubuntu Source服務器,從而節省大量網絡流量,並且可以大大提高安裝軟件的速度!

本文將介紹如何創建Ubuntu Source的本地鏡像。

創建Ubuntu本地鏡像

需求

為了創建ubuntu mirror服務器,你需要至少60G硬盤剩余空間。Ubuntu每一個版本分為32bit和64bit兩個版本,有兩組deb包。最新的ubuntu版本兩組deb包需要大約90GB的空間。

你可以創建ubuntu一個版本的32或者64bit服務器,也可以創建同時服務於32和64bit的服務器。也可以創建服務於所有ubuntu版本的source服務器。根據你的硬盤剩余空間和你的需要而定。

使用sohu的Ubuntu Source服務器作為源服務器

Sohu公司提供了多種Linux和BSD操作系統發行版的source服務器。點擊下面鏈接

http://mirrors.sohu.com/

可以看到sohu公司提供的所有種類的source服務器。

點擊http://mirrors.sohu.com/help/ubuntu.html 頁面可以看到Ubuntu Source服務器的使用幫助。

你可以直接修改/etc/apt/sources.list文件,添加上sohu的source服務器,從而使用sohu的source服務器,這比使用國外的ubuntu官方source服務器速度要快很多。

我接下來,要根據sohu的Ubuntu Source服務器,構建本地的Ubuntu Source服務器。

我選擇sohu的Ubuntu Source服務器作為復制的source的原因:

1,sohu的Ubuntu Source服務器速度相當快。如果我使用ubuntu官方的source服務器作為復制的源,顯然會花費更多的時間。

2,sohu的Ubuntu Source服務器每天都會和ubuntu官方source服務器同步一次。因此可以保證我www.linuxidc.com能夠使用最新版本的deb包。

我構建的Ubuntu Source服務器也會每天和sohu的Ubuntu Source服務器同步一次。

使用apt-mirror創建Ubuntu Source服務器的本地鏡像服務器

Sudo apt-get install apt-mirror

sudo apt-get install apache2

我們需要上面這兩個軟件來構建我們的本地Ubuntu Source服務器。

我現在以構建ubuntu10.10和ubuntu10.04的32和64位版本的本地ubunt source服務器為例進行介紹。

如果你需要服務於其他版本,請修改對應的配置。

/etc/apt/mirror.list配置文件修改為如下:

############# 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 <running host architecture>

# set postmirror_script $var_path/postmirror.sh

# set run_postmirror 0

set nthreads 20

set _tilde 0

#

############# end config ##############

deb http://mirrors.sohu.com/ubuntu lucid main main/debian-installer restricted restricted/debian-installer universe multiverse

deb http://mirrors.sohu.com/ubuntu maverick main main/debian-installer restricted restricted/debian-installer universe multiverse

deb http://mirrors.sohu.com/ubuntu lucid-security main restricted universe multiverse

deb http://mirrors.sohu.com/ubuntu maverick-security main restricted universe multiverse

deb http://mirrors.sohu.com/ubuntu lucid-updates main restricted universe multiverse

deb http://mirrors.sohu.com/ubuntu maverick-updates main restricted universe multiverse

#deb http://archive.ubuntu.com/ubuntu maverick-proposed main restricted universe multiverse

#deb http://archive.ubuntu.com/ubuntu maverick-backports main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu lucid main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu maverick main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu lucid-security main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu maverick-security main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu lucid-updates main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu maverick-updates main restricted universe multiverse

#deb-src http://archive.ubuntu.com/ubuntu maverick-proposed main restricted universe multiverse

#deb-src http://archive.ubuntu.com/ubuntu maverick-backports main restricted universe multiverse

deb-i386 http://mirrors.sohu.com/ubuntu lucid main main/debian-installer restricted restricted/debian-installer universe multiverse

deb-i386 http://mirrors.sohu.com/ubuntu maverick main main/debian-installer restricted restricted/debian-installer universe multiverse

deb-i386 http://mirrors.sohu.com/ubuntu lucid-security main restricted universe multiverse

deb-i386 http://mirrors.sohu.com/ubuntu maverick-security main restricted universe multiverse

deb-i386 http://mirrors.sohu.com/ubuntu lucid-updates main restricted universe multiverse

deb-i386 http://mirrors.sohu.com/ubuntu maverick-updates main restricted universe multiverse

#deb http://archive.ubuntu.com/ubuntu maverick-proposed main restricted universe multiverse

#deb http://archive.ubuntu.com/ubuntu maverick-backports main restricted universe multiverse

#deb-src http://mirrors.sohu.com/ubuntu lucid main restricted universe multiverse

#deb-src http://mirrors.sohu.com/ubuntu maverick main restricted universe multiverse

說明:

maverick和lucid分別是Ubuntu 10.10和10.04的代號。

deb http://* 表示下載64位版本的deb軟件。

deb-i386 http://* 表示下載32位版本的deb軟件。

然後執行: sudo apt-mirror

這會啟動20個線程【上面文件中配置】運行wget到 http://mirrors.sohu.com/ubuntu 下面下載相應的deb包。

sudo apt-mirror執行完成後,/var/spool/apt-mirror目錄下就有了所有需要的deb包和相應的配置文件。

因為我現在是從sohu下載的,所以實際的文件在:/var/spool/apt-mirror/mirror/mirrors.sohu.com/ubuntu目錄下。

如果你選擇其他Ubuntu Source服務區,那麼會下載到其他對應的目錄下。

Copyright © Linux教程網 All Rights Reserved