본문으로 바로가기

CentOS 7 에서 로컬 yum repository 생성 + JDK 설치

category OS/Linux 2019. 6. 3. 20:14

1. 서버 Network interface 활성화

 

nmtui 사용시 네트워크 인터페이스 활성화 실패시

 

# vi /etc/sysconfig/network-scripts/ifcfg-ens192

 

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens192

TYPE=Ethernet

PROXY_METHOD=none

BROWSER_ONLY=no

BOOTPROTO=none 변경

DEFROUTE=yes

IPV4_FAILURE_FATAL=yes

IPV6INIT=no

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

IPV6_ADDR_GEN_MODE=stable-privacy

NAME=ens192

UUID=8e057613-6955-46c8-ab71-e92b601907c4

DEVICE=ens192

ONBOOT=no

IPADDR=192.168.1.55

PREFIX=32

GATEWAY=192.168.1.254

IPV6_PRIVACY=no

IPADDR1=255.255.255.0

PREFIX1=32

USERS=root

~

(이후 안되면 rebooting)

그리고 nmtui에서 ip setup 활성화, systemctl start network 실행

 

 

2. 로컬 Repository로 설정할 디렉토리 생성

 

# cd /

# mkdir localrepo

 

[root@localhost /]# mkdir localrepo

[root@localhost /]# ls

CentOS7  bin  boot  dev  etc  home  lib  lib64  localrepo  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

[root@localhost /]#

[root@localhost /]#

[root@localhost /]# df -h

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/centos-root   14G  3.3G   11G  25% /

devtmpfs                 905M     0  905M   0% /dev

tmpfs                    920M     0  920M   0% /dev/shm

tmpfs                    920M  9.0M  911M   1% /run

tmpfs                    920M     0  920M   0% /sys/fs/cgroup

/dev/sda1               1014M  178M  837M  18% /boot

tmpfs                    184M  4.0K  184M   1% /run/user/42

tmpfs                    184M   20K  184M   1% /run/user/0

/dev/sr0                 4.3G  4.3G     0 100% /run/media/root/CentOS 7 x86_64

 

 

 

3. 마운트한 ISO 미디어 파일을 디렉토리로 복사

 

[root@localhost CentOS 7 x86_64]# cp -rv /run/media/root/CentOS\ 7\ x86_64/ /localrepo/

`/run/media/root/CentOS 7 x86_64/' -> `/localrepo/CentOS 7 x86_64'

`/run/media/root/CentOS 7 x86_64/CentOS_BuildTag' -> `/localrepo/CentOS 7 x86_64/CentOS_BuildTag'

`/run/media/root/CentOS 7 x86_64/EFI' -> `/localrepo/CentOS 7 x86_64/EFI'

`/run/media/root/CentOS 7 x86_64/EFI/BOOT' -> `/localrepo/CentOS 7 x86_64/EFI/BOOT'

`/run/media/root/CentOS 7 x86_64/EFI/BOOT/BOOTIA32.EFI' -> `/localrepo/CentOS 7 x86_64/EFI/BOOT/BOOTIA32.EFI'

`/run/media/root/CentOS 7 x86_64/EFI/BOOT/BOOTX64.EFI' -> `/localrepo/CentOS 7 x86_64/EFI/BOOT/BOOTX64.EFI'

`/run/media/root/CentOS 7 x86_64/EFI/BOOT/fonts' -> `/localrepo/CentOS 7 x86_64/EFI/BOOT/fonts'

`/run/media/root/CentOS 7 x86_64/EFI/BOOT/fonts/TRANS.TBL' -> `/localrepo/CentOS 7 x86_64/EFI/BOOT/fonts/TRANS.TBL'

`/run/media/root/CentOS 7 x86_64/EFI/BOOT/fonts/unicode.pf2' -> `/localrepo/CentOS 7 x86_64/EFI/BOOT/fonts/unicode.pf2'

`/run/media/root/CentOS 7 x86_64/EFI/BOOT/grub.cfg' -> `/localrepo/CentOS 7 x86_64/EFI/BOOT/grub.cfg'

