VIDEOCUBE
사설 yum 서버를 구축해보자 본문
사설 yum 서버 구축하기
web server 를 한대 준비해보자
yum install httpd
auditd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
crond 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
htcacheclean 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
httpd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
ip6tables 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
iptables 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
netconsole 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
netfs 0:해제 1:해제 2:해제 3:활성 4:활성 5:활성 6:해제
network 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
postfix 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
rdisc 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
restorecond 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
rsyslog 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
saslauthd 0:해제 1:해제 2:해제 3:해제 4:해제 5:해제 6:해제
sshd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
udev-post 0:해제 1:활성 2:활성 3:활성 4:활성 5:활성 6:해제
부팅 후에 자동으로 올라오도록 설정한다
chkconfig httpd on
httpd 0:해제 1:해제 2:활성 3:활성 4:활성 5:활성 6:해제
root@rpm:/root> service httpd start
httpd (을)를 시작 중: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.1.7 for ServerName
[ OK ]
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 924/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1000/master
tcp 0 0 :::80 :::* LISTEN 1129/httpd
tcp 0 0 :::22 :::* LISTEN 924/sshd
tcp 0 0 ::1:25 :::* LISTEN 1000/master
여기까지 기본 아파치를 설치한다..
Could not reliably determine the server's fully qualified domain name, using 192.168.1.7 for ServerName
이 메세지가 참 거슬린다..
vi /etc/httpd/conf/httpd.conf
#ServerName 를 다음과 같이 설정한다.
repo.videocube.com:80
root@rpm:/root> service httpd restart
메세지가.. 없어졌다..
이전 사설 dns 구축 편에서 작업했던 Zone 파일에 다음 내용을 추가하여 재시작한다.
repo A 192.168.1.7
root@dns:/var/named> nslookup repo.videocube.lab
Server: 192.168.1.6
Address: 192.168.1.6#53
Name: repo.videocube.lab
Address: 192.168.1.7
root@rpm:/root> ping repo.videocube.lab
PING repo.videocube.lab (192.168.1.7) 56(84) bytes of data.
64 bytes from rpm (192.168.1.7): icmp_seq=1 ttl=64 time=0.022 ms
64 bytes from rpm (192.168.1.7): icmp_seq=2 ttl=64 time=0.071 ms
64 bytes from rpm (192.168.1.7): icmp_seq=3 ttl=64 time=0.054 ms
64 bytes from rpm (192.168.1.7): icmp_seq=4 ttl=64 time=0.054 ms
64 bytes from rpm (192.168.1.7): icmp_seq=5 ttl=64 time=0.181 ms
64 bytes from rpm (192.168.1.7): icmp_seq=6 ttl=64 time=0.130 ms
web 으로 호출해보자 ...
외부에서 접속 하기전에 방화벽 설정이 정상적으로 되어 있는지 확인해보자
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
service iptables restart
iptables: 방화벽 규칙을 지웁니다: [ OK ]
iptables: 체인을 ACCEPT 규칙으로 설정 중: filter [ OK ]
iptables: 모듈을 언로드하는 중: [ OK ]
iptables: 방화벽 규칙 적용 중: [ OK ]
/etc/yum.repos.d 다음 폴더로 이동을 합니다.
vi videocube.repo
[videocube]
name = videocube repository
baseurl=http://repo.videocube.lab/repo/$releasever
gpgcheck=0
enabled=1
파일을 생성 후
다음 명령어를 실행 합니다.
root@rpm:/etc/yum.repos.d> yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirror.cdnetworks.com
* extras: centos.mirror.cdnetworks.com
* updates: centos.mirror.cdnetworks.com
http://repo.videocube.lab/repo/6/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
Trying other mirror.
repo id repo name status
base CentOS-6 - Base 6,706
extras CentOS-6 - Extras 46
updates CentOS-6 - Updates 756
videocube videocube repository 0
repolist: 7,508
http://repo.videocube.lab/repo/6/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
/repo/6/repodata/repomd.xml ==> 호출을 했더니 404....로 나옵니다.
tail -f /etc/httpd/logs/access_log 를 확인해 보면 접속 로그를 확인하실 수 있습니다.
192.168.1.7 - - [04/Nov/2017:00:58:23 +0900] "GET /repo/6/repodata/repomd.xml HTTP/1.1" 404 308 "-" "urlgrabber/3.9.1 yum/3.2.29"
/repo/6/repodata/repomd.xml 여기에서 6는 현재 설치되어 있는 OS release version 을 뜻합니다.
CentOS 7.x 이면 yum 실행 시 /repo/7/repodata/repomd.xml 로 호출이 됩니다.
os6, os7 폴더를 /data/rpm 안에 생성합니다.
mkdir -p /data/rpm/os6
mkdir -p /data/rpm/os7
apache 에서는 /repo/6 로 요청이 올때는 /data/rpm/os6 로 /repo/7 로 요청이 올때는 /data/rpm/os7 으로 바라보도록 설정하겠습니다.
vi /etc/httpd/conf/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
<Directory />
AllowOverride none
#Require all denied #apache 2.4 인 경우
Deny from denied #apache 2.2 인 경우
</Directory>
DocumentRoot "/data/rpm"
<Directory "/data/rpm">
Options Indexes FollowSymLinks
AllowOverride All
#Require all denied #apache 2.4 인 경우
Order allow,deny #apache 2.2 인 경우
Allow from all #apache 2.2 인 경우
</Directory>
<IfModule rewrite_module>
RewriteEngine On
#RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^/repo/([0-9]+)\.?([0-9.]+)?/?$ /centos$1 [L]
RewriteRule ^/repo/([0-9]+)\.?([0-9.]+)?/(.+) /centos$1/$3 [L]
</IfModule>
위와 같은 항목을 찾아서 수정합니다.
/data/rpm/os6, /data/rpm/os7 안에 index.html 을 각각 작성한 후에 정확하게 요청에 따라 분기되는지 확인합니다.
/repodata/repomd.xml 을 만들려면 다음과 같이 createrepo 를 설치한다.
yum
install
createrepo
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirror.cdnetworks.com
* extras: ftp.tsukuba.wide.ad.jp
* updates: ftp.tsukuba.wide.ad.jp
http://repo.videocube.lab/repo/6/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: videocube. Please verify its path and try again
위와 같이 나온다면..
vi /etc/yum.repos.d/videocube.repo
enabled=1 => 0 으로 설정합니다.
설치가 완료가 되면 다음과 같이 실행을 합니다.
/usr/bin/createrepo --update /data/rpm/os6
/usr/bin/createrepo --update /data/rpm/os7
/data/rpm/os6,
/data/rpm/os7 해당 폴더에 가면
├── index.html
└── repodata
├── 401dc19bda88c82c403423fb835844d64345f7e95f5b9835888189c03834cc93-filelists.xml.gz
├── 6bf9672d0862e8ef8b8ff05a2fd0208a922b1f5978e6589d87944c88259cb670-other.xml.gz
├── 77a287c136f4ff47df506229b9ba67d57273aa525f06ddf41a3fef39908d61a7-other.sqlite.bz2
├── 8596812757300b1d87f2682aff7d323fdeb5dd8ee28c11009e5980cb5cd4be14-primary.sqlite.bz2
├── dabe2ce5481d23de1f4f52bdcfee0f9af98316c9e0de2ce8123adeefa0dd08b9-primary.xml.gz
├── f8606d9f21d61a8bf405af7144e16f6d7cb1202becb78ba5fea7d0f1cd06a0b2-filelists.sqlite.bz2
└── repomd.xml
/repodata/repomd.xml 경로가 생성되는 것을 확인 하실 수 있습니다.
vi /etc/yum.repos.d/videocube.repo
enabled=0 => 1 으로 설정합니다.
Repository 연결 확인
yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.mirror.cdnetworks.com
* extras: ftp.tsukuba.wide.ad.jp
* updates: ftp.tsukuba.wide.ad.jp
repo id repo name status
base CentOS-6 - Base 6,706
extras CentOS-6 - Extras 46
updates CentOS-6 - Updates 756
videocube videocube repository 0
repolist: 7,508
crontab -e 해서 다음과 같이 설정하도록 합니다.
##################repository crontab#################
*/5 * * * * /usr/bin/createrepo --update /data/rpm/os6 > /dev/null 2>&1
*/5 * * * * /usr/bin/createrepo --update /data/rpm/os7 > /dev/null 2>&1
5분 마다 해당 폴더를 갱신하도록 하였습니다.
그럼 실제 다른 서버에서 편하게 Repository 를 연결하고, yum 을 이용한 설치를 하도록..
내일은 활용하는 방법을 찾아봐야겠습니다.
'시스템' 카테고리의 다른 글
Jenkins (젠킨스) 를 설치해보자 (0) | 2017.11.10 |
---|---|
GitLab을 설치해 보자!! (0) | 2017.11.09 |
RPM을 사설 yum에 등록하여 활용하기 (0) | 2017.11.05 |
사설 DNS 구축해 보기 문제해결 (0) | 2017.11.03 |
사설 DNS 구축해 보기 (0) | 2017.11.02 |