Go to content

geek_stuff/server & linux

ubuntu repository mirroring

우분투 레포지토리 미러링


내부에 ubuntu 설치된 pc나 서버가 여러대일 경우 각각 하나씩 다운받는 것보다 미러링을 받는게 훨씬 빠르다.

미러링은 의외로 간단한 듯.


1. 서버에서 설정하기

일단 apt-mirror를 설치


root@server:/# apt-get install apt-mirror



이후 /etc/apt/mirror.list를 수정

i-386과 amd-64를 동시에 미러링 한다면 다음과 같이 설정


############# config ##################
#
set base_path    /backup/backupdisk1/ubuntu
#
# 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-amd64 http://ftp.daum.net/ubuntu precise main restricted universe multiverse
deb-amd64 http://ftp.daum.net/ubuntu precise-security main restricted universe multiverse
deb-amd64 http://ftp.daum.net/ubuntu precise-updates main restricted universe multiverse
deb-amd64 http://ftp.daum.net/ubuntu precise-proposed main restricted universe multiverse
deb-amd64 http://ftp.daum.net/ubuntu precise-backports main restricted universe multiverse

# mirror the debian-installer directories for mirroring install base (eg: mini.iso)
deb http://ftp.daum.net/ubuntu precise main main/debian-installer restricted restricted/debian-installer universe universe/debian-installer multiverse multiverse/debian-installer

deb-i386 http://ftp.daum.net/ubuntu precise main restricted universe multiverse
deb-i386 http://ftp.daum.net/ubuntu precise-security main restricted universe multiverse
deb-i386 http://ftp.daum.net/ubuntu precise-updates main restricted universe multiverse
deb-i386 http://ftp.daum.net/ubuntu precise-proposed main restricted universe multiverse
deb-i386 http://ftp.daum.net/ubuntu precise-backports main restricted universe multiverse

deb-src http://ftp.daum.net/ubuntu precise main restricted universe multiverse
deb-src http://ftp.daum.net/ubuntu precise-security main restricted universe multiverse
deb-src http://ftp.daum.net/ubuntu precise-updates main restricted universe multiverse
deb-src http://ftp.daum.net/ubuntu precise-proposed main restricted universe multiverse
deb-src http://ftp.daum.net/ubuntu precise-backports main restricted universe multiverse

clean http://ftp.daum.net/ubuntu


apt-mirror 실행


root@server:/etc/apt# apt-mirror

root@server:/etc/apt# apt-mirror
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_PAPER = "ko_KR.UTF-8",
    LC_ADDRESS = "ko_KR.UTF-8",
    LC_MONETARY = "ko_KR.UTF-8",
    LC_NUMERIC = "ko_KR.UTF-8",
    LC_TELEPHONE = "ko_KR.UTF-8",
    LC_IDENTIFICATION = "ko_KR.UTF-8",
    LC_MEASUREMENT = "ko_KR.UTF-8",
    LC_TIME = "ko_KR.UTF-8",
    LC_NAME = "ko_KR.UTF-8",
    LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Downloading 222 index files using 20 threads...
Begin time: Mon Aug  6 10:54:08 2012
[20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4]... [3]... [2]... [1]... [0]...
End time: Mon Aug  6 10:54:09 2012

Proceed indexes: [SSSSSPPPPPPPPPPP]

0.0 bytes will be downloaded into archive.
Downloading 0 archive files using 0 threads...
Begin time: Mon Aug  6 10:54:20 2012
[0]...
End time: Mon Aug  6 10:54:20 2012


현재 repo 용량은 120G정도?



2. Client 에서 설정하기

/etc/apt/source.list의 host를 모두 수정한다.


deb http://archive.ubuntu.com/ubuntu/ precise main restricted

등을 모두 deb http://${server_ip}/ubuntu/ precise main restricted로 변경한다.

예를 들면 아래와 같이....

# deb cdrom:[Ubuntu 12.04 LTS _Precise Pangolin_ - Release i386 (20120423)]/ precise main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://192.168.0.1/ubuntu/ precise main restricted
deb-src http://192.168.0.1/ubuntu/ precise main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://192.168.0.1/ubuntu/ precise-updates main restricted
deb-src http://192.168.0.1/ubuntu/ precise-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://192.168.0.1/ubuntu/ precise universe
deb-src http://192.168.0.1/ubuntu/ precise universe
deb http://192.168.0.1/ubuntu/ precise-updates universe
deb-src http://192.168.0.1/ubuntu/ precise-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://192.168.0.1/ubuntu/ precise multiverse
deb-src http://192.168.0.1/ubuntu/ precise multiverse
deb http://192.168.0.1/ubuntu/ precise-updates multiverse
deb-src http://192.168.0.1/ubuntu/ precise-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://192.168.0.1/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://192.168.0.1/ubuntu/ precise-backports main restricted universe multiverse

deb http://192.168.0.1/ubuntu precise-security main restricted
deb-src http://192.168.0.1/ubuntu precise-security main restricted
deb http://192.168.0.1/ubuntu precise-security universe
deb-src http://192.168.0.1/ubuntu precise-security universe
deb http://192.168.0.1/ubuntu precise-security multiverse
deb-src http://192.168.0.1/ubuntu precise-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu precise partner
# deb-src http://archive.canonical.com/ubuntu precise partner

## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
deb http://192.168.0.1/ubuntu/ precise-proposed restricted main multiverse universe


또는 스크립트를 사용할 수도...

user@client:/etc/apt# mv source.list source.list.orig; cat source.list.orig | sed "s/kr.archive.ubuntu.com/192.168.0.1/" > source.list


이후 업데이트 한번하고 설치하면 끝

user@client:/# apt-get update