리눅스 (Linux)2016. 1. 6. 11:29

패키지 설치를 위한 RPM 과 YUM


1. RPM (Redhat Package Manager)

1) rpm 파일의 형식

패키지 이름-버전-릴리즈번호.os버전.아키텍쳐.rpm

CentOS 6 버전의 X window 용 에디터인 gedit 패키지를 예로 들어보자.

gedit-2.28.4-3.el6.x86_64.rpm

* 패키지 이름: gedit

* 버전: 2.28.4

* 릴리즈번호: 3

* OS버전: el6

* 아키텍쳐: x86_64 (64bit)


2) 자주 쓰이는 rpm 명령어

* 설치 : rpm -Uvh <패키지 파일(.rpm)>

U : 설치되어 있는 기존 패키지가 없다면 i 옵션과 같이 일반적인 설치를 하고, 기존에 패키지가 이미 설치되어 있다면 업그레이드를 한다.

v : 설치 과정의 확인

h : 설치 과정을 # 마크로 확인해 줌


* 삭제 : rpm -e <패키지 이름>


* 설치되어 있는 패키지 확인

rpm -qa <패키지 이름> : 설치되어 있는지 확인

rpm -qf <파일의 절대 경로>  : 이미 설치되어 있는 파일이 어느 패키지에 포함 된 것인지 확인

rpm -ql <패키지 이름>  : 특정 패키지에 어떤 파일들이 포함되어 있는지 확인

rpm -qi <패키지 이름>  : 설치된 패키지의 상세정보


* 아직 설치되어 있지 않은 패키지에 대한 확인

rpm -qlp <패키지 파일>  : 패키지 파일에 어떤 파일들이 포함되어 있는지 확인

rpm -qip <패키지 파일>  : 설치할 패키지의 상세정보

* mc 패키지를 가지고 위의 명령어 들을 테스트 해보자 (CentOS 기준)

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
[root@ServerA Packages]# pwd
/media/CentOS_6.4_Final/Packages
[root@ServerA Packages]#
[root@ServerA Packages]# rpm -qa mc
[root@ServerA Packages]#
[root@ServerA Packages]# ls mc-*
mc-4.7.0.2-3.el6.x86_64.rpm
[root@ServerA Packages]#
[root@ServerA Packages]# rpm -qip mc-4.7.0.2-3.el6.x86_64.rpm
warning: mc-4.7.0.2-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Name        : mc                           Relocations: (not relocatable)
Version     : 4.7.0.2                           Vendor: CentOS
Release     : 3.el6                         Build Date: Mon 23 Aug 2010 05:24:04 AM KST
Install Date: (not installed)               Build Host: c6b3.bsys.dev.centos.org
Group       : System Environment/Shells     Source RPM: mc-4.7.0.2-3.el6.src.rpm
Size        : 5662814                          License: GPLv2
Signature   : RSA/8, Sun 03 Jul 2011 01:44:55 PM KST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http://bugs.centos.org>
URL         : http://www.midnight-commander.org/
Summary     : User-friendly text console file manager and visual shell
Description :
Midnight Commander is a visual shell much like a file manager, only
with many more features. It is a text mode application, but it also
includes mouse support. Midnight Commander's best features are its
ability to FTP, view tar and zip files, and to poke into RPMs for
specific files.
[root@ServerA Packages]#
[root@ServerA Packages]# rpm -Uvh mc-4.7.0.2-3.el6.x86_64.rpm
warning: mc-4.7.0.2-3.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing...                ########################################### [100%]
   1:mc                     ########################################### [100%]
