Ossian Story
article thumbnail


[CentOS] Linux Package Management - Yum


Yum(Yellow dog Updater, Modified) 이란?


Yum은 RPM Package 설치 시 발생되는 Package의 의존성 문제를 해결한 Linux Package Management 도구입니다.

Package를 Online 기반으로 설치하며, 상황에 따라 RPM을 통한 Offline 기반 설치를 지원합니다. 또한 다수의 Package 설치도 지원합니다.



Yum 사용방법


Yum은 아래와 같은 내용으로 명령어를 사용하며 상황에 따라 옵션의 위치가 변경되어도 괜찮습니다.

 - yum [명령어] [옵션] [패키지명]


Yum의 주요 옵션

옵션명설명
 -y

 Yum 설치 시 발생되는 질문(Yes/No)을 모두 Yes로 처리합니다.
 Yum 삭제 시 삭제하려는 Package의 의존성 있는 Package까지 모두 삭제하므로 사용 시 주의해야 합니다.

 --enablerepo=[저장소명] 여러 Yum Repository를 사용할 경우 사용할 Repository를 지정합니다.
 --disablerepo=[저장소명] 해당하는 Yum Repository를 비활성화 합니다.
 --nogpgcheck 해당하는 Repository의 공개키가 없어서 서명검증에 실패할 경우 사용합니다.
 --downloadonly 해당하는 Package를 설치하지 않고 RPM으로 다운로드합니다.
 다운로드 시 기본경로는 /var/cache/yum에 다운로드 됩니다.
 --downloaddir=[경로명] downloadonly 옵션 사용 시 RPM이 다운로드 되는 경로를 지정합니다.



Yum의 주요 명령어

명령어설명
 yum install Package를 설치합니다. 설치 시 해당 Package의 의존성 있는 Package까지 같이 설치합니다.
 yum localinstall Yum Repository를 사용하지 않고 RPM으로 Offline 설치 시 사용합니다.
 RPM에 제작사의 서명이 없을 수 있으므로 --nogpgcheck 옵션을 추가하여 사용합니다.
 yum update 설치된 Package를 Update합니다. 패키지명을 넣지않을 경우 전체 시스템의 설치된 모든 Package를 업데이트합니다.
 yum check-update 설치된 Package 중 Update가 가능한 Package의 목록을 확인합니다.
 yum repolist 현재 활성화 된 Repository를 확인합니다.
 yum search 찾을 Package 및 Package Description을 검색합니다.
 yum history

 Package 설치, 변경, 삭제의 작업을 Transaction이라합니다.
 yum history는 Transaction의 내역을 확인하고 작업내역을 복원할 수 있습니다.



Yum install

 - "yum install -y httpd" 명령어를 통해 httpd Package가 설치되며 의존성 Package까지 같이 설치된 것을 확인할 수 있습니다.

[root@yum-test ~]# yum install -y httpd
Loaded plugins: fastestmirror
Determining fastest mirrors
epel/x86_64/metalink                                                                          |  19 kB  00:00:00
 * base: mirrors.cat.pdx.edu
 * epel: mirrors.develooper.com
 * extras: mirrors.ocf.berkeley.edu
 * updates: mirror.rackspace.com
...
Installed:
  httpd.x86_64 0:2.4.6-80.el7.centos
 
Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7_4.1       apr-util.x86_64 0:1.5.2-6.el7      httpd-tools.x86_64 0:2.4.6-80.el7.centos
  mailcap.noarch 0:2.1.41-2.el7
 
Complete!




Yum Update
 - "yum update -y httpd" 명령어를 통해 httpd Package를 업데이트합니다. 현재는 업데이트 할 버전이 없는 것을 확인할 수 있습니다.

[root@yum-test ~]# yum update -y httpd
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.pdx.edu
 * epel: mirrors.develooper.com
 * extras: mirrors.ocf.berkeley.edu
 * updates: mirror.rackspace.com
No packages marked for update




