linux class 1 페이지

본문 바로가기
사이트 내 전체검색


회원로그인

linux class

압축유틸리티/백업복구/패키지관리

페이지 정보

작성자 admin 작성일15-12-23 15:28 조회223회 댓글0건

본문

압축 utility

gzip 리눅스에서 가장 많이 사용되는 압축 프로그램이다.

man gzip
GZIP(1) GZIP(1)
NAME gzip, gunzip, zcat - compress or expand files
(gzip외에 옆에 두개의 gunzip, zcat 명령은 서로 관련 있는 명령어라는 의미이다)
SYNOPSIS gzip [ -acdfhlLnNrtvV19 ] [-S suffix] [ name ... ]
gunzip [ -acfhlLnNrtvV ] [-S suffix] [ name ... ] zcat [ -fhLV ] [ name ... ]

옵션이 많지만 자주 사용되는 옵션은 몇 개 안된다.


주요옵션

압축시 숫자 1 ~ 9 (정수) : 압축시 사용하는 옵션으로 숫자가 1에 가까울수록 압축효율은 낮고
압축시간을 단축된다.
숫자가 9에 가까울수록 압축효율은 높고 압축시간은 길어진다.

압축해제시 -d (또는 gunzip)

ex)
mkdir /tmp/test
cd /tmp/test

[root@river test]# cp /bin/a* /etc/syslog.conf ./ (실습을 위해 몇 개의 파일을 복사한다)

[root@river test]# lsarch ash ash.static aumix-minimal awk syslog.conf

[root@river test]# gzip * a.gz gzip: a.gz: No such file or directory

모든 파일을 압축한 후 a.gz 파일 하나로 만들려고 했으나 되지 않는다.gzip 뒤에 압축할 대상 만 적을 수 있을 뿐이다.
만들어질 파일은 결정하지 못한다. mswinodws 에서 사용되는 압축프로그램처럼 하나로 묶어주는 기능은 갖고 있지 못하다.
이것은 하나의 명령어는 최소한의 필요한 작업만 할 수 있도록 만들어져 있기 때문이다. unix의 철학이기도 하다.
압축 프로그램은 단지 압축과 관련된 일만 한다.

[root@river test]# lsarch.gz ash.gz ash.static.gz aumix-minimal.gz awk.gz syslog.conf.gz

[root@river test]#

파일들이 각각 압축되었다. 그러나 이렇게 압축한다면 관리하기 어려울 것이다. 예를 들어서 인터넷에 올리거나
메일로 보내거나 해야 한다면 지금처럼 몇 개 안되지만 수십 개 또는 수백 개의 파일로 이루어져 있다면 곤란할 것이다.
그런 경우 하나로 묶어줄 필요가 있다.

파일묶기

tar (Tape Archive) - 파일명이 의미하는 것과 같이 tar는 데이터를 자기테이프에 백업하기 위한 용도로 많이 쓰이는 명령어이다.
그러나 압축하기 전에 파일을 먼저 하나로 묶기 위해서도 많이 사용한다.

인터넷에 올라와 있는 linux 관련 소스패키지들은 파일명이 xxx.tar.gz 또는 xxx.tar.bz2 이런식의 이름을 가지는 파일들이 많다.
이 파일명이 의미하는 것은 어떤 파일들을 tar로 먼저 하나로 묶고 그 파일을 다시 압축프로그램으로 압축했다는 의미이다.

물론, 용량이 그리 크지 않다면 tar로 묶기만 하고 압축은 하지 않아도 될 것이다.

tar 주요옵션 (tar 명령어도 옵션이 매우 많다)

파일묶을때

tar -cvf 타겟파일 소스파일(디렉토리도 가능)
-c : 묶기
-v (verbose) : 진행과정을 보여준다.

이 옵션은 부가적인 것이다. 사용하지 않아도 된다.
-f :

묶인파일 풀때

tar -xvf 파일명
-x : 풀기


풀지않고 안에 파일리스트만 보고자 할때
tar -tvf 파일명-t : 묶인 파일 list 보기

ex)[root@river test]# tar -cvf test.tar *archashash.staticaumix-minimalawksyslog.conf
[root@river test]#

