YJWANG

CentOS Local Repository 구성하기 본문

00.OS

CentOS Local Repository 구성하기

왕영주 2021. 10. 26. 11:54

yum 과 같은 package manager를 사용하기 위해서는 repo가 필요합니다.

External Network로 연결이 안된 서버는 해당 repo를 받아 올 수 없기에 local 서버에 repo를 구성하는 방법으로 진행됩니다.

 

repo 구축에 필요한 RPM 및 iso 파일을 준비합니다.

[root@localhost ~]# ls -l CentOS-7-x86_64-Everything-2009.iso 
-rw-r--r-- 1 root root 10200547328 Oct 25 09:54 CentOS-7-x86_64-Everything-2009.iso

 

iso파일을 mount 합니다. (rpm 패키지가 별도로 있다면 해당 단계를 무시합니다.)

[root@localhost ~]# mount CentOS-7-x86_64-Everything-2009.iso /mnt
mount: /dev/loop0 is write-protected, mounting read-only

[root@localhost ~]# df -h /mnt
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop0      9.5G  9.5G     0 100% /mnt

 

패키지들이 복사될 directory를 생성합니다.

[root@localhost ~]# mkdir -p /media/localrepo/Packages

 

directory에 필요한 패키지들을 복사합니다.

[root@localhost ~]# cp -rvp /mnt/Packages/* /media/localrepo/Packages/

 

repodata를 iso에서 복사합니다. (rpm 패키지가 별도로 있다면 해당 단계를 무시합니다.)

[root@localhost ~]# cp -rvp /mnt/repodata /media/localrepo/

 

rpm 파일을 수동으로 복사한 경우 repodata를 생성합니다.

[root@localhost ~]# createrepo /media/localrepo/
Spawning worker 0 with 315 pkgs
Spawning worker 1 with 315 pkgs
Spawning worker 2 with 315 pkgs
Spawning worker 3 with 315 pkgs
Spawning worker 4 with 315 pkgs
Spawning worker 5 with 315 pkgs
Spawning worker 6 with 315 pkgs
Spawning worker 7 with 315 pkgs
Spawning worker 8 with 315 pkgs
Spawning worker 9 with 315 pkgs
Spawning worker 10 with 315 pkgs
Spawning worker 11 with 315 pkgs
Spawning worker 12 with 315 pkgs
Spawning worker 13 with 315 pkgs
Spawning worker 14 with 315 pkgs
Spawning worker 15 with 315 pkgs
Spawning worker 16 with 315 pkgs
Spawning worker 17 with 315 pkgs
Spawning worker 18 with 315 pkgs
Spawning worker 19 with 315 pkgs
Spawning worker 20 with 315 pkgs
Spawning worker 21 with 315 pkgs
Spawning worker 22 with 315 pkgs
Spawning worker 23 with 315 pkgs
Spawning worker 24 with 314 pkgs
Spawning worker 25 with 314 pkgs
Spawning worker 26 with 314 pkgs
Spawning worker 27 with 314 pkgs
Spawning worker 28 with 314 pkgs
Spawning worker 29 with 314 pkgs
Spawning worker 30 with 314 pkgs
Spawning worker 31 with 314 pkgs

 

repo config 파일을 생성합니다.

[root@localhost ~]# cat /etc/yum.repos.d/local.repo
[local]
name=local-repo
baseurl=file:///media/localrepo/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

이후 yum cache를 초기화하고 패키지를 불러 오는지 확인합니다.

[root@localhost repodata]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: local
Cleaning up list of fastest mirrors
Other repos take up 36 M of disk space (use --verbose for details)

[root@localhost repodata]# yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
local                                                                                                                                                                                                                  | 2.9 kB  00:00:00     
local/primary_db                                                                                                                                                                                                       | 6.1 MB  00:00:00     
repo id                                                                                                           repo name                                                                                                             status
local                                                                                                             local-repo                                                                                                            10,072
repolist: 10,072

 

반응형