`/run/media/root/CentOS 7 x86_64/EFI/BOOT/grubia32.efi' -> `/localrepo/CentOS 7 x86_64/EFI/BOOT/grubia32.efi'

`/run/media/root/CentOS 7 x86_64/EFI/BOOT/grubx64.efi' -> `/localrepo/CentOS 7 x86_64/EFI/BOOT/grubx64.efi'

..................................... 생략 ....................................

 

4. Online Repository 설정 파일들 삭제 (또는 다른 곳으로 이동)

 

#rm -rf /etc/yum.repos.d/*

 

[root@localhost /]# rm -rf /etc/yum.repos.d/*

[root@localhost /]#

[root@localhost /]#

[root@localhost /]#

[root@localhost /]# cd /etc/yum.repos.d/*

-bash: cd: /etc/yum.repos.d/*: 그런 파일이나 디렉터리가 없습니다

 

 

 

5. Offline Repository 설정 파일 생성

 

# vi /etc/yum.repos.d/local.repo

 

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

 

 

[local]

 

 

name=local.repo

baseurl=file:///localrepo/

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPMG-GPG-KEY

설정 후 저장

 

 

6. Local Repository 업데이트

 

# createrepo /localrepo/

 

 

[root@localhost /]# createrepo /localrepo/

Spawning worker 0 with 4445 pkgs

Workers Finished

Saving Primary metadata

Saving file lists metadata

Saving other metadata

Generating sqlite DBs

Sqlite DBs complete

 

 

# yum clean all

 

 

[root@localhost /]# yum clean all

Loaded plugins: fastestmirror, langpacks

Cleaning repos: local

Cleaning up everything

Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos

 

 

 

 

# yum repolist

 

[root@localhost /]# yum repolist

Loaded plugins: fastestmirror, langpacks

local                                                                                                                                                   | 2.9 kB  00:00:00     

local/primary_db                                                                                                                                        | 3.4 MB  00:00:00     

Determining fastest mirrors

repo id                                                                            repo name                                                                             status

local                                                                              local.repo                                                                            4,445

repolist: 4,445

 

 

7. JDK 설치

 

 

7-1. 설치 가능확인

 

 

# yum list java*jdk-devel

 

[root@localhost /]# yum list java*jdk-devel

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

Available Packages

java-1.6.0-openjdk-devel.x86_64                                                        1:1.6.0.41-1.13.13.1.el7_3                                                         local

java-1.7.0-openjdk-devel.x86_64                                                        1:1.7.0.141-2.6.10.5.el7                                                           local

java-1.8.0-openjdk-devel.x86_64                                                        1:1.8.0.131-11.b12.el7                                                             local

 

 

7.2 설치

 

# yum install java-1.8.0-openjdk-devel.x86_64

 

[root@localhost /]# yum install java-1.8.0-openjdk-devel.x86_64

Loaded plugins: fastestmirror, langpacks

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.131-11.b12.el7 will be installed

--> Finished Dependency Resolution

 

Dependencies Resolved

 

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

Package                                            Arch                             Version                                             Repository                       Size

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

Installing:

java-1.8.0-openjdk-devel                           x86_64                           1:1.8.0.131-11.b12.el7                              local                           9.7 M

 

Transaction Summary

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

Install  1 Package

 

Total download size: 9.7 M

Installed size: 40 M

Is this ok [y/d/N]: y

Downloading packages:

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : 1:java-1.8.0-openjdk-devel-1.8.0.131-11.b12.el7.x86_64                                                                                                      1/1

  Verifying  : 1:java-1.8.0-openjdk-devel-1.8.0.131-11.b12.el7.x86_64                                                                                                      1/1

 

Installed:

  java-1.8.0-openjdk-devel.x86_64 1:1.8.0.131-11.b12.el7                                                                                                                       

 

Complete!

 

 

 

7.3 설치 확인

 

[root@localhost /]# rpm -qa java*jdk-devel

java-1.8.0-openjdk-devel-1.8.0.131-11.b12.el7.x86_64

 

[root@localhost /]# javac -version

javac 1.8.0_131