[root@river test]# ls -l
합계 1780-rwxr-xr-x 1 root root 2644 5월 9 11:57 arch
-rwxr-xr-x 1 root root 92444 5월 9 11:57 ash
-rwxr-xr-x 1 root root 492968 5월 9 11:57 ash.static
-rwxr-xr-x 1 root root 10456 5월 9 11:57 aumix
-minimal-rwxr-xr-x 1 root root 294332 5월 9 11:57 awk
-rw-r--r-- 1 root root 693 5월 9 11:57 syslog.conf
-rw-r--r-- 1 root root 901120 5월 9 12:10 test.tar
[root@river test]#

생성된 tar 파일 크기가 원래 파일을 다 합한 크기보다 더 크다. 압축된 것이 아님을 알 수 있다.
이제 tar 파일을 압축해보자

우선 압축하기전에 압축효율을 확인해보기 위해 tar 파일을 다른 이름으로 몇 개 복사한다.

[root@river test]# cp test.tar test1.tar

[root@river test]# cp test.tar test2.tar

[root@river test]# cp test.tar test3.tar

[root@river test]# ls -l test*
-rw-r--r-- 1 root root 901120 5월 9 12:10 test.tar
-rw-r--r-- 1 root root 901120 5월 9 12:16 test1.tar
-rw-r--r-- 1 root root 901120 5월 9 12:16 test2.tar
-rw-r--r-- 1 root root 901120 5월 9 12:16 test3.tar

[root@river test]# time gzip test.tar
real 0m0.194suser 0m0.190ssys 0m0.000s

time 명령은 time 의 인수로 사용되는 명령의 실행시간을 측정하는 프로그램이다.
출력 결과 중 real이 명령 실행 시 완료까지 걸린 시간을 나타낸다.

[root@river test]# time gzip test3.tar
real 0m0.194suser 0m0.180ssys 0m0.010s

[root@river test]# time gzip -1 test1.tar
real 0m0.083suser 0m0.080ssys 0m0.000s

[root@river test]# time gzip -9 test2.tar
real 0m0.409suser 0m0.410ssys 0m0.000s

[root@river test]# ls -l test*
-rw-r--r-- 1 root root 901120 5월 9 12:10 test.tar
-rw-r--r-- 1 root root 448839 5월 9 12:16 test1.tar.gz
-rw-r--r-- 1 root root 417022 5월 9 12:16 test2.tar.gz
-rw-r--r-- 1 root root 418790 5월 9 12:16 test3.tar.gz
[root@river test]#

압축효율이 높을수록 시간이 많이 걸리는 것을 알 수 있으며 옵션을 사용하지 않아도 됨을 알 수 있다.
옵션을 사용하지 않았을 때의 압축효율과 시간은 위의 출력결과를 참조하라. 사실, 파일이 아주 크지 않다면
굳이 옵션을 사용해야 할 필요가 없을 것이다.

이번에는 압축해제를 해보자. 압축해제는 압축의 역순으로 해야 한다.

[root@river test]# gunzip test.tar.gz

[root@river test]# tar -tvf test1.tar.gz

[root@river test]# gunzip test1.tar.gz (이것은 gzip -d test1.tar.gz) 와 같다.

[root@river test]# lstest.tar test1.tar test2.tar.gz test3.tar.gz

압축이 풀리면서 용량이 늘어난다.

[root@river test]# tar -tvf test1.tar (풀기 전에 먼저 어떤 파일들을 포함하는지 확인)
-rwxr-xr-x root/root 2644 2007-05-09 11:57:01 arch
-rwxr-xr-x root/root 92444 2007-05-09 11:57:01 ash
-rwxr-xr-x root/root 492968 2007-05-09 11:57:01 ash.static
-rwxr-xr-x root/root 10456 2007-05-09 11:57:01 aumix-minimal
-rwxr-xr-x root/root 294332 2007-05-09 11:57:01 awk
-rw-r--r-- root/root 693 2007-05-09 11:57:01 syslog.conf

[root@river test]# tar -xvf test1.tar
arch
ash
ash.static
aumix-minimal
awk
syslog.conf
[root@river test]# ls
arch ash ash.static aumix-minimal awk syslog.conf test.tar test1.tar test2.tar.gz test3.tar.gz

[root@river test]#

제대로 풀렸다.

bzip2

압축 tool 이 여러 가지가 있으나 압축에 대한 기본개념은 큰 차이가 없다. 그러므로 한 가지 압축프로그래만 잘 알아도
다른 압축툴을 쓰는데 별 어려움이 없을 것이다.