Yum check-update

 - "yum check-update" 명령어를 통해 현재 설치된 Package 중 Update가 가능한 Package 목록을 확인할 수 있습니다.

[root@yum-test ~]# yum check-update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.pdx.edu
 * epel: mirrors.develooper.com
 * extras: mirrors.ocf.berkeley.edu
 * updates: mirror.rackspace.com
 
iwl105-firmware.noarch                               18.168.6.1-62.2.el7_5                                    updates
iwl135-firmware.noarch                               18.168.6.1-62.2.el7_5                                    updates
iwl2000-firmware.noarch                              18.168.6.1-62.2.el7_5                                    updates
iwl2030-firmware.noarch                              18.168.6.1-62.2.el7_5                                    updates
iwl3160-firmware.noarch                              22.0.7.0-62.2.el7_5                                      updates
iwl6000g2b-firmware.noarch                           17.168.5.2-62.2.el7_5                                    updates
iwl7260-firmware.noarch                              22.0.7.0-62.2.el7_5                                      updates
iwl7265-firmware.noarch                              22.0.7.0-62.2.el7_5                                      updates
kernel.x86_64                                        3.10.0-862.3.3.el7                                       updates
kernel-tools.x86_64                                  3.10.0-862.3.3.el7                                       updates
kernel-tools-libs.x86_64                             3.10.0-862.3.3.el7                                       updates
linux-firmware.noarch                                20180220-62.2.git6d51311.el7_5                           updates
python-perf.x86_64                                   3.10.0-862.3.3.el7                                       updates




Yum search
 - "yum search nginx" 명령어를 통해 Yum Repository에 해당 Package가 존재하는지 검색합니다.

[root@yum-test ~]# yum search nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.pdx.edu
 * epel: mirrors.develooper.com
 * extras: mirrors.ocf.berkeley.edu
 * updates: mirror.rackspace.com
================================================ N/S matched: nginx =================================================
collectd-nginx.x86_64 : Nginx plugin for collectd
munin-nginx.noarch : Network-wide graphing framework (cgi files for nginx)
nextcloud-nginx.noarch : Nginx integration for NextCloud
nginx-all-modules.noarch : A meta package that installs all available Nginx modules
nginx-filesystem.noarch : The basic directory layout for the Nginx server
nginx-mod-http-geoip.x86_64 : Nginx HTTP geoip module
nginx-mod-http-image-filter.x86_64 : Nginx HTTP image filter module
nginx-mod-http-perl.x86_64 : Nginx HTTP perl module
nginx-mod-http-xslt-filter.x86_64 : Nginx XSLT module
nginx-mod-mail.x86_64 : Nginx mail modules
nginx-mod-stream.x86_64 : Nginx stream modules
owncloud-nginx.noarch : Nginx integration for ownCloud
pcp-pmda-nginx.x86_64 : Performance Co-Pilot (PCP) metrics for the Nginx Webserver
python2-certbot-nginx.noarch : The nginx plugin for certbot
nginx.x86_64 : A high performance web server and reverse proxy server
 
  Name and summary matches only, use "search all" for everything.




Yum repolist

 - "yum repolist" 명령어를 통해 현재 활성화 된 Repository 목록을 확인할 수 있습니다.

