1. 程式人生 > >Linux雲伺服器初學之一 ——熟悉linux的yum工具

Linux雲伺服器初學之一 ——熟悉linux的yum工具

yum

一、yum 簡介
  yum,是Yellow dog Updater, Modified 的簡稱,是杜克大學為了提高RPM 軟體包安裝性而開發的一種軟體包管理器。起初是由yellow dog 這一發行版的開發者Terra Soft 研發,用python 寫成,那時還叫做yup(yellow dog updater),後經杜克大學的[email protected] 開發團隊進行改進,遂有此名。yum 的宗旨是自動化地升級,安裝/移除rpm 包,收集rpm 包的相關資訊,檢查依賴性並自動提示使用者解決。yum 的關鍵之處是要有可靠的repository,顧名思義,這是軟體的倉庫,它可以是http 或ftp 站點,也可以是本地軟體池,但必須包含rpm 的header,header 包括了rpm 包的各種資訊,包括描述,功能,提供的檔案,依賴性等。正是收集了這些header 並加以分析,才能自動化地完成餘下的任務。
  
  yum 主要功能是更方便的新增/刪除/更新RPM 包,自動解決包的倚賴性問題,便於管理大量系統的更新問題。

  yum 可以同時配置多個資源庫(Repository),簡潔的配置檔案(/etc/yum.conf),自動解決增加或刪除rpm 包時遇到的依賴性問題,保持與RPM 資料庫的一致性。
二、yum的安裝配置和使用

1、查詢已安裝的RPM軟體包的資訊

格式:rpm -q[子選項] [軟體名稱]
常用的子選項: -a:列出已安裝的所有軟體包

[[email protected]_0_5_centos ~]# rpm -qa|grep yum
yum-utils-1.1.30-37.el6.noarch
yum-plugin-fastestmirror-1.1.30-37.el6.noarch
yum-plugin-security-1.1.30-37.el6.noarch
yum-metadata-parser-1.1.2-16.el6.x86_64
yum-3.2.29-73.el6.centos.noarch

2、檢視軟體列表

格式:yum list [軟體名].. ..
用法:yum search 關鍵詞

[[email protected]_0_5_centos ~]# yum list //列出所有包
.. ..
Installed Packages //已安裝的包
ConsoleKit.x86_64 0.4.1-3.el6 @anaconda .. ..x86_64/6.8
.. ..
Available Packages //可用的包
.. ..
zsh.x86_64 4.3.10-7.el6 centos6

3、軟體包基本操作

格式:yum [-y] 指令 [軟體名]…
常用指令
install:安裝指定軟體包,類似於rpm -i
remove:解除安裝指定軟體包,類似於rpm -e

[[email protected]_0_5_centos ~]# yum -y install bind
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Resolving Dependencies
–> Running transaction check
—> Package bind.x86_64 32:9.8.2-0.62.rc1.el6_9.4 will be installed
–> Processing Dependency: bind-libs = 32:9.8.2-0.62.rc1.el6_9.4 for package: 32:bind-9.8.2-0.62.rc1.el6_9.4.x86_64
–> Processing Dependency: portreserve for package: 32:bind-9.8.2-0.62.rc1.el6_9.4.x86_64
–> Running transaction check
—> Package bind-libs.x86_64 32:9.8.2-0.47.rc1.el6_8.3 will be updated
–> Processing Dependency: bind-libs = 32:9.8.2-0.47.rc1.el6_8.3 for package: 32:bind-utils-9.8.2-0.47.rc1.el6_8.3.x86_64
—> Package bind-libs.x86_64 32:9.8.2-0.62.rc1.el6_9.4 will be an update
—> Package portreserve.x86_64 0:0.0.4-11.el6 will be installed
–> Running transaction check
—> Package bind-utils.x86_64 32:9.8.2-0.47.rc1.el6_8.3 will be updated
—> Package bind-utils.x86_64 32:9.8.2-0.62.rc1.el6_9.4 will be an update
–> Finished Dependency Resolution
Dependencies Resolved
Package Arch Version Repository Size
Installing:
bind x86_64 32:9.8.2-0.62.rc1.el6_9.4 updates 4.0 M
Installing for dependencies:
portreserve x86_64 0.0.4-11.el6 os 23 k
Updating for dependencies:
bind-libs x86_64 32:9.8.2-0.62.rc1.el6_9.4 updates 892 k
bind-utils x86_64 32:9.8.2-0.62.rc1.el6_9.4 updates 189 k
Transaction Summary
Install 2 Package(s)
Upgrade 2 Package(s)
Total download size: 5.1 M
Downloading Packages:
(1/4): bind-9.8.2-0.62.rc1.el6_9.4.x86_64.rpm | 4.0 MB 00:00
(2/4): bind-libs-9.8.2-0.62.rc1.el6_9.4.x86_64.rpm | 892 kB 00:00
(3/4): bind-utils-9.8.2-0.62.rc1.el6_9.4.x86_64.rp | 189 kB 00:00
(4/4): portreserve-0.0.4-11.el6.x86_64.rpm | 23 kB 00:00
Total 7.0 MB/s | 5.1 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : 32:bind-libs-9.8.2-0.62.rc1.el6_9.4.x86_64 1/6
Installing : portreserve-0.0.4-11.el6.x86_64 2/6
Installing : 32:bind-9.8.2-0.62.rc1.el6_9.4.x86_64 3/6
Updating : 32:bind-utils-9.8.2-0.62.rc1.el6_9.4.x86_64 4/6
Cleanup : 32:bind-utils-9.8.2-0.47.rc1.el6_8.3.x86_64 5/6
Cleanup : 32:bind-libs-9.8.2-0.47.rc1.el6_8.3.x86_64 6/6
Verifying : 32:bind-utils-9.8.2-0.62.rc1.el6_9.4.x86_64 1/6
Verifying : portreserve-0.0.4-11.el6.x86_64 2/6
Verifying : 32:bind-libs-9.8.2-0.62.rc1.el6_9.4.x86_64 3/6
Verifying : 32:bind-9.8.2-0.62.rc1.el6_9.4.x86_64 4/6
Verifying : 32:bind-utils-9.8.2-0.47.rc1.el6_8.3.x86_64 5/6
Verifying : 32:bind-libs-9.8.2-0.47.rc1.el6_8.3.x86_64 6/6
Installed:
bind.x86_64 32:9.8.2-0.62.rc1.el6_9.4
Dependency Installed:
portreserve.x86_64 0:0.0.4-11.el6
Dependency Updated:
bind-libs.x86_64 32:9.8.2-0.62.rc1.el6_9.4
bind-utils.x86_64 32:9.8.2-0.62.rc1.el6_9.4

Complete!

4、清空本地yum快取

適用於yum快取存在錯誤時,再次查詢或更新時,會自動重建快取。

[[email protected]_0_5_centos ~]# yum clean all
Loaded plugins: fastestmirror, security
Cleaning repos: epel extras os updates
Cleaning up Everything
Cleaning up list of fastest mirrors

5、更新軟體

僅更新指定的軟體
命令:yum update

更新全部軟體
yum update