yum工具的使用

kuqlan發表於2015-03-11

YUM源安裝軟體方式

  • yum是什麼?
    yum = Yellow dog Updater, Modified
    主要功能是更方便的新增/刪除/更新RPM.
    它能自動解決包的倚賴性問題.
    它能便於管理大量系統的更新問題
  • yum特點
    可以同時配置多個資源庫(Repository)
    簡潔的配置檔案(/etc/yum.conf/etc/yum.repos.d 下的檔案)
    自動解決增加或刪除rpm包時遇到的倚賴性問題
    使用方便
    保持與
    RPM資料庫的一致性
  • yum工具安裝

 

首先檢視是否安裝

rpm -qa  |grep yum

  • Centos/RHEL
    #rpm -ivh yum-2.4.3-4.el4.centos.noarch.rpm

 

 

一般系統自帶的yum源因沒有買服務原因無法使用,需要清理原有的yum原始檔後,重新定義:

定義yum

cd /etc/yum.repos.d

[root@ocm1 yum.repos.d]# pwd

/etc/yum.repos.d

 

清空改目錄下的所有的,以字尾為repo檔案。

 

  • 配置本地yum源語法格式如下:

/etc/yum.repos.d 中的所有定義的Yum源配置檔案刪除。然後建立server.repo檔案(副檔名一定是repo)內容如下:

[RHEL6]

name=local iso 

baseurl=file:///home/redhat-iso或者

gpgcheck=0     --本地光碟或ISO安裝,該配置最好改為0

enable=1

 

  • 其中baseurl 應的含義:

 baseurl:協議   路徑

baseurl一般初學者老犯錯誤的地方,這裡需要將ISO檔案或光碟先mount到某個目錄下:

如,虛擬機器上掛載iso檔案後,透過df -h 可得知,掛載到 /media/RHEL_5.5 i386 DVD目錄下,而主目錄名含空格,因此在baseurl=file:// /media/RHEL_5.5 i386 DVD 配置時,報錯無法安裝。

[root@ocm1 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              29G  4.5G   24G  17% /

/dev/sda1              99M   12M   83M  12% /boot

tmpfs                1014M     0 1014M   0% /dev/shm

/dev/hdc              2.9G  2.9G     0 100% /media/RHEL_5.5 i386 DVD

 

需要如下兩種方法來mount光碟或ISO檔案:

[root@ocm1 ~]# mount /dev/hdc /mnt  

mount: block device /dev/hdc is write-protected, mounting read-only

[root@ocm1 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              29G  4.5G   24G  17% /

/dev/sda1              99M   12M   83M  12% /boot

tmpfs                1014M     0 1014M   0% /dev/shm

/dev/hdc              2.9G  2.9G     0 100% /media/RHEL_5.5 i386 DVD

/dev/hdc              2.9G  2.9G     0 100% /mnt

[root@ocm1 ~]# cd /mnt/Server/

 

或者

[root@ocm1 ~]# mount /dev/cdrom /media/

mount: block device /dev/cdrom is write-protected, mounting read-only

[root@ocm1 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda3              29G  4.5G   24G  17% /

/dev/sda1              99M   12M   83M  12% /boot

tmpfs                1014M     0 1014M   0% /dev/shm

df: `/media/RHEL_5.5 i386 DVD': No such file or directory

/dev/hdc              2.9G  2.9G     0 100% /media

[root@ocm1 ~]# cd /media/Server/

 

以上配置結束後,就可以使用yum了,如下所示(如下案例,先解除安裝ftp包再安裝的):

[root@ocm1 yum.repos.d]# yum install -y lftp*

Loaded plugins: rhnplugin, security

This system is not registered with RHN.

RHN support will be disabled.

ClusterStorage                                                                                                                           | 1.3 kB     00:00    

RHEL6                                                                                                                                    | 1.3 kB     00:00    

RHEL6/primary                                                                                                                            | 753 kB     00:00    

RHEL6                                                                                                                                                 2348/2348

iso                                                                                                                                      | 1.3 kB     00:00    

Setting up Install Process

Resolving Dependencies

--&gt Running transaction check

---&gt Package lftp.i386 0:3.7.11-4.el5 set to be updated

--&gt Finished Dependency Resolution

 

Dependencies Resolved

 

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

 Package                             Arch                                Version                                     Repository                            Size

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

Installing:

 lftp                                i386                                3.7.11-4.el5                                RHEL6                                929 k

 

Transaction Summary

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

Install       1 Package(s)

Upgrade       0 Package(s)

 

Total download size: 929 k

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Finished Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing     : lftp                                                                                                                                     1/1

 

Installed:

  lftp.i386 0:3.7.11-4.el5                                                                                                                                     

 

Complete!

[root@ocm1 yum.repos.d]#


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18841027/viewspace-1455477/,如需轉載,請註明出處,否則將追究法律責任。

相關文章