[root@ServerA Packages]#
[root@ServerA Packages]# rpm -qi mc
Name        : mc                           Relocations: (not relocatable)
Version     : 4.7.0.2                           Vendor: CentOS
Release     : 3.el6                         Build Date: Mon 23 Aug 2010 05:24:04 AM KST
Install Date: Tue 12 Nov 2013 07:01:46 AM KST      Build Host: c6b3.bsys.dev.centos.org
Group       : System Environment/Shells     Source RPM: mc-4.7.0.2-3.el6.src.rpm
Size        : 5662814                          License: GPLv2
Signature   : RSA/8, Sun 03 Jul 2011 01:44:55 PM KST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem <http: bugs.centos.org="">
URL         : http://www.midnight-commander.org/
Summary     : User-friendly text console file manager and visual shell
Description :
Midnight Commander is a visual shell much like a file manager, only
with many more features. It is a text mode application, but it also
includes mouse support. Midnight Commander's best features are its
ability to FTP, view tar and zip files, and to poke into RPMs for
specific files.
[root@ServerA Packages]#
[root@ServerA Packages]# rpm -ql mc
/etc/mc
/etc/mc/Syntax
/etc/mc/cedit.menu
/etc/mc/edit.indent.rc
/etc/mc/edit.spell.rc
/etc/mc/extfs
~~~~~~
[root@ServerA Packages]#
[root@ServerA Packages]# rpm -e mc
[root@ServerA Packages]#
[root@ServerA Packages]# rpm -qa mc
[root@ServerA Packages]#


2. YUM (Yellowdog Updater Modified)

1) YUM 의 개념

RPM 의 단점인 의존성 문제를 해결하기 위해 제공되는 것이 바로 YUM 이다. 특정 패키지를 설치 할 때 의존성이 있는 다른 패키지를 먼저 자동으로 설치해 줌으로써 의존성 문제를 해결한다. 

또한 rpm 같은 경우는 설치할 패키지 파일을 CD에서 복사하거나 다운로드 해서 설치해야 하지만 YUM 은 인터넷만 연결되어 있다면 인터넷을 통하여 rpm 파일이 저장된 저장소 (repository)에서 설치하고자 하는 rpm 파일들을 자동으로 다운로드 해서 설치해 준다. 


2) YUM  사용법

* 기본설치 : yum (-y) install <패키지 이름>

-y 옵션은 패키지 다운로드 후 설치할 것인지 묻는 부분을 자동으로 넘어가게 해준다. 


* rpm 파일로 설치 : yum install <rpm 파일 이름>

rpm 파일을 이미 가지고 있더라도 rpm -Uvh 명령 대신 yum 을 사용하면 좋은 점은 의존성 파일들은 알아서 인터넷 repository 에서 다운로드 해서 설치해 준다. 


* 업데이트 목록 체크 : yum check-update

시스템에 설치된 패키지 중에서 업데이트가 가능한 패키지의 목록을 출력해 준다.


* 업데이트 : yum update <패키지 이름>

* 삭제 : yum remove <패키지 이름>

* 정보 확인 : yum info <패키지 이름>

* 특정 파일이 속한 패키지 이름 확인 : yum provides <파일 이름>


* 의존성이 있는 mysql 패키지를 yum 을 이용해서 설치 및 명령어 테스트 해보자.

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
## 정보 확인
 
[root@ServerA ~]# yum info mysql
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.neowiz.com
 * extras: ftp.neowiz.com
 * updates: ftp.neowiz.com
base                                                                                                                                                                   | 3.7 kB     00:00    
base/primary_db                                                                                                                                                        | 4.4 MB     00:00    
extras                                                                                                                                                                 | 3.4 kB     00:00    
extras/primary_db                                                                                                                                                      |  18 kB     00:00    
updates                                                                                                                                                                | 3.4 kB     00:00    
updates/primary_db                                                                                                                                                     | 5.1 MB     00:01    
Available Packages
Name        : mysql
Arch        : x86_64
Version     : 5.1.69
Release     : 1.el6_4
Size        : 907 k
Repo        : updates
Summary     : MySQL client programs and shared libraries
URL         : http://www.mysql.com
License     : GPLv2 with exceptions
Description : MySQL is a multi-user, multi-threaded SQL database server. MySQL is a
            : client/server implementation consisting of a server daemon (mysqld)
            : and many different client programs and libraries. The base package
            : contains the standard MySQL client programs and generic MySQL files.
 
## 설치
 
[root@ServerA ~]# yum -y install mysql
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.neowiz.com
 * extras: ftp.neowiz.com
 * updates: ftp.neowiz.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.x86_64 0:5.1.69-1.el6_4 will be installed