[root@river test]# ls
test.tar

[root@river test]# cp test.tar test1.tar

[root@river test]# cp test.tar test2.tar

[root@river test]# gzip -9 test1.tar

[root@river test]# bzip2 test2.tar

[root@river test]# ls -l
합계 1680
-rw-r--r-- 1 root root 901120 5월 9 12:10 test.tar
-rw-r--r-- 1 root root 417022 5월 9 12:36 test1.tar.gz
-rw-r--r-- 1 root root 385616 5월 9 12:36 test2.tar.bz2
[root@river test]#

test.tar 파일 하나만 남겨두고 모두 삭제한 후 다시 두개의 다른 파일명으로 복사를 했다. 그
리고 gzip 과 bzip2 로 각각 압축했다. 출력결과를 보면 gzip2 로 최대한 압축효율을 높인것 보다
bzip2 로 압축한것이 용량이 더 작다는 것을 알 수 있다. 이것이 bzip2 압축 프로그램의 가장 큰 장점이다.

용량이 아주 큰 파일들은 최대한 용량을 줄이기 위해 bzip2 를 많이 사용한다.
그 외의 경우에는 주로 gzip 을 많이 사용한다.

backup / restore

백업

- 시스템이나 저장된 데이터에 문제가 생겼을때 복원하기 위하여 백업한다.

- 데이터가 손실될수 있는 경우
시스템 크래쉬, 커널패닉,Disk Fail, 하드웨어 장애
운영자의 실수,
허가받지 않은 사용자에 의한 데이터 파괴.
낙뢰, 화재, 침수등의 재난

백업종류

Full backup (완전백업)
파일시스템 전체를 백업

Incremental backup (증분백업)
이전에 백업한 시점을 기준으로 변경되거나 추가된 데이터만 백업

Differential backup (차등백업)
- 전체 백업한 시점을 기준으로 변경되거나 추가된 데이터만 백업
- full backup 이후로 부터 시간이 멀어질수록 백업하는데 시간과 용량이 더 필요해진다.

백업매체
자기테이프,하드디스크, CD-RW,usb 메모리 등 데이터를 기록할 수 있는 각종 매체.

백업 명령어

tar (tape archive)

incremental backup

tar 의 -g, --listed-incremental 옵션이 필요하다.

/dev/sdb2 95195 6822 83458 8% /mnt/backup
/dev/sdb1 95179 5652 84613 7% /home

ex)
/home 디렉토리의 계정을 /mnt/backup 디렉토리에 백업을 받으려면

백업스케쥴은 아래와 같다고 가정.
월 : 풀백업
화 ~ 금 : 증분백업

월 : tar -g /mnt/backup/home.backup.list -cvzf /mnt/backup/home0.backup.tar.gz ./
화 : tar -g /mnt/backup/home.backup.list -cvzf /mnt/backup/home1.backup.tar.gz ./
수 : tar -g /mnt/backup/home.backup.list -cvzf /mnt/backup/home2.backup.tar.gz ./
... 이하생략

*. home.backup.list 은 백업할때의 정보가 저장되고 이후 증분백업할때 참고되어진다.
Restore는 full backup 부터 복구한다음 화요일 -> 수요일 -> 목요일 ... 백업데이터를 차례대로
풀어줘야 한다.

