티스토리 뷰

공부/Linux

24. Software 관리

김대욱대욱 2018. 3. 19. 17:21

목표

1. RPM 패키지 관리

2. YUM 패키지 관리

3. 소스 패키지 관리



1. RPM 패키지 관리

  [참고] 오픈소스 프로젝트 (한국 미러링 사이트)

http://ftp.daum.net

http://ftp.neowiz.com/pub

http://mirror.cdnetworks.com

위의 사이트 외에도 더 있다.


 ▷ RPM (Redhat Package Manager)

  - Redhat 사에서 패키지를 좀 더 쉽게 설치하고 관리하기 위해 만든 패키지 관리 프로그램이다.

  - 명령어 형식

# rpm [옵션]

  - 명령어 옵션

  EX )

패키지 설치 및 업데이트

rpm -ivh package-filename.rpm       /* 이전 버전 패키지 삭제 하지않고 새버전 설치 */

rpm -Fvh package-filename.rpm       /* 이전 버전 패키지가 있을 경우만 패키지 설치 */

rpm -Uvh package-filename.rpm       /* 이전 버전이면 업그레이드 하고 없으면 설치 */

rpm -ivh --nodeps package-filename.rpm  /* 의존성 체크 안함 */

rpm -Uvh --force package-filename.rpm   /* 패키지 충돌이 발생해도 강제적으로 설치 */


패키지 삭제

rpm -e package-filename             /* 패키지 삭제*/

rpm -e nodeps package-filename     /* 의존성 문제를 무시하고 패키지 삭제 */


패키지 정보 확인

rpm -qa package-filename            /* 지정된 패키지 설치 유무 확인 */

rpm -qa | grep package-filename      /* 전체 패키지 목록에서 지정된 패키지 설치 유무 확인 */

rpm -qi | package-filename            /* 설치된 패키지의 자세한 정보 확인 */

rpm -ql package-filenames            /* 설치된 패키지의 파일과 디렉토리 목록 확인 */

rpm -qf /usr/bin/ls                    /* 지정된 파일이 포함된 패키지 이름 확인 */

rpm -qip package-filename.rpm         /* 설치하고자 하는 패키지의 자세한 정보 확인 */

 

  - 인터넷 상에서 패키지를 다운로드 하여 설치하는 방법

다음 명령어는 접속하는 사이트와 자신이 사용하는 CentOS 버젼에 따라 다르다.

다음과 같은식으로 적는다는 것만 알고 입력할때는 파악하고 입력해야 한다.

# wget ftp://ftp.pbone.net/mirror/ftp.centos.org/5.10/os/i386/CentOs/php-5.1.6-39.el5_9.i386.rpm


2. YUM 패키지 관리

 ▷ YUM (Yellowdog Update Manager, Yellowdog Update Modified)

  - rpm의 경우 wget을 이용해 rpm패키지가 저장된 서버의 주소를 입력하고 옵션을 이용해 패키지를 설채해야 하지만, yum은

rpm 패키지가 저장된 서버에 자동으로 접속하고 설치하고자 하는 패키지를 다운로드하여 설치한다.


  - 명령어 형식

# yum [옵션] Command


# yum list

# yum list installed

# yum list available


# yum -y update

# yum -y update php

# yum -y install php


# yum -y localinstall php.rpm


  - Command 종류

Clean          캐쉬 데이터 삭제

erase          패키지 삭제

groupinstall    시스템 그룹안에 패키지 설치

grouplist       이용가능한 패키지 그룹 리스트

groupremove   시스템의 패키지 그룹 삭제

info            패키지 정보 자세히 출력

list             패키지의 리스트

localinstall      로컬 RPM 설치

repolist         repositories 소프트웨어 설정 출력

update         패키지 업데이트

upgrade        패키지 업그레이드


  - 명령어 옵션

-y             모든 질문에 yes라고 대답


