apt-mirror 設定紀錄–之一

每次安裝ubuntu,都要花上很多時間去網路上更新package,尤其是在傳教的時候,大家一起上網更新的速度奇慢,接著整個氣氛就冷掉了,等到更新完成想玩的人也走掉一半,有鑑於此,決定在內部裝一臺Server去mirror這些更新的package,希望可以把這部份耗損的時間給降低(至少我自己更新也快,哈),還好這些資料都很好找,稍微拜一下Google大神就有很多資料,我怕自己忘記流程,所以要做一點筆記,簡單紀錄如下:

1.誠如標題,要mirror的話當然要裝apt-mirror囉,安裝方法:

sudo apt-get install apt-mirror

2.安裝的過程應該不會出什麼問題,裝好之後就要進行設定,不過在設定之前還有一些準備工作要做,我們要先建立幾個資料匣,來放將來mirror回來的相關檔案,資料匣的位置沒有一定要在哪裡,原則只有一個–容量要大,因為mirror回來的東西需要很大的空間,我自己mirror的site只有幾個,預計佔用的空間是36.5G(這不用算,後面自然會知道),保險起見還是準備個50G來用吧(什麼?沒有那麼大的空間?那還是不要mirror了吧)

3.要進行設定,設定檔的路徑是:/etc/apt/mirror.list

原始設定檔的內容如下(ubuntu 9.04,其他版本可能不同)

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

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

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

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

要注意的地方是”config”的設定,略為說明幾個參數所代表的意義:

設定整個apt-mirror動作的根目錄:set base_path

設定”mirror”資料匣位置:set mirror_path

設定”skel”資料匣位置:set skel_path

設定”var”資料匣位置:set var_path

要使用多少個執行序進行下載:set nthreads

其他沒有列出來的部份我是保留原始設定,我打算把apt-mirror的根目錄設定在”/home/apt-mirrot/ubuntu/”下,所以要將

# set base_path    /var/spool/apt-mirror

變更為(記得把註解取消掉)

set base_path    /home/apt-mirror/ubuntu

其他3個的設定

# set mirror_path  $base_path/mirror
# set skel_path    $base_path/skel
# set var_path     $base_path/var

內容保持不變,只要把註解部份拿掉就好,會像這樣

set mirror_path  $base_path/mirror
set skel_path    $base_path/skel
set var_path     $base_path/var

下載的執行序部份預設的20個有點多,我修改為10

set nthreads     10

接下來是設定檔的第二部份,也就是我要進行mirror的網站位置設定,我是直接使用原始的網址設定,但是source code的部份我就不打算要了(沒有時間去編譯,直接用比較快),

原始設定如下

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

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

經過我修改後變成

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

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

就是把source code的部份都刪掉(或是註解掉那幾行也行),然後把想要的binary網站部份的打開,比較特別的地方是原來的”deb”被我改成”deb-amd64″,同樣的還有一份是”deb-i386″,因為我兩種(amd64、i386)都有mirror的需求,所以要做點修改,如果要mirror的部份與這臺server是相同的,就不用修改,保持”deb”就可以了,不指定的時候會根據server的版本進行mirror。

4.設定檔修改完成後,記得根據修改的內容把該建立的資料匣都建立好,依照我的設定,我必須建立資料匣,使用指令如下:

sudo mkdir /home/apt-mirror/ubuntu

sudo mkdir /home/apt-mirror/ubuntu/mirror

sudo mkdir /home/apt-mirror/ubuntu/skel

sudo mkdir /home/apt-mirror/ubuntu/var

為什麼我在指令前面加上了sudo?因為資料匣是建立在/home下面,當然要root權限才行呀

5.以上的動作都完成之後,就可以準備進行mirror的動作了,下指令:

sudo apt-mirror

如果動作正常,就會看到一些相關訊息,內容就是進行mirror需要多少空間,會啟用多少的執行序等等…然後呢?

要mirror的東西那麼多,幾十G的東西可有得等了,接下來的內容也要等等,哈哈~~

參考來源:How To Create A Local Debian/Ubuntu Mirror With apt-mirror

RSS feed | Trackback URI

留言回應 »

尚無回應。

名稱
信箱
URI
您的留言 (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

Trackback responses to this post