Ubuntuのリポジトリミラー

1月2月にも書いたUbuntu 9.10 (karmic koala)のノウハウ。

複数台のマシンをセットアップしたり、aptパッケージの版数を管理する必要がある場合は、リポジトリミラーを立てておいた方が良い。

基本的には

$ sudo aptitude install apt-mirror

apt-mirrorインストールし、cron等で定期的にパブリックマスターと同期させるだけ。意外に簡単だ。

apt-mirrorの設定は/etc/apt/mirror.listで、こんな感じ。

############# config ##################
#
# set base_path    `/var/lib/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  architecture>
# set postmirror_script $var_path/postmirror.sh
set base_path    /var/lib/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  i386**
set postmirror_script $var_path/postmirror.sh
set run_postmirror 0
set nthreads     20
set _tilde 0
#
############# end config ##############
deb-i386 http://archive.ubuntu.com/ubuntu karmic main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu karmic-security main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu karmic-updates main restricted universe multiverse
#deb-i386 http://archive.ubuntu.com/ubuntu karmic-proposed main restricted universe multiverse
#deb-i386 http://archive.ubuntu.com/ubuntu karmic-backports main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu karmic main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu karmic-security main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu karmic-updates main restricted universe multiverse
#deb-amd64 http://archive.ubuntu.com/ubuntu karmic-proposed main restricted universe multiverse
#deb-amd64 http://archive.ubuntu.com/ubuntu karmic-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu karmic main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu karmic-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu karmic-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu karmic-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu karmic-backports main restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu

通常はset defaultarch i386を設定して

deb http://archive.ubuntu.com/ubuntu …

を列挙していけば良いが、今回はi386に加えてamd64もミラーする必要があったので、deb-i386とdeb-amd64に分けて書く必要があるというのがポイント。

設定した/var/lib/apt-mirror配下のディレクトリを作成し、

$ sudo apt-mirror

で同期開始。同期にはi386だけで50GB以上、amd64も含めると70GB以上の空き容量と、8時間ほどの時間が必要だった。

同期した後は、WebサーバのDocumentRoot/var/lib/apt-mirror/mirror/archive.ubuntu.com/ubuntuへのシンボリックリンクを作成し、Webサーバを起動すればOK。Webサーバはmini-httpdあたりで充分。

mini-httpd/etc/mini-httpd.confdata_dirDocumentRootに合わせて書き直すだけかな。/etc/default/mini-httpd

# Start daemon?
# 0 = no
# 1 = yes
START=0

を 1 にしとけば自動起動するよ。

参照

Ubuntu Japanese Team http://www.ubuntulinux.jp/

Ubuntu http://www.ubuntu.com/

blog@browncat.org http://blog.browncat.org/

popey.com blog http://popey.com/blog/