3. 소스 패키지 관리

 ▷ 소스(Source) 파일로 설치하기

  - RPM 패키지를 지원하지 않는 프로그램이나 RPM 패키지 지원이 느려 바로 업데이트를 적용할 수 없는 프로그램을 설치하기 위해서는 소스 코드를 이용하여 컴파일하여 설치할 수 밖에 없다.


 ▷ Source Compile (EX: pkg.tar.gz)

# tar xvzf pkg.tar.gz

# cd pkg

# ./configure --prefix=/usr/local/pkg

# make

# make install

[참고] APM (Apache + PHP + MySQL) 설치

       ATJO (Apache + Tomcat + JAVA(JDK/SDK) + Oracle) 설치


4. Create an RPM

 ▷ rpm 패키지 생성 절차

  - 소스 프로그램 개발

  - 소스 .tar.gz 파일 생성

  - SPEC 파일 생성

  - rpm build

  - GPG Key 생성

  - 패키지 sign

  - Yum Repository 구성

  - 테스트


 ▷ 간단한 프로그램 개발

  - rpm 패키지 생성 절차

ⓐ 소스 프로그램 개발

ⓑ 소스 .tar.gz 파일 생성

ⓒ SPEC 파일 생성

ⓓ rpm build

ⓔ GPG Key 생성

ⓕ 패키지 sign

ⓖ Yum Repository 구성

테스트


  ⓐ 소스 프로그램 개발

# cd /test && rm -rf /test/*

# mkdir -p hello-1.0

# vi hello-1.0/hello.sh

원하는 내용 작성


  ⓑ 소스 .tar.gz 파일 생성

# ls /usr/src/redhat

# tar cvzf /usr/src/redhat/SOURCES/hello-1.0-1.tar.gz hello-1.0

# tar tvzf /usr/src/redhat/SOURCES/hello-1.0.-1.tar.gz


  ⓒ SPEC 파일 생성

vi /usr/src/redhat/SPECS/hello.spec

  <![endif] -->

%define name hello

%define version 1.0

%define release 1

 

Name: hello

Version: 1.0

Release: 1

Summary: Hello

Group: CentOS

License: GPL

URL: http://www.example.com

Source0: %{name}-%{version}-%{release}.tar.gz

BuildRoot: /var/tmp/%{name}-buildroot

 

%description

Installs /root/bin/hello.sh

 

%prep

%setup -q -n %{name}-%{version}

 

%build

 

%install

rm -rf $RPM_BUILD_ROOT

mkdir -p $RPM_BUILD_ROOT/root/bin

install -m 755 hello.sh $RPM_BUILD_ROOT/root/bin/hello.sh

 

%clean

rm -rf $RPM_BUILD_ROOT

 

%files

%defattr(-,root,root,-)

/root/bin/hello.sh

 

%changelog


  ⓓ rpm build

# yum -y install rpm-build

# rpmbuild -ba /usr/src/redhat/SPECS/hello.spec

# find /usr/src/redhat

 
  ⓔ GPG Key 생성

# cd

# gpp --gen-key

  <![endif] -->

gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.

This program comes with ABSOLUTELY NO WARRANTY.

This is free software, and you are welcome to redistribute it

under certain conditions. See the file COPYING for details.

 

gpg: directory `/root/.gnupg' created

gpg: new configuration file `/root/.gnupg/gpg.conf' created

gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run

gpg: keyring `/root/.gnupg/secring.gpg' created

gpg: keyring `/root/.gnupg/pubring.gpg' created

Please select what kind of key you want:

(1) DSA and Elgamal (default)

(2) DSA (sign only)

(5) RSA (sign only)

Your selection? <ENTER>

DSA keypair will have 1024 bits.

ELG-E keys may be between 1024 and 4096 bits long.

What keysize do you want? (2048) <ENTER>

Please specify how long the key should be valid.

0 = key does not expire

<n> = key expires in n days

<n>w = key expires in n weeks

