"데비안 미러 서버를 만드는 방법"의 두 판 사이의 차이
491번째 줄: | 491번째 줄: | ||
<pre> | <pre> | ||
$ tail -f /home/ftpsync/log/rsync-ftpsync-cd.log | $ tail -f /home/ftpsync/log/rsync-ftpsync-cd.log | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | === 저장소(debian-multimedia) 미러링 === | ||
+ | |||
+ | ==== /home/ftpsync/etc/ftpsync-multimedia.conf 파일 생성 ==== | ||
+ | /home/ftpsync/etc/ftpsync.conf.sample 파일을 복사해서 ftpsync-multimedia.conf 파일을 생성합니다. | ||
+ | |||
+ | <pre> | ||
+ | $ id | ||
+ | uid=1001(ftpsync) gid=1001(ftpsync) groups=1001(ftpsync) | ||
+ | $ cp /home/ftpsync/etc/ftpsync.conf.sample /home/ftpsync/etc/ftpsync-multimedia.conf | ||
+ | </pre> | ||
+ | |||
+ | ==== /home/ftpsync/etc/ftpsync-multimedia.conf 파일 설정 ==== | ||
+ | ftpsync-security.conf 파일은 데비안 미러 서버에서 'debian-multimedia' 저장소를 다운로드하는 데 사용합니다. 저는 ftpsync-cd.conf 파일을 이용해 http://mirror.debianusers.or.kr/debian-multimedia/ 저장소를 만들었습니다. | ||
+ | 제가 사용하는 ftpsync-multimedia.conf는 다음과 같습니다. | ||
+ | |||
+ | <syntaxhighlight lang="diff"> | ||
+ | ######################################################################## | ||
+ | ######################################################################## | ||
+ | ## This is a sample configuration file for the ftpsync mirror script. ## | ||
+ | ## Only options most users may need are included. For documentation ## | ||
+ | ## and all available options see ftpsync.conf(5). ## | ||
+ | ######################################################################## | ||
+ | ######################################################################## | ||
+ | |||
+ | - # MIRRORNAME=`hostname -f` | ||
+ | + MIRRORNAME=`hostname -f` | ||
+ | - # TO="/srv/mirrors/debian/" | ||
+ | + TO="/data/mirrors/debian-multimedia/" | ||
+ | # MAILTO="$LOGNAME" | ||
+ | # HUB=false | ||
+ | |||
+ | ######################################################################## | ||
+ | ## Connection options | ||
+ | ######################################################################## | ||
+ | |||
+ | - RSYNC_HOST= | ||
+ | + RSYNC_HOST="ftp.kaist.ac.kr" | ||
+ | - RSYNC_PATH="debian" | ||
+ | + RSYNC_PATH="debian-multimedia" | ||
+ | # RSYNC_USER= | ||
+ | # RSYNC_PASSWORD= | ||
+ | |||
+ | ######################################################################## | ||
+ | ## Mirror information options | ||
+ | ######################################################################## | ||
+ | |||
+ | # INFO_MAINTAINER="Admins <admins@example.com>, Person <person@example.com>" | ||
+ | # INFO_SPONSOR="Example <https://example.com>" | ||
+ | # INFO_COUNTRY=DE | ||
+ | # INFO_LOCATION="Example" | ||
+ | # INFO_THROUGHPUT=10Gb | ||
+ | |||
+ | ######################################################################## | ||
+ | ## Include and exclude options | ||
+ | ######################################################################## | ||
+ | |||
+ | - # ARCH_INCLUDE= | ||
+ | + #ARCH_INCLUDE="all amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x" | ||
+ | + ARCH_INCLUDE="amd64 i386 source" | ||
+ | # ARCH_EXCLUDE= | ||
+ | |||
+ | ######################################################################## | ||
+ | ## Log option | ||
+ | ######################################################################## | ||
+ | |||
+ | - # LOGDIR= | ||
+ | + LOGDIR="/home/ftpsync/log" | ||
+ | |||
+ | + ## limit I/O bandwidth. Value is KBytes per second, unset or 0 means unlimited | ||
+ | + RSYNC_BW="1024" # (1024KByte/s / 1024) * 8 = 8Mbit/s | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | ==== 미러링 실행 ==== | ||
+ | |||
+ | <pre> | ||
+ | $ /home/ftpsync/bin/./ftpsync sync:archive:multimedia | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | ==== 미러링 로그 확인 ==== | ||
+ | |||
+ | 아래 명령으로 미러링의 실시간 로그를 확인할 수 있습니다. | ||
+ | |||
+ | <pre> | ||
+ | $ tail -f /home/ftpsync/log/rsync-ftpsync-multimedia.log | ||
</pre> | </pre> |
2021년 5월 1일 (토) 22:40 판
목차
Nginx 설치 및 설정
$ sudo apt install nginx nginx-extras libnginx-mod-http-geoip libnginx-mod-http-fancyindex
nginx에서 디렉터리 목록 나열을 허용하기(fancyindex 이용)
/etc/nginx/sites-available/default 파일에서 ‘location /’ 항목에 아래 초록색 내용을 추가합니다. fancyindex를 이용하면 웹에서 파일과 디렉터리 목록을 예쁘게 볼 수 있습니다.
(.. 생략 ..)
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#autoindex on; # 디렉터리 목록을 나열한다.
#autoindex_exact_size off;
+ fancyindex on; # 디렉터리 목록을 나열한다.(fancyindex 사용)
+ fancyindex_exact_size off;
try_files $uri $uri/ =404;
}
(.. 생략 ..)
nginx에서 해외 아이피 차단. 국내 아이피만 접속 허용(geoip 이용)
/etc/nginx/nginx.conf 파일 수정
/etc/nginx/nginx.conf 파일에 아래 초록색으로 표시한 내용을 추가합니다.
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
+ # 우리나라를 제외한 해외 아이피를 모두 차단함.
+ geoip_country /usr/share/GeoIP/GeoIP.dat;
+ map $geoip_country_code $allowed_country {
+ default no;
+ KR yes;
+ }
##
# Basic Settings
##
sendfile on;
(..생략..)
/etc/nginx/sites-available/default 파일 수정
(..생략..)
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
fancyindex on;
fancyindex_exact_size off;
+ if ($allowed_country = no) {
+ return 444;
+ }
+ try_files $uri $uri/ /index.html;
- #try_files $uri $uri/ =404;
}
(..생략..)
Nginx 재시작
$ sudo systemctl restart nginx
rsync 설치
$ sudo apt install rsync
MRTG 설치 및 설정 [1]
$ sudo apt install snmpd snmp mrtg
/etc/snmp/snmpd.conf 파일을 아래처럼 수정합니다.
(..생략..)
-#rocommunity public localhost
+rocommunity public localhost
(..생략..)
snmpd를 재시작합니다.
$ systemctl restart snmpd
mrtg 디렉터리를 생성합니다.
$ sudo mkdir /data/mrtg
mrtg.cfg 파일을 백업합니다.
$ sudo cp /etc/mrtg.cfg /etc/mrtg.cfg.bak
/etc/mrtg 파일을 편집합니다.
(..생략..)
- #WorkDir: /var/www/mrtg
+ WorkDir: /data/mrtg
(..생략..)
+ # to get bits instead of bytes and graphs growing to the right
+ Options[_]: growright, bits
(..생략..)
cfgmaker public@localhost > /etc/mrtg.cfg
MRTG의 index.html 파일을 생성합니다.
indexmaker /etc/mrtg.cfg > /data/mrtg/index.html
MRTG 데이터는 /data/mrtg에 저장됩니다. 이 데이터를 웹에서 보여주고자 /var/www/mrtg로 심볼릭링크를 걸었습니다.
$ ln -s /data/mrtg/ /var/www/mrtg
이제 MRTG의 인덱스 페이지를 볼 수 있습니다. 저의 경우는 http://mirror.debianusers.or.kr/mrtg/ 에서 MRTG의 인덱스 페이지를 확인할 수 있습니다.
디렉터리(/data)
디렉터리(/data)의 퍼미션 변경
$ sudo chmod 757 data
미러용 디렉터리(/data/mirrors) 생성
$ id uid=1001(ftpsync) gid=1001(ftpsync) groups=1001(ftpsync) $ mkdir /data/mirrors
ftpsync
사용자 계정(ftpsync) 생성
$ sudo adduser ftpsync
crontab을 사용할 수 있는 사용자 설정
/etc/cron.allow 파일에 'ftpsync'를 추가한 후 저장합니다.
root
westporch
+ ftpsync
크론을 다시 시작합니다.
$ sudo systemctl restart cron
ftpsync 다운로드
아래 명령어로 ftpsync를 내려받습니다.
$ wget https://ftp-master.debian.org/ftpsync.tar.gz -P /home/ftpsync
다운로드 받은 파일을 압축 해제합니다. ftpsync.tar.gz 파일의 압축을 해제하면 distrib 디렉터리가 생깁니다.
디렉터리 변경(이동)
$ mv /home/ftpsync/distrib/bin /home/ftpsync/ $ mv /home/ftpsync/distrib/etc /home/ftpsync/
로그 디렉터리 생성
$ id uid=1001(ftpsync) gid=1001(ftpsync) groups=1001(ftpsync) $ mkdir /home/ftpsync/log
저장소(debian) 미러링
/home/ftpsync/etc/ftpsync.conf 파일 생성
/home/ftpsync/etc/ftpsync.conf.sample 파일을 복사해서 ftpsync.conf 파일을 생성합니다.
$ id uid=1001(ftpsync) gid=1001(ftpsync) groups=1001(ftpsync) $ cp /home/ftpsync/etc/ftpsync.conf.sample /home/ftpsync/etc/ftpsync.conf
/home/ftpsync/etc/ftpsync.conf 파일 설정
ftpsync.conf 파일은 데비안 미러 서버에서 'debian' 저장소를 다운로드하는 데 사용합니다. 저는 ftpsync.conf 파일을 이용해 http://mirror.debianusers.or.kr/debian/ 저장소를 만들었습니다. 제가 사용하는 ftpsync.conf는 다음과 같습니다.
########################################################################
########################################################################
## This is a sample configuration file for the ftpsync mirror script. ##
## Only options most users may need are included. For documentation ##
## and all available options see ftpsync.conf(5). ##
########################################################################
########################################################################
- # MIRRORNAME=`hostname -f`
+ MIRRORNAME=`hostname -f`
- # TO="/srv/mirrors/debian/"
+ TO="/data/mirrors/debian/"
# MAILTO="$LOGNAME"
# HUB=false
########################################################################
## Connection options
########################################################################
- RSYNC_HOST=
+ RSYNC_HOST= "ftp.kaist.ac.kr"
RSYNC_PATH="debian"
# RSYNC_USER=
# RSYNC_PASSWORD=
########################################################################
## Mirror information options
########################################################################
# INFO_MAINTAINER="Admins <admins@example.com>, Person <person@example.com>"
# INFO_SPONSOR="Example <https://example.com>"
# INFO_COUNTRY=DE
# INFO_LOCATION="Example"
# INFO_THROUGHPUT=10Gb
########################################################################
## Include and exclude options
########################################################################
- # ARCH_INCLUDE=
+ #ARCH_INCLUDE="all amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x"
+ ARCH_INCLUDE="amd64 i386 source"
# ARCH_EXCLUDE=
########################################################################
## Log option
########################################################################
- # LOGDIR=
+ LOGDIR="/home/ftpsync/log"
+ ## limit I/O bandwidth. Value is KBytes per second, unset or 0 means unlimited
+ RSYNC_BW="1024" # (1024KByte/s / 1024) * 8 = 8Mbit/s
미러링 실행
$ /home/ftpsync/bin/./ftpsync
미러링 로그 확인
아래 명령으로 미러링의 실시간 로그를 확인할 수 있습니다.
$ tail -f /home/ftpsync/log/rsync-ftpsync.log
저장소(debian-security) 미러링
/home/ftpsync/etc/ftpsync-security.conf 파일 생성
/home/ftpsync/etc/ftpsync.conf.sample 파일을 복사해서 ftpsync-security.conf 파일을 생성합니다.
$ id uid=1001(ftpsync) gid=1001(ftpsync) groups=1001(ftpsync) $ cp /home/ftpsync/etc/ftpsync.conf.sample /home/ftpsync/etc/ftpsync-security.conf
/home/ftpsync/etc/ftpsync-security.conf 파일 설정
ftpsync-security.conf 파일은 데비안 미러 서버에서 'debian-security' 저장소를 다운로드하는 데 사용합니다. 저는 ftpsync-security.conf 파일을 이용해 http://mirror.debianusers.or.kr/debian-security/ 저장소를 만들었습니다. 제가 사용하는 ftpsync-security.conf는 다음과 같습니다.
########################################################################
########################################################################
## This is a sample configuration file for the ftpsync mirror script. ##
## Only options most users may need are included. For documentation ##
## and all available options see ftpsync.conf(5). ##
########################################################################
########################################################################
- # MIRRORNAME=`hostname -f`
+ MIRRORNAME=`hostname -f`
- # TO="/srv/mirrors/debian/"
+ TO="/data/mirrors/debian-security/"
# MAILTO="$LOGNAME"
# HUB=false
########################################################################
## Connection options
########################################################################
- RSYNC_HOST=
+ RSYNC_HOST="ftp.kaist.ac.kr"
- RSYNC_PATH="debian"
+ RSYNC_PATH="debian-security"
# RSYNC_USER=
# RSYNC_PASSWORD=
########################################################################
## Mirror information options
########################################################################
# INFO_MAINTAINER="Admins <admins@example.com>, Person <person@example.com>"
# INFO_SPONSOR="Example <https://example.com>"
# INFO_COUNTRY=DE
# INFO_LOCATION="Example"
# INFO_THROUGHPUT=10Gb
########################################################################
## Include and exclude options
########################################################################
- # ARCH_INCLUDE=
+ #ARCH_INCLUDE="all amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x"
+ ARCH_INCLUDE="amd64 i386 source"
# ARCH_EXCLUDE=
########################################################################
## Log option
########################################################################
- # LOGDIR=
+ LOGDIR="/home/ftpsync/log"
+ ## limit I/O bandwidth. Value is KBytes per second, unset or 0 means unlimited
+ RSYNC_BW="1024" # (1024KByte/s / 1024) * 8 = 8Mbit/s
미러링 실행
$ /home/ftpsync/bin/./ftpsync sync:archive:security
미러링 로그 확인
아래 명령으로 미러링의 실시간 로그를 확인할 수 있습니다.
$ tail -f /home/ftpsync/log/rsync-ftpsync-security.log
저장소(debian-cd) 미러링
/home/ftpsync/etc/ftpsync-cd.conf 파일 생성
/home/ftpsync/etc/ftpsync.conf.sample 파일을 복사해서 ftpsync-cd.conf 파일을 생성합니다.
$ id uid=1001(ftpsync) gid=1001(ftpsync) groups=1001(ftpsync) $ cp /home/ftpsync/etc/ftpsync.conf.sample /home/ftpsync/etc/ftpsync-cd.conf
/home/ftpsync/etc/ftpsync-cd.conf 파일 설정
ftpsync-security.conf 파일은 데비안 미러 서버에서 'debian-cd' 저장소를 다운로드하는 데 사용합니다. 저는 ftpsync-cd.conf 파일을 이용해 http://mirror.debianusers.or.kr/debian-cd/ 저장소를 만들었습니다. 제가 사용하는 ftpsync-cd.conf는 다음과 같습니다.
########################################################################
########################################################################
## This is a sample configuration file for the ftpsync mirror script. ##
## Only options most users may need are included. For documentation ##
## and all available options see ftpsync.conf(5). ##
########################################################################
########################################################################
- # MIRRORNAME=`hostname -f`
+ MIRRORNAME=`hostname -f`
- # TO="/srv/mirrors/debian/"
+ TO="/data/mirrors/debian-cd/"
# MAILTO="$LOGNAME"
# HUB=false
########################################################################
## Connection options
########################################################################
- RSYNC_HOST=
+ RSYNC_HOST="ftp.kaist.ac.kr"
- RSYNC_PATH="debian"
+ RSYNC_PATH="debian-cd"
# RSYNC_USER=
# RSYNC_PASSWORD=
########################################################################
## Mirror information options
########################################################################
# INFO_MAINTAINER="Admins <admins@example.com>, Person <person@example.com>"
# INFO_SPONSOR="Example <https://example.com>"
# INFO_COUNTRY=DE
# INFO_LOCATION="Example"
# INFO_THROUGHPUT=10Gb
########################################################################
## Include and exclude options
########################################################################
- # ARCH_INCLUDE=
+ #ARCH_INCLUDE="all amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x"
+ ARCH_INCLUDE="amd64 i386"
# ARCH_EXCLUDE=
########################################################################
## Log option
########################################################################
- # LOGDIR=
+ LOGDIR="/home/ftpsync/log"
+ ## limit I/O bandwidth. Value is KBytes per second, unset or 0 means unlimited
+ RSYNC_BW="1024" # (1024KByte/s / 1024) * 8 = 8Mbit/s
미러링 실행
$ /home/ftpsync/bin/./ftpsync sync:archive:cd
미러링 로그 확인
아래 명령으로 미러링의 실시간 로그를 확인할 수 있습니다.
$ tail -f /home/ftpsync/log/rsync-ftpsync-cd.log
저장소(debian-multimedia) 미러링
/home/ftpsync/etc/ftpsync-multimedia.conf 파일 생성
/home/ftpsync/etc/ftpsync.conf.sample 파일을 복사해서 ftpsync-multimedia.conf 파일을 생성합니다.
$ id uid=1001(ftpsync) gid=1001(ftpsync) groups=1001(ftpsync) $ cp /home/ftpsync/etc/ftpsync.conf.sample /home/ftpsync/etc/ftpsync-multimedia.conf
/home/ftpsync/etc/ftpsync-multimedia.conf 파일 설정
ftpsync-security.conf 파일은 데비안 미러 서버에서 'debian-multimedia' 저장소를 다운로드하는 데 사용합니다. 저는 ftpsync-cd.conf 파일을 이용해 http://mirror.debianusers.or.kr/debian-multimedia/ 저장소를 만들었습니다. 제가 사용하는 ftpsync-multimedia.conf는 다음과 같습니다.
########################################################################
########################################################################
## This is a sample configuration file for the ftpsync mirror script. ##
## Only options most users may need are included. For documentation ##
## and all available options see ftpsync.conf(5). ##
########################################################################
########################################################################
- # MIRRORNAME=`hostname -f`
+ MIRRORNAME=`hostname -f`
- # TO="/srv/mirrors/debian/"
+ TO="/data/mirrors/debian-multimedia/"
# MAILTO="$LOGNAME"
# HUB=false
########################################################################
## Connection options
########################################################################
- RSYNC_HOST=
+ RSYNC_HOST="ftp.kaist.ac.kr"
- RSYNC_PATH="debian"
+ RSYNC_PATH="debian-multimedia"
# RSYNC_USER=
# RSYNC_PASSWORD=
########################################################################
## Mirror information options
########################################################################
# INFO_MAINTAINER="Admins <admins@example.com>, Person <person@example.com>"
# INFO_SPONSOR="Example <https://example.com>"
# INFO_COUNTRY=DE
# INFO_LOCATION="Example"
# INFO_THROUGHPUT=10Gb
########################################################################
## Include and exclude options
########################################################################
- # ARCH_INCLUDE=
+ #ARCH_INCLUDE="all amd64 arm64 armel armhf i386 mips mips64el mipsel ppc64el s390x"
+ ARCH_INCLUDE="amd64 i386 source"
# ARCH_EXCLUDE=
########################################################################
## Log option
########################################################################
- # LOGDIR=
+ LOGDIR="/home/ftpsync/log"
+ ## limit I/O bandwidth. Value is KBytes per second, unset or 0 means unlimited
+ RSYNC_BW="1024" # (1024KByte/s / 1024) * 8 = 8Mbit/s
미러링 실행
$ /home/ftpsync/bin/./ftpsync sync:archive:multimedia
미러링 로그 확인
아래 명령으로 미러링의 실시간 로그를 확인할 수 있습니다.
$ tail -f /home/ftpsync/log/rsync-ftpsync-multimedia.log