rm -rf /home/*
[root@centos1 home]# tar -xvzf /mnt/backup/home0.backup.tar.gz
[root@centos1 home]# tar -xvzf /mnt/backup/home1.backup.tar.gz
... 이하생략.



백업스크립트

#! /bin/bash

backup_dir=/mnt/backup
time=$(date +%Y%m%d%H%M)
day=$(date +%a)
backup_source=/home

if [ ! -d $backup_dir ]
then
mkdir $backup_dir
fi

if [ $day = "일" ]
then
rm -f $backup_dir/home.backup.list
tar -g $backup_dir/home.backup.list -czf $backup_dir/home_$time.full-backup.tar.gz $backup_source
else
tar -g $backup_dir/home.backup.list -czf $backup_dir/home_$time.backup.tar.gz $backup_source
fi


*. /etc/crontab 파일에 등록하여 주기적으로 자동 백업이 되게 한다.

ex)
0 1 * * * root /root/bin/backup.sh

[root@centos1 home]# touch newtestfile
[root@centos1 home]# vi sysuer1/.bash_profile
[root@centos1 home]#

*. 특정디렉토리 제외하려면
[root@centos1 backup]# tar -cvf homeA.tar /home/sysuer1 /home/sysuer2 --exclude /home/sysuer1/test1 --exclude /home/sysuer2/test1/

--exclude 옵션을 사용한다. 
 

dd
디스크를 복제하거나 파티션내의 모든 데이터를 복제할때 유용하게 사용될 수 있다.
디스크 전체를 복제할때는 소스디스크와 타겟디스크 용량이 같아야 한다.

dd if=/ of=/dev/st0 ; 파일시스템 전체를 테이프 드라이버에 백업.
dd if=/dev/sda1 of=/dev/st0
dd if=/dev/sda1 of=/dev/sdb1
dd if=/dev/sda of=/dev/sdc

cpio - copy files to and from archives

도움말문서 http://heirloom.sourceforge.net/man/cpio.1.html#1
[root@centos1 ~]# cpio --help
Usage: cpio [OPTION...] [destination-directory]

주요옵션
-o : 표준입력으로부터 경로명의 파일목록을 읽어스 그 파일명을 경로명 상태정보와 함께 표준출력으로 복사.
-i : cpio -o 의 실행결과를 표준입력으로 하여 패턴이 일치하는 파일만 선택한다.
-p : 표준입력으로부터 경로명의 목록을 읽어서 지정한 디렉토리에 파일을 생성하고 복사한다.
-d : 디렉토리가 필요할경우 자동으로 생성한다.
-f : 패턴과 일치하는것을 제외하고 모든 파일복사.
-v : 진행되는 상황을 표시해준다.
-c : 아스키 형태로 정보를 읽거나 저장.
-u : restore 할때 같은 이름의 파일이 있으면 덮어쓴다. 디폴트는 같은 파일이 있는경우 원본의 시간을 비교하여 오래된 파일인
경우에만 덮어쓴다.


ex)
[root@centos1 home]# ls file1 file2 | cpio -ocv > /backup/test.cpio
file1
file2
1 block
[root@centos1 backup]# cpio -ivc < test.cpio
file1
file2
1 block
[root@centos1 backup]# cat file1
hello

[root@centos1 home]# find . | cpio -ocv > /backup/test2.cpio : 백업

[root@centos1 test]# cpio -ivc < ../test2.cpio : 복원

[root@centos1 backup]# cpio -t < test.cpio : resotore 하지 않고 백업된 파일목록을 보는경우
file1
file2
1 block
[root@centos1 backup]# cpio -vt < test.cpio : 자세히 보려면 v 옵션을 추가한다.
-rw-r--r-- 1 root root 6 Jul 16 06:08 file1
-rw-r--r-- 1 root root 6 Jul 16 06:08 file2
1 block
[root@centos1 backup]#


rpm -Redhat Package Manager

- 초기 리눅스 시스템은 어떤 프로그램을 설치하고자 하면 소스를 받아다가 일일이 컴파일해야 했다.
컴파일에 대한 지식이 없는 사람에게는 매우 힘든 작업이었다. 그러다가 redhat 사에서 rpm 이라는 패키지 관리 툴을 만들어
배포판에 포함함으로써 리눅스 프로그램의 설치,추가,삭제등을 손쉽게 할 수 있게 되었으며 이것이 많은 리눅스 배포판 중에서도
redhat이 널리 사용되게 된 이유중에 하나가 되었다.

rpm 패키지 관리방식은 설치 후 바로 사용할 수 있는 바이너리 파일, 설치될 파일경로, 환경설정파일등을 하나의
패키지에 저장하여 rpm 이라는 명령어를 통해 패키지를 손쉽게 설치,업그레이드,질의,검증,삭제 등이 가능한 방식이다.
mswindows 에서 패키지를 관리하는 것처럼 쉽다.

* 참고 - 소스코드 설치 -------------------------------------------------------------------------
/usr/include# cd /tmp
/tmp# wget http://apache.tt.co.kr/httpd/httpd-2.2.31.tar.bz2
--2016-02-16 18:14:47-- http://apache.tt.co.kr/httpd/httpd-2.2.31.tar.bz2
Resolving apache.tt.co.kr... 211.47.69.77
Connecting to apache.tt.co.kr|211.47.69.77|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5610489 (5.3M) [application/x-bzip2]
Saving to: `httpd-2.2.31.tar.bz2'

100%[===========================================================================>] 5,610,489 3.43M/s in 1.6s

2016-02-16 18:14:49 (3.43 MB/s) - `httpd-2.2.31.tar.bz2' saved [5610489/5610489]

/tmp# tar -xf httpd-2.2.31.tar.bz2
/tmp# cd httpd-2.2.31
/tmp/httpd-2.2.31# find . -name httpd
/tmp/httpd-2.2.31# find . -name *.c | head -n 5
./modules/aaa/mod_auth_basic.c
./modules/aaa/mod_authnz_ldap.c
./modules/aaa/mod_authz_owner.c
./modules/aaa/mod_authz_groupfile.c
./modules/aaa/mod_authz_user.c
/tmp/httpd-2.2.31# ./configure --prefix=/usr/local/apache
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for limits.h... yes
checking for unistd.h... (cached) yes
.. 이하생략

-- 이 작업의 결과로 Makefile 이 생성되며 이 파일이 있으면 make 명령을 통해서
소스코드를 컴파일 할 수 있다.

/tmp/httpd-2.2.31# make
.....
gcc -g -O2 -pthread -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/tmp/httpd-2.2.31/srclib/pcre -I. -I/tmp/httpd-2.2.31/os/unix -I/tmp/httpd-2.2.31/server/mpm/prefork -I/tmp/httpd-2.2.31/modules/http -I/tmp/httpd-2.2.31/modules/filters -I/tmp/httpd-2.2.31/modules/proxy -I/tmp/httpd-2.2.31/include -I/tmp/httpd-2.2.31/modules/generators ....
-- 컴파일이 끝나면

/tmp/httpd-2.2.31# find . -name httpd
./httpd
./.libs/httpd
/tmp/httpd-2.2.31#

위에서 처럼 바이너리 파일이 생성이 된다.
./.libs/httpd 파일을 실행하면 아파치 서버가 실행이 되지만 아직 한가지 단계가 남아있다.
컴파일 결과로 생성된 바이너리 파일과 환경설정 파일을 적절한 경로로 옮겨야 한다.
(configure 스크립트 실행할때 옵션으로 준 --prefix=/usr/local/apache 가 옮겨질 디렉토리)
/tmp/httpd-2.2.31# make install
<--- 잠시 기다리면 /usr/local/apache 디렉토리가 생성이 되며 아파치 실행에 필요한 파일이
옮겨진다.

/tmp/httpd-2.2.31# cd /usr/local/apache
/usr/local/apache# ls
bin build cgi-bin conf error htdocs icons include lib logs man manual modules
/usr/local/apache

/usr/local/apache# ./bin/httpd ; 아파치 실행.
httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.10.30 for ServerName
/usr/local/apache# pgrep -fl httpd
55091 ./bin/httpd
55092 ./bin/httpd
55093 ./bin/httpd
55094 ./bin/httpd
55095 ./bin/httpd
55096 ./bin/httpd
/usr/local/apache#
*. 아파치가 실행될때 경고메시지가 하나 출력이 되었지만 실행은 되었다.
아파치의 경고메시지는 컴파일의 문제가 아니라 아파치설정 파일 httpd.conf 설정문제이다.
----------------------아파치소스파일 컴파일 참고사항 끝--------------------------------------

rpm 패키지 파일의 형태.

fedora os 설치 시디안에 있는 패키지들 역시 rpm 으로 되어있다. cdrom 을 마운트 시키고 확인해 보자

[root@river root]# umount /mnt/cdrom

[root@river root]# mount /mnt/cdrom

[root@river root]# cd /mnt/cdrom/Fedora/RPMS/

[root@river RPMS]# ls -l | more
합계 517140
-rw-r--r-- 77 root root 1837336 2월 24 2003 Suite-0.11.1-13.i386.rpm
-rw-r--r-- 77 root root 558616 2월 24 2003 GConf-1.0.9-10.i386.rpm
-rw-r--r-- 77 root root 733991 2월 24 2003 GConf2-2.2.0-1.i386.rpm
-rw-r--r-- 77 root root 282745 2월 24 2003 Glide3-20010520-25.i386.rpm


... 이하생략

rrpm 패키지는 모두 이런형태의 포맷을 갖는다.

[root@river RPMS]# ls -l httpd*
-rw-r--r-- 75 root root 1056911 2월 26 2003 httpd-2.0.40-21.i386.rpm
-rw-r--r-- 75 root root 832576 2월 26 2003 ttpd-manual-2.0.40-21.i386.rpm
[root@river RPMS]#

웹서버 패키지가 두개가 있다는것을 볼 수 있다.

웹서버패키지를 설치해보자. 그전에 rpm 패키지 형태 및 설치옵션을 간단하게 알아보자.

rpm 패키지의 형태.

패키지명-패키지버전-아키텍처.rpm : 이런 형태로 되어 있다.

ex)
httpd-2.0.40-21.i386.rpm
=> 패키지명 httpd
버전 : 2.0.40-21
아키텍처: i386
확장자 : rpm

아키텍처는 alpha,arm,mips,sparc,i386 등 여러 가지가 있는데 i386 은 인텔cpu 와 호환이 되는것을 의미하는 것으로
일반PC가 여기에 해당된다. 만약 인터넷에서 rpm 파일을 다운로드 받아서 설치하는 경우에는 바이너리 패키지이므로
아키텍처를 잘 확인해야 한다. 자신이 사용하는 cpu에 맞는 아키텍처 여야 한다.

rpm 주요옵션 (rpm은 매우 많은 옵션을 가지고 있다)

설치시(rpm 패키지를 설치한다는 것은 패키지 안에 포함된 파일들을 적당한 디렉토리에 옮겨주는것이다.)
rpm -i 패키지명
그러나 일반적으로 -ivh 형태로 많이 사용한다.
i (install) : 설치. 이 옵션 하나만 사용해도 된다.
v (verbose) : 이 옵션을 사용하면 설치진행과정을 볼 수 있다.
h (hash mark => '#') : 진행과정을 해시마크를 찍어서 보여준다. (ftp client 명령어에 있는 hash와 같은 의미이다.)
--replacepkgs : 덮어쓰기로 설치하고자 하는 경우에 추가하는 옵션이다.


질의옵션

rpm 패키지의 설치 유무를 확인하거나 어떤 경로에 설치되어 있는지를 알고자 하는 경우에 사용하는 옵션이다.

-q : 질의옵션

ex)
[root@river RPMS]#rpm -q httpd
(파일명 대신 패키지명만 적어야한다)
httpd-2.0.40-21 (패키지가 이미 설치되어 있다)[root@river RPMS]#

설치된 모든 rpm 패키지를 보고자 하는 경우에는

root@river RPMS]# rpm -qa | more (a 옵션을 추가한다)
setup-2.5.25-1
bzip2-libs-1.0.2-8
e2fsprogs-1.32-6
glib-1.2.10-10
iputils-20020927-2

-- 이하 생략

설치된 패키지 중 문자열로 검색 할 경우(찾고자 하는 패키지 이름을 정확히 모를 경우)

[root@river RPMS]# rpm -qa | grep mail (찾은 결과를 grep 으로 걸러내면 될 것이다)
mailx-8.1.1-28sendmail-8.12.8-4
mailcap-2.1.13-1mozilla-mail-1.2.1-26
sendmail-cf-8.12.8-4
procmail-3.22-9
fetchmail-6.2.0-3[root@river RPMS]#

rpm 실행시 응답이 없거나 에러가 발생되면 아래와 같은 파일이 잘못되어 그럴수 있다. 그럴때는
[/var/lib/rmp]# ls *db*
__db.000 __db.001 __db.002 __db.003
위에 보이는 db 파일을 삭제하고 새로 생성하면 된다.
rm *db*
rpm --rebuilddb


이제 웹서버 패키지를 설치해보자

[root@river RPMS]# rpm -ivh httpd-2.0.40-21.i386.rpm
경고: httpd-2.0.40-21.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
준비 중... ########################################### [100%]
httpd-2.0.40-21 패키지는 이미 설치되어 있습니다
[root@river RPMS]#

이미 설치되어 있으므로 삭제하고 새로 설치하거나 덮어쓰기로 설치해야 한다.

[root@river RPMS]# rpm -ivh --replacepkgs httpd-2.0.40-21.i386.rpm
경고: httpd-2.0.40-21.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
준비 중... ########################################### [100%]
1:httpd ########################################### [100%]
[root@river RPMS]#

설치가 완료되었다.

이번에는 웹서버 메뉴얼관련 패키지도 설치해보자

[root@river RPMS]# rpm -i httpd-manual-2.0.40-21.i386.rpm
경고: httpd-manual-2.0.40-21.i386.rpm: V3 DSA signature: NOKEY, key ID db42a60e
* . 설치시 경고 메세지는 CentOS의 패키지가 정확히 맞는지를 검증하지 못했다는 의미이다.
경고가 뜨지 않게 하려면 아래 명령을 한번 실행해 주면 된다
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
[root@river RPMS]#

설치되었다. 설치시 -i 옵션만 사용했을때와 -ivh 옵션을 사용 했을 때의 차이를 알 수 있다.


패키지 설치경로 확인

[root@river RPMS]# rpm -ql httpd | more (-ql 옵션을 사용하면 된다)/etc/httpd
/etc/httpd
/conf/etc
/httpd/conf.d
/etc/httpd/conf.d/README
/etc/httpd/conf/httpd.conf/

-- 이하생략

*. 설치하거나 삭제 할 때 주의할 점이 있다. 의존성 관계에 있는 패키지라면 의존성 관계에 걸려있는 패키지를
먼저 설치하거나 제거한 후 설치 및 삭제를 해야 한다. 의존성 관계를 무시할 수 있는 옵션도 있는데 --nodeps 옵션이다.
(rpm -e --nodeps 패키지명. e는 제거옵션이다) 그러나 의존성을 함부로 무시하고 설치 및 삭제를 하는 것은 좋지 않다.
당연히 문제가 있을 수 있다.

rpm 패키지 삭제

rpm 패키지를 직접 찾아서 삭제하기는 어렵다. 파일이 많고 설치경로도 여러 개의 경로에 분산되어 설치되는 경우가
대부분이므로. 그냥 rpm 이 제공하는 삭제 옵션을 사용하면 된다.

-e : 삭제옵션

root@river RPMS]# rpm -e httpd-manual

[root@river RPMS]# rpm -e httpd오류: Failed dependencies: httpd is needed by (installed) redhat-config-httpd-1.0.1-18
[root@river RPMS]#

httpd-manual 패키지는 삭제되었으나 httpd 패키지는 의존성에 걸려 삭제되지 않았다.
redhat-config 패키지가 httpd 패키지의 일부 파일을 사용한다는 것이다. 이럴 경우 httpd 패키지는 삭제되지 않는다.
삭제 하려면 redhat-config 패키지를 먼저 삭제하고 httpd 패키지를 삭제하든지 그렇지 않으면 의존성을 무시하고 (--nodeps)
삭제해야 한다.

[root@river RPMS]# rpm -e --nodeps httpd (여기서는 의존성을 무시하고 삭제하기로 한다)

[root@river RPMS]# rpm -q httpdhttpd 패키지가 설치되어 있지 않습니다[root@river RPMS]#

깨끗하게 삭제되었다.

YUM - Yellowdog Updater Modified
rpm 명령의 불편한 점인 패키지 의존성 문제를 해결해준다.
특정 패키지를 설치할때 의존성 관계에 있는 패키지를 먼저 자동으로 설치해준다.

yum 은 인터넷을 통하여 rpm 파일이 저장된 저장소(repository)에서 필요한 파일을 다운로드 후
설치할수 있다. 파일을 다운로드 받게 되는 저장소의 주소는 /etc/yum.repos.d 디렉토리의 파일에 저장되어 있다.

*. yum 이 설치 되어 있지 않으면 씨디롬을 마운트하여 rpm 설치를 하거나 아니면 인터넷에서
다운로드하여 rpm 설치한다.

yum 설정파일

[root@bega rpm]# cat /etc/yum.conf
[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log : yum 으로 작업한 기록이 저장되는 파일
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
metadata_expire=1800
installonly_limit=2

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

[root@bega rpm]# ls /etc/yum.repos.d
fedora-rawhide.repo fedora-updates.repo
fedora-updates-testing.repo fedora.repo
[root@bega rpm]#
* 위에 파일 내용에 파일을 다운로드 받을 저장소 주소가 포함되어 있다.

사용법

yum [options] [command] [package ...]

yum install 패키지 [ 패키지2 패키지3 ...] => 패키지 설치
yum check-update 업데이트 가능 목록보기
yum update 패키지이름 => 패키지 업데이트
yum remove 패키지이름 => 패키지 삭제
yum info 패키지이름 => 패키지 정보확인
yum update => 커널을 포함한 전체 패키지 업데이트

ex)
[root@bega updates]# yum info telnet-server
Loaded plugins: refresh-packagekit
Installed Packages
Name : telnet-server
Arch : i386
Epoch : 1
Version : 0.17
Release : 42.fc9
Size : 49 k
Repo : installed
Summary : 텔넷 원격 로그인 프로토콜에 사용되는 서버 프로그램.
License : BSD
Description: Telnet is a popular protocol for logging into remote systems over
: the Internet. The telnet-server package includes a telnet daemon
: that supports remote logins into the host machine. The telnet
: daemon is disabled by default. You may enable the telnet daemon by
: editing /etc/xinetd.d/telnet.

[root@bega updates]#


[root@bega updates]#

[root@bega ftpuser]# yum install telnet-server
Loaded plugins: refresh-packagekit
fedora | 2.4 kB 00:00
primary.sqlite.bz2 | 6.1 MB 00:49
updates | 2.3 kB 00:00
primary.sqlite.bz2 | 2.2 MB 00:15
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package telnet-server.i386 1:0.17-42.fc9 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
telnet-server i386 1:0.17-42.fc9 fedora 36 k

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 36 k
Is this ok [y/N]:
Downloading Packages:
(1/1): telnet-server-0.17-42.fc9.i386.rpm | 36 kB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: telnet-server ######################### [1/1]

Installed: telnet-server.i386 1:0.17-42.fc9
Complete!
[root@bega ftpuser]#



[root@bega ftpuser]# yum install xinetd
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package xinetd.i386 2:2.3.14-18.fc9 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Updating:
xinetd i386 2:2.3.14-18.fc9 fedora 124 k

Transaction Summary
=============================================================================
Install 0 Package(s)
Update 1 Package(s)
Remove 0 Package(s)

Total download size: 124 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): xinetd-2.3.14-18.fc9.i386.rpm | 124 kB 00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : xinetd ######################### [1/2]
Cleanup : xinetd ######################### [2/2]

Updated: xinetd.i386 2:2.3.14-18.fc9
Complete!
[root@bega ftpuser]#[root@bega packages]# rpm -q telnet-server
telnet-server-0.17-42.fc9.i386

[root@bega packages]# yum remove telnet-server <= 패키지 제거할때
Loaded plugins: refresh-packagekit
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package telnet-server.i386 1:0.17-42.fc9 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Removing:
telnet-server i386 1:0.17-42.fc9 installed 49 k

Transaction Summary
=============================================================================
Install 0 Package(s)
Update 0 Package(s)
Remove 1 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : telnet-server ######################### [1/1]
??: /etc/xinetd.d/telnet(?)?? /etc/xinetd.d/telnet.rpmsave(?)??????????
Removed: telnet-server.i386 1:0.17-42.fc9
Complete!
[root@bega packages]# rpm -q telnet-server
telnet-server 패키지가 설치되어 있지 않습니다

*.기타 옵션
yum list all
yum list available 사용가능한 패키지 목록 출력

yum list updates
업데이트 가능한 패키지 출력

yum list installed
설치된 패키지 목록 출력
yum check-update
시스템에 필요한 업데이트 목록ㄹ 출력

yum update 패키지명


yum info 패키지명

yum list recent
yum 저장소에 최근에 추가된 패키지 목록 확인

yum search 검색어

패키지 설명과 요약문 패키지 이름에서 지정한 특정 문자열에 매칭하는지
여부를 확인하여 그 정보를 출려해준다.

ex)
yum search quota

yum localinstall 패키지명
yum localupdate 패키지명


패키지그룹 - 관련 패키지를 하나의 그룹을 묶은것
yum grouplist
yum groupinstall 패키지그룹명
yum groupremove 패키지그룹명
yum groupinfo 패키지그룹명

댓글목록

등록된 댓글이 없습니다.


접속자집계

오늘
104
어제
75
최대
611
전체
448,154
개인정보취급방침 서비스이용약관 twoseven.kr All rights reserved.
상단으로