<n>m = key expires in n months

<n>y = key expires in n years

Key is valid for? (0) <ENTER>

Key does not expire at all

Is this correct? (y/N) y

 

You need a user ID to identify your key; the software constructs the user ID

from the Real Name, Comment and Email Address in this form:

"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"

 

Real name: Baik, SeoungChan

Email address: jang4sc@hanmail.net

Comment: <ENTER>

You selected this USER-ID:

"Baik, SeoungChan <jang4sc@hanmail.net>"

 

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o

You need a Passphrase to protect your secret key.

 

Passphrase: testing123

Repeat passphrase: testing123

We need to generate a lot of random bytes. It is a good idea to perform

some other action (type on the keyboard, move the mouse, utilize the

disks) during the prime generation; this gives the random number

generator a better chance to gain enough entropy.

++++++++++..++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.++++++++++++++++++++.+++++++++++++++.+++++.+++++..++++++++++..>+++++.....................................................+++++

 

Not enough random bytes available. Please do some other work to give

the OS a chance to collect more entropy! (Need 283 more bytes)

We need to generate a lot of random bytes. It is a good idea to perform

some other action (type on the keyboard, move the mouse, utilize the

disks) during the prime generation; this gives the random number

generator a better chance to gain enough entropy.

.+++++++++++++++++++++++++.++++++++++.+++++.++++++++++......+++++++++++++++..+++++++++++++++..+++++.+++++++++++++++.+++++++++++++++++++++++++.+++++.++++++++++.+++++>.+++++.+++++...>+++++..................................................................................+++++^^^

gpg: /root/.gnupg/trustdb.gpg: trustdb created

gpg: key ACD89B3E marked as ultimately trusted

public and secret key created and signed.

 

gpg: checking the trustdb

gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model

gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u

pub 1024D/ACD89B3E 2014-01-23

Key fingerprint = 98A1 E2A6 AE47 FE97 BFE8 6DC4 BCAB 0ADE ACD8 9B3E

uid Baik, SeoungChan <jang4sc@hanmail.net>

sub 2048g/CA2DE316 2014-01-23

KEY ID : ACD89B3E


  ⓕ 패키지 sign

# gpg -a -o ~/RPM-GPG-KEY-test --export ACD89B3E

# ls RPM*

# cat RPM-GPG-KEY-test

# vi ~/.rpmmacros

%_gpg_name ACD89B3E

# rpm --resign /usr/src/redhat/RPMS/i386/hello-1.0-1.i386.rpm


ⓖ Yum Repository 구성

# mkdir /var/www/html/packages

# cp /usr/src/redhat/RPMS/i386/hello*.rpm /var/www/html/packages

# cp RPM-GPG-KEY-test /var/www/html/packages


# yum -y install createrepo

# createrepo /var/www/html/packages

#service httpd restart


테스트

# vi /etc/yum.repos.d/hello.repo ( baseurl 에는 본인의 mirrorlist 사이트를 입력하면된다. )

[hello]

name=hello

description=Test Yum Repository

baseurl=http://172.16.9.252/packages

enabled=1

gpgcheck=1

gpgkey=http://172.16.9.252/packages/RPM-GPG-KEY-test



# yum -y install hello

# hello.sh

자기가 만든 코드 출력


  (복원) hello.repo 파일 복원

# cd /etc/yum.repos.d

# vi hello.repo

[hello]

name=hello

description=Test Yum Repository

baseurl=http://172.16.9.252/packages

enabled=0

gpgcheck=1

gpgkey=http://172.16.9.252/packages/RPM-GPG-KEY-test




'공부 > Linux' 카테고리의 다른 글

26. 사용자 그룹관리  (0) 2018.03.23
25. 부팅 과정  (0) 2018.03.23
23. swap 관리  (0) 2018.03.19
22. RAID관리  (0) 2018.03.19
21. LVM 관리  (0) 2018.03.19
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/04   »
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