본문 바로가기

운영체제/Unix & Linux

[Yum] Yum Local Http Repos 구성

반응형

개요

구성

CentOS 7.6

 

단계 1) 웹서버 설치(nginx)

shell> yum install epel-release

shell> yum install nginx

 - epel-release : extra pacacke for enterprise linux, 커뮤니티 기반 저장소

 

단계 2) yum local repository 생성

 1. yum local repository 생성,설정 및 관리를 위한 패키지 설치

shell> yum install createrepo yum-utils

 2. 패키지와 관련정보를 저장할 repositories 디렉토리 생성

shell> mkdir /home/www/html/repos/{base,centosplus,extras,updates}

 3. local repository와 centos yum repository와 동기화

shell> reposync -g -l -d -m --repoid=base --newest-only --download-metadata --download_path=/home/www/html/repos
shell> reposync -g -l -d -m --repoid=centosplus --newest-only --download-metadata --download_path=/home/www/html/repos/
shell> reposync -g -l -d -m --repoid=extras --newest-only --download-metadata --download_path=/home/www/html/repos/
shell> reposync -g -l -d -m --repoid=updates --newest-only --download-metadata --download_path=/home/www/html/repos/

-g : 다운로드 완료후 gpg 검사 실패한 파일 삭제

-l : yum plugin  지원 활성화

-d :  신규 다운로드 패키지가 로컬에 저장된 패키지를 대체할 경우 로컬 패키지 삭제

--downloadcomps(-m) : comps.xml 파일 다운로드 활성화, 

--repoid(-r) : repository ID

--newest-only(-n) : repos 내에 각 패키지의 가장 최신 버전만 다운로드

--download-metadata : 모든 메타데이타 다운로드

--download_path(-p) : 패키지 다운로드 경로(디폴트 현재 디렉토리), 예로 repoid가 base일경우 /home/www/html/repos/base 디렉토리에 패키지가 다운로드 됨

** download-metadata, -m 옵션은  yum 의 yum-security 또는 'groupinstall' 기능 사용 같은 다양한 플러그인을 사용하도록 허가한다.

 4. 다운받은 local repository에 새로운 repodata 생성

shell> createrepo -g comps.xml /home/www/html/repos/base/  
shell> createrepo -g comps.xml /home/www/html/repos/centosplus/
shell> createrepo -g comps.xml /home/www/html/repos/extras/  
shell> createrepo -g comps.xml /home/www/html/repos/updates/  

 -g 옵션 : 패키지 그룹정보를 업데이트하기 위해 사용됨

 - createrepo 샘플 출력

shell> createrepo -g comps.xml /home/www/html/repos/base/
Spawning worker 0 with 5049 pkgs
Spawning worker 1 with 5048 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
shell> cd /home/www/html/repos/base/
shell> ls -F
4af1fba0c1d6175b7e3c862b4bddfef93fffb84c37f7d5f18cfbff08abc47f8a-c7-x86_64-comps.xml.gz
Packages/
comps.xml
repodata/ => repodata 디렉토리 생성 및 하위에 repository 설정파일 생성됨
shell> 

 

단계 3) 웹서버 구성(ngnix)

shell> vi /etc/nginx/conf.d/repos.conf

server {
        listen   80;
        server_name  repos.test.lab; # repos.test.lab을 자신의 환경에 맞게 도메인 수정
        root   /home/www/html/repos;
        location / {
                index  index.php index.html index.htm;
                autoindex on; #enable listing of directory index
        }
}

 

단계 4) cron 등록(자동으로 패키지를 다운로드 받을수 있도록 cron job에 등록)

 1.  yum repository 동기화 스크립트 생성

  shell> /etc/cron.daily/update-localrepos

#!/bin/bash
##specify all local repositories in a single variable
LOCAL_REPOS=”base centosplus extras updates”
##a loop to update repos one at a time 
for REPO in ${LOCAL_REPOS}; do
reposync -g -l -d -m --repoid=$REPO --newest-only --download-metadata --download_path=/home/www/html/repos/
createrepo -g comps.xml /var/www/html/repos/$REPO/  
done

 2. cron script 에 실행 권한 부여

  shell> chmod 755 /etc/cron.daily/update-localrepos

 3. cron 스케쥴 등록

  shell> crontab -e

0 0 * * * * /etc/cron.daily/update-localrepos

 

단계 5) 클라이언트 머신에서 local yum repository 구성

 1. local repos 추가

   shell> vim /etc/yum.repos.d/local-repos.repo

[local-base]
name=CentOS Base
baseurl=http://repos.test.lab/base/
gpgcheck=0
enabled=1

[local-centosplus]
name=CentOS CentOSPlus
baseurl=http://repos.test.lab/centosplus/
gpgcheck=0
enabled=1

[local-extras]
name=CentOS Extras
baseurl=http://repos.test.lab/extras/
gpgcheck=0
enabled=1

[local-updates]
name=CentOS Updates
baseurl=http://repos.test.lab/updates/
gpgcheck=0
enabled=1

 2. yum repository 리스트 확인

  shell> yum repolist

repo id               repo name                                           status
base/7/x86_64         CentOS-7 - Base                                     10,097
epel/x86_64           Extra Packages for Enterprise Linux 7 - x86_64      13,509
extras/7/x86_64       CentOS-7 - Extras                                      307
local-base            CentOS Base                                         10,097
local-centosplus      CentOS CentOSPlus                                        0
local-extras          CentOS Extras                                            0
local-updates         CentOS Updates                                           0
updates/7/x86_64      CentOS-7 - Updates                                   1,012
repolist: 35,022

 3. local repository에서 패키지 설치

  shell>  yum --disablerepo=\* --enablerepo=local-base update yum

shell> yum --disablerepo=\* --enablerepo=local-base update yum
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package yum.noarch 0:3.4.3-150.el7.centos will be updated
중략
---> Package rpm-sign.x86_64 0:4.11.3-21.el7 will be updated
---> Package rpm-sign.x86_64 0:4.11.3-40.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch       Version                     Repository      Size
================================================================================
Updating:
 yum                noarch     3.4.3-163.el7.centos        local-base     1.2 M
Updating for dependencies:
 rpm                x86_64     4.11.3-40.el7               local-base     1.2 M
 rpm-build          x86_64     4.11.3-40.el7               local-base     149 k
 rpm-build-libs     x86_64     4.11.3-40.el7               local-base     107 k
 rpm-libs           x86_64     4.11.3-40.el7               local-base     278 k
 rpm-python         x86_64     4.11.3-40.el7               local-base      83 k
 rpm-sign           x86_64     4.11.3-40.el7               local-base      48 k

Transaction Summary
================================================================================
Upgrade  1 Package (+6 Dependent packages)

Total download size: 3.0 M
Is this ok [y/d/N]: y
Downloading packages:

 

반응형

'운영체제 > Unix & Linux' 카테고리의 다른 글

[Ubuntu] Ubuntu 18 네임서버 설정  (0) 2020.03.18
virbr0 인터페이스 삭제  (0) 2020.03.16
[Yum] Yum 파일 구조  (0) 2020.01.16
[Yum] Yum 명령어  (0) 2020.01.16
프로세스 모든 인자(argument) 표시 - solaris  (0) 2019.12.24