[root@yum-test ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.pdx.edu
 * epel: mirrors.develooper.com
 * extras: mirrors.ocf.berkeley.edu
 * updates: mirror.rackspace.com
repo id                                   repo name                                                            status
base/7/x86_64                             CentOS-7 - Base                                                       9,911
epel/x86_64                               Extra Packages for Enterprise Linux 7 - x86_64                       12,584
extras/7/x86_64                           CentOS-7 - Extras                                                       313
google-cloud-compute                      Google Cloud Compute                                                     10
google-cloud-sdk                          Google Cloud SDK                                                        128
updates/7/x86_64                          CentOS-7 - Updates                                                      695
repolist: 23,641




Yum history
 - "yum history list" 명령어를 통해 Yum Transaction 내역을 확인할 수 있습니다.

[root@yum-test ~]# yum history list
Loaded plugins: fastestmirror
ID     | Login user               | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
     8 | root <root>              | 2018-06-18 16:02 | Install        |    5
     7 | System <unset>           | 2018-06-11 18:38 | Install        |    1
     6 | System <unset>           | 2018-06-11 18:36 | I, U           |   44
     5 | System <unset>           | 2018-06-11 18:36 | Install        |    1
     4 | System <unset>           | 2018-06-11 18:36 | Install        |   22
     3 | System <unset>           | 2018-06-11 18:35 | Install        |    1
     2 | System <unset>           | 2018-06-11 18:35 | Install        |    1
     1 | System <unset>           | 2018-06-11 18:32 | Install        |  319
history list




Yum downloadonly
 - "yum install -y mysql --downloadonly --downloaddir=[경로명]" 명령어를 통해 Package를 RPM으로 다운로드 받습니다.

[root@yum-test ~]# yum install -y mysql --downloadonly --downloaddir=/root/yum_rpm_download
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.cat.pdx.edu
 * epel: mirrors.develooper.com
 * extras: mirrors.ocf.berkeley.edu
 * updates: mirror.rackspace.com
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.56-2.el7 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=====================================================================================================================
 Package                   Arch                     Version                             Repository              Size
=====================================================================================================================
Installing:
 mariadb                   x86_64                   1:5.5.56-2.el7                      base                   8.7 M
 
Transaction Summary
=====================================================================================================================
Install  1 Package
 
Total download size: 8.7 M
Installed size: 49 M
Background downloading packages, then exiting:
mariadb-5.5.56-2.el7.x86_64.rpm                                                               | 8.7 MB  00:00:01
exiting because "Download Only" specified
 
 
[root@yum-test yum_rpm_download]# ls
mariadb-5.5.56-2.el7.x86_64.rpm




Yum localinstall

 - "yum localinstall -y [패키지명]" 명령어를 통해 RPM Package를 설치할 수 있습니다. 단, 의존성 문제가 발생될 수 있습니다.

[root@yum-test yum_rpm_download]# yum localinstall -y mariadb-5.5.56-2.el7.x86_64.rpm
Loaded plugins: fastestmirror
Examining mariadb-5.5.56-2.el7.x86_64.rpm: 1:mariadb-5.5.56-2.el7.x86_64
Marking mariadb-5.5.56-2.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.56-2.el7 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=====================================================================================================================
 Package             Arch               Version                       Repository                                Size
=====================================================================================================================
Installing:
 mariadb             x86_64             1:5.5.56-2.el7                /mariadb-5.5.56-2.el7.x86_64              49 M
 
Transaction Summary
=====================================================================================================================
Install  1 Package
 
Total size: 49 M
Installed size: 49 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:mariadb-5.5.56-2.el7.x86_64                                                                     1/1
  Verifying  : 1:mariadb-5.5.56-2.el7.x86_64                                                                     1/1
 
Installed:
  mariadb.x86_64 1:5.5.56-2.el7
 
Complete!




Yum remove

 - "yum remove -y [패키지명]" 명령어를 통해 설치된 Package를 삭제할 수 있습니다.

[root@yum-test yum_rpm_download]# yum remove -y mariadb
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.56-2.el7 will be erased
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=====================================================================================================================
 Package                  Arch                    Version                           Repository                  Size
=====================================================================================================================
Removing:
 mariadb                  x86_64                  1:5.5.56-2.el7                    installed                   49 M
 
Transaction Summary
=====================================================================================================================
Remove  1 Package
 
Installed size: 49 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:mariadb-5.5.56-2.el7.x86_64                                                                     1/1
  Verifying  : 1:mariadb-5.5.56-2.el7.x86_64                                                                     1/1
 
Removed:
  mariadb.x86_64 1:5.5.56-2.el7
 
Complete!





profile

Ossian Story

@ossians