강좌
클라우드/리눅스에 관한 강좌입니다.
네트워크 분류

RockyLinux강좌11 : RockyLinux 로컬저장소(Local Repository) 만들어 사용하기

작성자 정보

  • 관리자 작성
  • 작성일

컨텐츠 정보

본문


RockyLinux 로컬저장소(Local Repository) 만들어 사용하기


 

1.     Repository 무엇인가


Repository RPM기반의 리눅스들의 패키지들을 존재하는 저장소이다

yum이나 dnf를 이용하여원격지의 서버에서 패키지를 설치하려고 할 때 /etc/yum.repos.d/ 디렉토리에 설정되어 있는 Repository들에서 패키지를 가져와서 설치하게 된다.

 

Repository를 정의할 때에는 repo파일을 설정해 두어야하며, 형식은 다음과 같다.

 

[저장소ID]

  name=저장소이름

baseurl=패키지와repodata가 존재하는 위치

gpgcheck=0(GPG서명사용안함) 또는 1(GPG서명사용함)

enabled=0(Repo비활성화)또는 1(Repo활성화)

 

참고로 /etc/yum.repos.d/rocky.repo 파일의 예이다.

[baseos]

name=Rocky Linux $releasever - BaseOS

mirrorlist=https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=BaseOS-$releasever$rltype

#baseurl=http://dl.rockylinux.org/$contentdir/$releasever/BaseOS/$basearch/os/

gpgcheck=1

enabled=1

countme=1

metadata_expire=6h

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9

 

 

2.     Local Repository의 필요성


패키지를 설치하거나 업데이트할 때에 대부분 /etc/yum.repos.d/ 에 설정되어 있는 원격지의  repository에서 패키지를 받아와서 실행하게 된다.

 

하지만 외부와의 통신이 엄격히 제한적인 상황에서는 이 작업이 불가능하다

수많은 서버들을 유지관리하고 있는 경우에는 로컬에서만 사용할 수 있는 repository를 만들어서 사용하는 것이 효율적일 때가 많다.

 

그리고 무엇보다 엄격하게 차단되어 있는 내부망에서 패키지 설치를 위해서 외부와 연결되게 되면 보안에 취약해질 수 있다.

 

폐쇄망에서 로컬 Repository를 운영하는 궁극적인 이유는 첫번째로 보안성, 두번째는 편의성이다.

 

 

3.     Repository 위치 확인


Repo파일들은 /etc/yum.repos.d/ 디렉토리에 존재한다.

 

[root@sulinux01 ~]# ls -l /etc/yum.repos.d/

합계 24

-rw-r--r-- 1 root root 1919  4 28 10:56 docker-ce.repo

-rw-r--r-- 1 root root 6586 12 13 15:14 rocky-addons.repo

-rw-r--r-- 1 root root 1161 12 13 15:14 rocky-devel.repo

-rw-r--r-- 1 root root 2379 12 13 15:14 rocky-extras.repo

-rw-r--r-- 1 root root 3405 12 13 15:14 rocky.repo

[root@sulinux01 ~]#

 

 


4.     기존 Repo들 백업해두기


Local Repository로 구성할 것이기 때문에 원격지 Repository 설정은 백업해 두도록 한다.

 

[root@sulinux01 ~]# cd /etc/yum.repos.d/

[root@sulinux01 yum.repos.d]#

[root@sulinux01 yum.repos.d]# ls -l

합계 24

-rw-r--r-- 1 root root 1919  4 28 10:56 docker-ce.repo

-rw-r--r-- 1 root root 6586 12 13 15:14 rocky-addons.repo

-rw-r--r-- 1 root root 1161 12 13 15:14 rocky-devel.repo

-rw-r--r-- 1 root root 2379 12 13 15:14 rocky-extras.repo

-rw-r--r-- 1 root root 3405 12 13 15:14 rocky.repo

[root@sulinux01 yum.repos.d]#

[root@sulinux01 yum.repos.d]# mkdir repo_backup

[root@sulinux01 yum.repos.d]#

[root@sulinux01 yum.repos.d]# mv *.repo ./repo_backup/

[root@sulinux01 yum.repos.d]#

[root@sulinux01 yum.repos.d]# ls -l

합계 0

drwxr-xr-x 2 root root 120  5 25 11:36 repo_backup

[root@sulinux01 yum.repos.d]#

[root@sulinux01 yum.repos.d]# ls -l repo_backup/

합계 24

-rw-r--r-- 1 root root 1919  4 28 10:56 docker-ce.repo

-rw-r--r-- 1 root root 6586 12 13 15:14 rocky-addons.repo

-rw-r--r-- 1 root root 1161 12 13 15:14 rocky-devel.repo

-rw-r--r-- 1 root root 2379 12 13 15:14 rocky-extras.repo

-rw-r--r-- 1 root root 3405 12 13 15:14 rocky.repo

[root@sulinux01 yum.repos.d]#

 

 

5.     RockyLinux DVD 마운트하기

 