--> Processing Dependency: mysql-libs = 5.1.69-1.el6_4 for package: mysql-5.1.69-1.el6_4.x86_64
--> Running transaction check
---> Package mysql-libs.x86_64 0:5.1.66-2.el6_3 will be updated
---> Package mysql-libs.x86_64 0:5.1.69-1.el6_4 will be an update
--> Finished Dependency Resolution
 
Dependencies Resolved
 
==============================================================================================================================================================================================
 Package                                       Arch                                      Version                                             Repository                                  Size
==============================================================================================================================================================================================
Installing:
 mysql                                         x86_64                                    5.1.69-1.el6_4                                      updates                                    907 k
Updating for dependencies:
 mysql-libs                                    x86_64                                    5.1.69-1.el6_4                                      updates                                    1.2 M
 
Transaction Summary
==============================================================================================================================================================================================
Install       1 Package(s)
Upgrade       1 Package(s)
 
Total download size: 2.1 M
Downloading Packages:
(1/2): mysql-5.1.69-1.el6_4.x86_64.rpm                                                                                                                                 | 907 kB     00:00    
(2/2): mysql-libs-5.1.69-1.el6_4.x86_64.rpm                                                                                                                            | 1.2 MB     00:00    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                         3.6 MB/s | 2.1 MB     00:00    
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
 Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
 Package: centos-release-6-4.el6.centos.10.x86_64 (@anaconda-CentOS-201303020151.x86_64/6.4)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating   : mysql-libs-5.1.69-1.el6_4.x86_64                                                                                                                                           1/3
  Installing : mysql-5.1.69-1.el6_4.x86_64                                                                                                                                                2/3
  Cleanup    : mysql-libs-5.1.66-2.el6_3.x86_64                                                                                                                                           3/3
  Verifying  : mysql-5.1.69-1.el6_4.x86_64                                                                                                                                                1/3
  Verifying  : mysql-libs-5.1.69-1.el6_4.x86_64                                                                                                                                           2/3
  Verifying  : mysql-libs-5.1.66-2.el6_3.x86_64                                                                                                                                           3/3
 
Installed:
  mysql.x86_64 0:5.1.69-1.el6_4                                                                                                                                                              
 
Dependency Updated:
  mysql-libs.x86_64 0:5.1.69-1.el6_4                                                                                                                                                         
 
Complete!
 
## 삭제
 
[root@ServerA ~]# yum remove mysql
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package mysql.x86_64 0:5.1.69-1.el6_4 will be erased
--> Finished Dependency Resolution
 
Dependencies Resolved
 
============================================================================================================================================================================================================================================
 Package                                               Arch                                                   Version                                                        Repository                                                Size
============================================================================================================================================================================================================================================
Removing:
 mysql                                                 x86_64                                                 5.1.69-1.el6_4                                                 @updates                                                 2.4 M
 
Transaction Summary
============================================================================================================================================================================================================================================
Remove        1 Package(s)
 
Installed size: 2.4 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : mysql-5.1.69-1.el6_4.x86_64                                                                                                                                                                                              1/1
  Verifying  : mysql-5.1.69-1.el6_4.x86_64                                                                                                                                                                                              1/1
 
Removed:
  mysql.x86_64 0:5.1.69-1.el6_4                                                                                                                                                                                                            
 
Complete!


3) YUM 설정 파일

YUM 설정 파일은 /etc/yum.conf 와 /etc/yum.repos.d/ 디렉토리가 있다. 

둘 다 따로 설정해 줄 필요는 없지만, 만약 mirrorlist URL 같은 변경이 필요하다면 /etc/yum.repos.d/ 안에 파일들의 URL 을 수정해 주면 된다.

'리눅스 (Linux)' 카테고리의 다른 글

리눅스/네트워크(network) 설정  (0) 2016.01.06
CentOS 리눅스 yum 사용법  (0) 2016.01.06
CentOS 7 root 패스워드 초기화  (0) 2016.01.06
페도라 리눅스  (0) 2015.12.30
리눅스 재부팅 안내 명령어  (0) 2015.12.25
Posted by 랩퍼우