如何創建和使用本地UbuntuSource鏡像服務器?
創建和使用本地UbuntuSource鏡像服務器可能還有很多用戶并不知道方法,下文就給出了詳細的描述,具體內容如下所述。
什么需要創建Ubuntu本地鏡像
Ubuntu發行版光盤中都只有少數常用軟件包。Ubuntu上要安裝的軟件,常常需要到Ubuntu源服務器上下載。
使用如下命令可以搜索和安裝可用的軟件包。
- apt-cachesearchpackageName
- sudoapt-getinstallpackageName
apt-get實際使用wget命令,從/etc/apt/sources.list配置文件指定的源上下載對應的.deb軟件包,然后使用dpkg-ipackageName.deb安裝軟件。
如果Ubuntu電腦所在的環境網絡性能較差,或者不能連接互聯網,那么就很難安裝UbuntuSource服務器上的海量軟件包。
此時,你可以在局域網內創建自己的UbuntuSource服務器,從而節省大量網絡流量,并且可以大大提高安裝軟件的速度!
本文將介紹如何創建UbuntuSource的本地鏡像。
創建Ubuntu本地鏡像
需求
為了創建Ubuntumirror服務器,你需要至少60G硬盤剩余空間。Ubuntu每一個版本分為32bit和64bit兩個版本,有兩組deb包。***的ubuntu版本兩組deb包需要大約90GB的空間。
你可以創建Ubuntu一個版本的32或者64bit服務器,也可以創建同時服務于32和64bit的服務器。也可以創建服務于所有ubuntu版本的source服務器。根據你的硬盤剩余空間和你的需要而定。
使用sohu的UbuntuSource服務器作為源服務器
Sohu公司提供了多種Linux和BSD操作系統發行版的source服務器。點擊下面鏈接
http://mirrors.sohu.com/
可以看到sohu公司提供的所有種類的source服務器。
點擊http://mirrors.sohu.com/help/Ubuntu.html頁面可以看到UbuntuSource服務器的使用幫助。
你可以直接修改/etc/apt/sources.list文件,添加上sohu的source服務器,從而使用sohu的source服務器,這比使用國外的Ubuntu官方source服務器速度要快很多。
我接下來,要根據sohu的UbuntuSource服務器,構建本地的UbuntuSource服務器。
我選擇sohu的UbuntuSource服務器作為復制的source的原因:
1,sohu的UbuntuSource服務器速度相當快。如果我使用ubuntu官方的source服務器作為復制的源,顯然會花費更多的時間。
2,sohu的UbuntuSource服務器每天都會和ubuntu官方source服務器同步一次。因此可以保證我www.linuxidc.com能夠使用***版本的deb包。
我構建的UbuntuSource服務器也會每天和sohu的UbuntuSource服務器同步一次。
使用apt-mirror創建UbuntuSource服務器的本地鏡像服務器
- Sudoapt-getinstallapt-mirror
- sudoapt-getinstallapache2
我們需要上面這兩個軟件來構建我們的本地UbuntuSource服務器。
我現在以構建Ubuntu10.10和ubuntu10.04的32和64位版本的本地ubuntsource服務器為例進行介紹。
如果你需要服務于其他版本,請修改對應的配置。
/etc/apt/mirror.list配置文件修改為如下:
- #############config###################
- #setbase_path/var/spool/apt-mirror
- #
- #setmirror_path$base_path/mirror
- #setskel_path$base_path/skel
- #setvar_path$base_path/var
- #setcleanscript$var_path/clean.sh
- #setdefaultarch
- #setpostmirror_script$var_path/postmirror.sh
- #setrun_postmirror0
- setnthreads20
- set_tilde0
- ##############endconfig##############
- debhttp://mirrors.sohu.com/Ubuntulucidmainmain/debian-installerrestrictedrestricted/debian-installeruniversemultiverse
- debhttp://mirrors.sohu.com/Ubuntumaverickmainmain/debian-installerrestrictedrestricted/debian-installeruniversemultiverse
- debhttp://mirrors.sohu.com/Ubuntulucid-securitymainrestricteduniversemultiverse
- debhttp://mirrors.sohu.com/Ubuntumaverick-securitymainrestricteduniversemultiverse
- debhttp://mirrors.sohu.com/Ubuntulucid-updatesmainrestricteduniversemultiverse
- debhttp://mirrors.sohu.com/Ubuntumaverick-updatesmainrestricteduniversemultiverse
- #debhttp://archive.Ubuntu.com/ubuntumaverick-proposedmainrestricteduniversemultiverse
- #debhttp://archive.Ubuntu.com/ubuntumaverick-backportsmainrestricteduniversemultiverse
- deb-srchttp://mirrors.sohu.com/Ubuntulucidmainrestricteduniversemultiverse
- deb-srchttp://mirrors.sohu.com/Ubuntumaverickmainrestricteduniversemultiverse
- deb-srchttp://mirrors.sohu.com/Ubuntulucid-securitymainrestricteduniversemultiverse
- deb-srchttp://mirrors.sohu.com/Ubuntumaverick-securitymainrestricteduniversemultiverse
- deb-srchttp://mirrors.sohu.com/Ubuntulucid-updatesmainrestricteduniversemultiverse
- deb-srchttp://mirrors.sohu.com/Ubuntumaverick-updatesmainrestricteduniversemultiverse
- #deb-srchttp://archive.Ubuntu.com/ubuntumaverick-proposedmainrestricteduniversemultiverse
- #deb-srchttp://archive.Ubuntu.com/ubuntumaverick-backportsmainrestricteduniversemultiverse
- deb-i386http://mirrors.sohu.com/Ubuntulucidmainmain/debian-installerrestrictedrestricted/debian-installeruniversemultiverse
- deb-i386http://mirrors.sohu.com/Ubuntumaverickmainmain/debian-installerrestrictedrestricted/debian-installeruniversemultiverse
- deb-i386http://mirrors.sohu.com/Ubuntulucid-securitymainrestricteduniversemultiverse
- deb-i386http://mirrors.sohu.com/Ubuntumaverick-securitymainrestricteduniversemultiverse
- deb-i386http://mirrors.sohu.com/Ubuntulucid-updatesmainrestricteduniversemultiverse
- deb-i386http://mirrors.sohu.com/Ubuntumaverick-updatesmainrestricteduniversemultiverse
- #debhttp://archive.Ubuntu.com/ubuntumaverick-proposedmainrestricteduniversemultiverse
- #debhttp://archive.Ubuntu.com/ubuntumaverick-backportsmainrestricteduniversemultiverse
- #deb-srchttp://mirrors.sohu.com/Ubuntulucidmainrestricteduniversemultiverse
- #deb-srchttp://mirrors.sohu.com/Ubuntumaverickmainrestricteduniversemultiverse
說明:
maverick和lucid分別是Ubuntu10.10和10.04的代號。
debhttp://*表示下載64位版本的deb軟件。
deb-i386http://*表示下載32位版本的deb軟件。
然后執行:sudoapt-mirror
這會啟動20個線程【上面文件中配置】運行wget到http://mirrors.sohu.com/Ubuntu下面下載相應的deb包。
sudoapt-mirror執行完成后,/var/spool/apt-mirror目錄下就有了所有需要的deb包和相應的配置文件。
因為我現在是從sohu下載的,所以實際的文件在:/var/spool/apt-mirror/mirror/mirrors.sohu.com/Ubuntu目錄下。
如果你選擇其他UbuntuSource服務區,那么會下載到其他對應的目錄下。
總結:
希望本文介紹的創建和使用本地UbuntuSource鏡像服務器的方法能夠對讀者有所幫助,更多有關linux系統的知識還有待于讀者去探索和學習。
【編輯推薦】