로컬 저장소를 구성하기 위해서는 먼저 최신버전의 패키지들을 가져와야 한다. RockyLinux의 최신버전 패키지들을 전부 https://rockylinux.org/download/ 에서 받아오려면 시간이 많이 걸린다. 이경우에 미리 만들어둔

 RockyLinux ISO DVD를 마운트시켜서 파일을 복사해오는 것이 훨씬 빠르다

물론 직접 wget으로 https://rockylinux.org/download/에서 받아와도 무방하다.

 네트워크 상태에 따라서 다르겠지만 아마도 하루종일 다운로드만 해야 할 지 모른다.  g

그래서 RockyLinux DVD를 마운트하여 복사하고자 한다.  

 

현재 파일시스템 마운트 상황 살펴보기

[root@sulinux01 ~]# lsblk

NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS

sda           8:0    0   40G  0 disk

├─sda1        8:1    0  600M  0 part /boot/efi

├─sda2        8:2    0    1G  0 part /boot

└─sda3        8:3    0 38.4G  0 part

  ├─rl-root 253:0    0 36.4G  0 lvm  /

  └─rl-swap 253:1    0    2G  0 lvm  [SWAP]

sr0          11:0    1  8.4G  0 rom  /run/media/root/Rocky-9-1-x86_64-dvd

[root@sulinux01 ~]#

 

DVD 마운트할 디렉토리(마운트포인트) 생성하기

[root@sulinux01 ~]# ls -l /mnt

합계 0

[root@sulinux01 ~]#

[root@sulinux01 ~]# mkdir /mnt/dvd

[root@sulinux01 ~]#

/mnt/dvd 디렉토리(마운트포인트)를 생성하고 rock DVD를 여기에 마운트할 것이다.

 

DVD 마운트하기

   Rockylinux DVD를 마운트 한 후에 내용을 확인한 것이다.

[root@sulinux01 ~]# mount /dev/sr0 /mnt/dvd

mount: /mnt/dvd: WARNING: source write-protected, mounted read-only.

[root@sulinux01 ~]#

[root@sulinux01 ~]# ls -l /mnt/dvd

합계 26

drwxr-xr-x 1 root root 2048 11 24 10:48 AppStream

drwxrwxr-x 1 root root 2048 11 24 11:09 BaseOS

-rw-r--r-- 1 root root 5504 11 24 10:48 COMMUNITY-CHARTER

-rw-r--r-- 1 root root 1394 11 24 10:48 Contributors

drwxrwxr-x 1 root root 2048 11 19  2022 EFI

-rw-r--r-- 1 root root  372 11 24 10:48 EULA

-rw-r--r-- 1 root root 2204 11 24 10:48 LICENSE

-rw-r--r-- 1 root root 1750 11 24 10:48 RPM-GPG-KEY-Rocky-9

-rw-r--r-- 1 root root 3159 11 24 10:48 RPM-GPG-KEY-Rocky-9-Testing

drwxrwxr-x 1 root root 2048 11 19  2022 images

drwxrwxr-x 1 root root 2048 11 19  2022 isolinux

-rw-r--r-- 1 root root  101 11 24 11:09 media.repo

[root@sulinux01 ~]#

 

DVD 내용 복사하기

마운트한 RockyLinux DVD 파일들을 /mnt/dvd 로 복사한다. 이때 주의할 것은 .()으로 시작하는 숨김파일들까지 모두 복사해야 하기 때문에 -a옵션을 사용한다.

 

[root@sulinux01 ~]# cp -a /mnt/dvd/. /rockyiso/

[root@sulinux01 ~]#

[root@sulinux01 ~]# ls -al /rockyiso/

합계 40

drwxr-xr-x   7 root root  264 11 19  2022 .

dr-xr-xr-x. 19 root root  271  5 25 11:23 ..

-rw-rw-r--   1 root root   45 11 24 11:09 .discinfo

-rw-rw-r--   1 root root 1522 11 24 11:09 .treeinfo

drwxr-xr-x   4 root root   38 11 24 10:48 AppStream

drwxrwxr-x   4 root root   38 11 24 11:09 BaseOS

-rw-r--r--   1 root root 5504 11 24 10:48 COMMUNITY-CHARTER

-rw-r--r--   1 root root 1394 11 24 10:48 Contributors

drwxrwxr-x   3 root root   18 11 19  2022 EFI

-rw-r--r--   1 root root  372 11 24 10:48 EULA

-rw-r--r--   1 root root 2204 11 24 10:48 LICENSE

-rw-r--r--   1 root root 1750 11 24 10:48 RPM-GPG-KEY-Rocky-9

-rw-r--r--   1 root root 3159 11 24 10:48 RPM-GPG-KEY-Rocky-9-Testing

drwxrwxr-x   3 root root   59 11 19  2022 images

drwxrwxr-x   2 root root  239 11 19  2022 isolinux

-rw-r--r--   1 root root  101 11 24 11:09 media.repo

[root@sulinux01 ~]#

 

8G가 넘는 용량이기 때문에 복사하는데 상당한 시간이 걸린다. 복사된 후에 내용을 확인하였다.

 


6.     Local repo파일 작성하기


이제 Local Repository 파일을 생성한다.

