«   2021/04   »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
04-16 16:02
Notice
Today
202
Total
1,418,505
관리 메뉴

변군이글루

[Linux] CentOS Yum Repository 서버 구축 본문

* 리눅스

[Linux] CentOS Yum Repository 서버 구축

변군 변군이글루 2020. 12. 10. 13:53

CentOS Yum Repository 서버 구축

repository 구축을 위한 필수 패키지 다운로드

$ yum install -y createrepo yum-utils

디렉터리 설계

/app/repo_root/reop

$ tree -L 5
.
└── repo
    ├── centos
    │   ├── 7 -> 7.9.2009
    │   ├── 7.9.2009
    │   │   ├── extras
    │   │   │   └── x86_64
    │   │   ├── isos
    │   │   │   └── x86_64
    │   │   ├── os
    │   │   │   └── x86_64
    │   │   └── updates
    │   │       └── x86_64
    │   ├── 8 -> 8.3.2011
    │   └── 8.3.2011
    │       ├── isos
    │       │   └── x86_64
    │       └── os
    │           └── x86_64
    └── epel
        ├── 7
        │   └── x86_64
        │       ├── Packages
        │       ├── debug
        │       ├── drpms
        │       └── repodata
        └── 8
            └── Everything
                └── x86_64

저장소 생성

###CentOS7
$ mkdir -p repo/centos/7.9.2009/{centosplus,extras,isos,os,updates}/x86_64

###CentOS8
$ mkdir -p repo/centos/8.3.2011/{isos,os}/x86_64

### 레포지토리 생성
$ createrepo repo

패키지 업데이트 스크립트(mirror synchronization)

centos8_mirror.sh 스크립트 편집

#!/bin/bash

ContentDir="centos"
ReleaseVer="8"
BaseList="BaseOS AppStream extras"
#BaseList="BaseOS"
BaseArch="x86_64"
LocalDirectory=/app/repo_root/repo

for REPO in ${BaseList[@]}
do
  #reposync -p /app/repo_root/repo/centos/8 --repoid=BaseOS --download-metadata --newest-only
  #reposync -p /app/repo_root/repo/centos/8 --repoid=AppStream --download-metadata --newest-only
  reposync -p ${LocalDirectory}/${ContentDir}/${ReleaseVer} --repoid=${REPO} --download-metadata --newest-only
done

centos_mirror.sh 스크립트 편집

#!/bin/bash

ContentDir="centos"
ReleaseVer="7"
#BaseList="os updates extras centosplus virt"
BaseList="os updates extras"
BaseArch="x86_64"
LocalDirectory=/app/repo_root/repo/centos

RSYNC="/usr/bin/rsync -aqHz --delete"
MirrorUrl="rsync://ftp.kaist.ac.kr/CentOS"

for ver in $ReleaseVer
do
  for arch in $BaseArch
  do
    for base in $BaseList
    do
      ${RSYNC} ${MirrorUrl}/${ver}/${base}/${arch} ${LocalDirectory}/${ver}/${base}/
    done
  done
done

epel8_mirror.sh 스크립트 편집

#!/bin/bash 

ContentDir="epel"
ReleaseVer="8"
BaseList="Everything"
BaseArch="x86_64"
LocalDirectory="/app/repo_root/repo"

RSYNC="/usr/bin/rsync -aqHz --delete"
MirrorUrl="dl.fedoraproject.org::fedora-epel"

for ver in ${ReleaseVer}
do
  for arch in ${BaseArch}
  do
    ${RSYNC} ${MirrorUrl}/${ver}/${BaseList}/${arch}/ ${LocalDirectory}/${ContentDir}/${ver}/${BaseList}/${BaseArch}
  done
done

epel_mirror.sh 스크립트 편집

#!/bin/bash 

ContentDir="epel"
ReleaseVer="7"
BaseList=""
BaseArch="x86_64"
LocalDirectory="/app/repo_root/repo"

RSYNC="/usr/bin/rsync -aqHz --delete"
MirrorUrl="dl.fedoraproject.org::fedora-epel"

for ver in $ReleaseVer
do
  for arch in $BaseArch
  do
    ${RSYNC} ${MirrorUrl}/${ver}/${arch}/ ${LocalDirectory}/${ContentDir}/${ver}/${arch}
    createrepo ${LocalDirectory}/${ContentDir}/${ver}/${arch}/
  done
done

웹 서버 구성

클라이언트 설정

repo 파일 다운로드

### CentOS7
curl -Ssf http://pkg.sangchul.kr/dl/CentOS7-Base.repo -o /etc/yum.repos.d/CentOS-Base.repo
curl -Ssf http://pkg.sangchul.kr/dl/epel7.repo -o /etc/yum.repos.d/epel.repo

### CentOS8
curl -Ssf http://pkg.sangchul.kr/dl/CentOS8-Base.repo -o /etc/yum.repos.d/CentOS-Base.repo
curl -Ssf http://pkg.sangchul.kr/dl/epel8.repo -o /etc/yum.repos.d/epel.repo

repo 파일

CentOS7-Base.repo

# CentOS-Base.repo
[base]
name=CentOS-$releasever - Base
baseurl=http://pkg.sangchul.kr/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates 
[updates]
name=CentOS-$releasever - Updates
baseurl=http://pkg.sangchul.kr/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://pkg.sangchul.kr/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://pkg.sangchul.kr/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

CentOS8-Base.repo

# CentOS-Base.repo
[BaseOS]
name=CentOS-$releasever - Base
baseurl=http://pkg.sangchul.kr/$contentdir/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

epel7.repo

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://pkg.sangchul.kr/pub/epel/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://pkg.sangchul.kr/pub/epel/7/$basearch/debug
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://pkg.sangchul.kr/pub/epel/7/SRPMS
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

epel8.repo

[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
baseurl=http://pkg.sangchul.kr/pub/epel/$releasever/Everything/$basearch
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

[epel-debuginfo]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug
baseurl=http://pkg.sangchul.kr/pub/epel/$releasever/Everything/$basearch/debug
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

[epel-source]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Source
baseurl=http://pkg.sangchul.kr/pub/epel/$releasever/Everything/SRPMS
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

 

 

0 Comments
댓글쓰기 폼