리눅스2023. 8. 21. 10:51

 

반달가면 이글루에서 백업 - http://bahndal.egloos.com/626023 (2019.4.5)

우분투 계열 배포판에서 공식 S/W저장소(S/W repository)의 자료를 가져와서 미러(mirror) 서버를 구축하는 방법이다. 장비가 매우 많거나 인터넷 접속이 원활하지 않을 때는 미러 서버를 구축해 놓고 이를 통해 패키지를 설치/업그레이드하는 것이 편리할 수 있다.

리눅스 민트 19(우분투 18.04 LTS 기반)에서 작업했다.

우선 apt-mirror 패키지와 apache2 패키지를 설치한다. apt-mirror는 우분투 S/W저장소 자료를 다운로드하기 위한 것이고 apache2는 미러 서버에서 구동할 웹서버다.

# S/W 저장소 갱신
sudo apt-get update

# apt-mirror, apache2 설치
sudo apt-get install apt-mirror apache2

이제 미러링할 자료를 저장할 곳을 지정한다. 여기서는 /var/local_repo 디렉토리로 정했다.

# 자료 저장 디렉토리 생성
sudo mkdir /var/local_repo

이제 apt-mirror 설정을 편집해야 한다. 설정 파일 /etc/apt/mirror.list 편집.

# apt-mirror 설정 파일 편집
sudo vi /etc/apt/mirror.list

우분투 16.04(코드명 Xenial Xerus)와 우분투 18.04(코드명 Bionic Beaver)의 S/W저장소를 미러링한다면 /etc/apt/mirror.list 파일의 내용에는 아래와 같은 내용이 있어야 한다.

# base_path 항목 설정
set base_path /var/local_repo
...
#### 16.04LTS XENIAL ####
deb-amd64 http://archive.ubuntu.com/ubuntu xenial main main/debian-installer restricted restricted/debian-installer universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu xenial-proposed main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse

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

#### 18.04LTS BIONIC ####
deb-amd64 http://archive.ubuntu.com/ubuntu bionic main main/debian-installer restricted restricted/debian-installer universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu bionic-security main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu bionic-updates main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu bionic-proposed main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu bionic-backports main restricted universe multiverse

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

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

deb-amd64 항목은 64비트 패키지, deb-i386 항목은 32비트 패키지, deb-src 항목은 소스코드에 대응된다. 만약 64비트 패키지만 미러링할 것이면 deb-amd64 항목만 추가해도 된다.  

설정 편집을 마치고 저장을 했으면, 이제 apt-mirror를 실행해서 다운로드를 시작한다. 시간이 꽤 걸린다.

# S/W저장소 다운로드
sudo apt-mirror

다운로드가 완료되었으면 접근권한과 웹서버를 설정할 차례다. 먼저 chmod로 접근권한을 설정하자. 전체(a)를 대상으로 읽기(r) 권한과 실행(X, 디렉토리에 한정) 권한을 추가해 주면 되겠다(chmod에 대한 좀 더 자세한 내용은 이전 게시물을 참고하자. 여기로). 후에 미러 서버의 접속경로를 /var/www/ubuntu로 연결되도록 심볼릭 링크(symbolic link)를 만든다.  

# 접근권한 설정: 읽기 및 실행 추가  
sudo chmod -R a+rX /var/local_repo

# symbolic link 생성
sudo ln -s /var/local_repo/mirror/archive.ubuntu.com/ubuntu /var/www/ubuntu

apache2 프로세스가 구동중이라면 정지시킨다.

# apache2 정지
sudo systemctl stop apache2

이제 apache2 설정 파일을 편집해야 한다. /etc/apache2/sites-enabled/000-default.conf 파일을 편집.

# apache2 설정 파일 편집
sudo vi /etc/apache2/sites-enabled/000-default.conf

/etc/apache2/sites-enabled/000-default.conf 파일의 DocumentRoot 항목을 /var/www로 설정해주자.

DocumentRoot /var/www

편집과 저장이 완료되었으면 apache2 웹서버를 구동한다.

# apache2 구동
sudo systemctl start apache2

미러 서버 구성이 완료되었다. 웹브라우저에서 제대로 접속이 되는지 시험해 보자. http://127.0.0.1/ubuntu에 접속했을 때 "dists", "pool" 이렇게 두개의 디렉토리가 보인다면 정상이다.

구축한 미러 서버를 통해 S/W 패키지를 다운로드하기 위한 클라이언트 설정은 다음에 정리하기로.

728x90
Posted by 반달가면