[root@sulinux01 ~]#

[root@sulinux01 ~]# vi /etc/yum.repos.d/local.repo

 

[ISO_AppStream]

name=Rocky9.1_AppStream

baseurl=file:///rockyiso/AppStream/

enabled=1

gpgcheck=0

 

[ISO_BaseOS]

name=Rocky9.1_BaseOS

baseurl=file:///rockyiso/BaseOS/

enabled=1

gpgcheck=0


RockyLinux DVD의 내용을 복사했던 위치(/rockyiso/)AppStreamBaseOS의 경로를 맞게 설정했는가를 확인한다.

 

vi로 작성한 후에 다시 한번 확인한다.

[root@sulinux01 ~]# cat /etc/yum.repos.d/local.repo

[ISO_AppStream]

name=Rocky9.1_AppStream

baseurl=file:///rockyiso/AppStream/

enabled=1

gpgcheck=0

 

[ISO_BaseOS]

name=Rocky9.1_BaseOS

baseurl=file:///rockyiso/BaseOS/

enabled=1

gpgcheck=0

[root@sulinux01 ~]#


 

7.     Cache 재구성하기(makecache)

 

Cache 재구성

[root@sulinux01 ~]# dnf makecache

Rocky9.1_AppStream                                          148 MB/s | 6.4 MB     00:00

Rocky9.1_BaseOS                                             102 MB/s | 1.7 MB     00:00

메타 자료 캐쉬가 생성되었습니다.

[root@sulinux01 ~]#



 

8.     Local Repository 작동확인



이제 모든 설정작업이 끝났다.

설치한 RockyLinux 로컬저장소가 잘 작동이 되는지를 다음과 같이 확인해본다.

 

Local Repository 정상작동 확인

[root@sulinux01 ~]# yum repolist

레포지터리 ID                                             레포지터리 이름

ISO_AppStream                                             Rocky9.1_AppStream

ISO_BaseOS                                                Rocky9.1_BaseOS

[root@sulinux01 ~]#

 

dnf로 패키지 설치해보기

[root@sulinux01 ~]# dnf install tftp

마지막 메타자료 만료확인 0:06:13 이전인: 2023 05 25 () 오후 12 06 31.

종속성이 해결되었습니다.

=====================================================================

 꾸러미                  구조                      버전                          레포지터리                        크기

=====================================================================

설치 중:

 tftp                    x86_64                    5.2-37.el9                    ISO_AppStream                     33 k

 

연결 요약

=====================================================================

설치  1 꾸러미

 

전체 크기: 33 k

설치된 크기 : 53 k

진행할까요? [y/N]: y

꾸러미 내려받기 중:

연결 확인 실행 중

연결 확인에 성공했습니다.

연결 시험 실행 중

연결 시험에 성공했습니다.

연결 실행 중

  준비중                                                                                     1/1

  설치중            : tftp-5.2-37.el9.x86_64                                                    1/1

  스크립트릿 실행중 : tftp-5.2-37.el9.x86_64                                                    1/1

  확인중            : tftp-5.2-37.el9.x86_64                                                    1/1

 

설치되었습니다:

  tftp-5.2-37.el9.x86_64

 

완료되었습니다!

[root@sulinux01 ~]#

 

이상과 같이 RockyLinux 로컬 저장소를 설치하고 패키지를 직접 설치해 보았다.

 

참고로 dnf뿐아니라 yum으로 패키지 설치/업데이트를 해도 동일하게 방금 설정한 로컬저장소를 사용하게 된다.



9. 참고사항 : 저장소를 BaseOS와 AppStream으로 분리한 이유


RockLinux뿐아니라 CentOS 8과 RHEL 8 부터는 "BaseOS", "AppStream" 2개의 저장소를 사용한다. 

저장소를 이 두가지로 분리한 이유는 자주 업데이트되는 AppStream패키지들로 인하여 기반이되는 OS플랫폼관련 패키지들에 영향을 받지않고 안정성과 유연성을 때문이다. 


- BaseOS 저장소


BaseOS 리포지토리는 운영체제의 기반이 되는 최소한의 기본기능의 코어(핵심, 필수) 패키지들로 구성된다.

즉, 커널 핵심 패키지 그룹으로 하드웨어, 가상머신, 클라우드 인스턴스, 컨테이너에서 실행 가능하도록 하는 패키지들로 구성된다. 



- AppStream(애플리케이션 스트림) 저장소


AppStream은 BaseOS의 패키지외에 어플리케이션, 소프트웨어, 종속성, 데이터베이스과 관련된 패키지들로 구성된다.

즉, Apache웹서버, Cyrus-imapd, Vim 등과 같은 패키지들, 또는 Java, PHP, Python 등과 같은 개발언어 패키지들, 그리고 MariaDB, PostgreSQL 등과 같은 DBMS 패키지들로 구성된다.  AppStream 패키지들은 BaseOS 패키지들보다 훨씬 더 많이 업데이트된다. 

 

 

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,032 명
  • 현재 강좌수 :  35,773 개
  • 현재 접속자 :  270 명