不小心誤刪除了 VPS 下面的 yum,大家都知道 yum 在 linux 中是很重要的一個功能,站群軟體的下載,系統的更新都要靠他。沒有 yum,系統基本處於半殘廢狀態。
yum 的安裝操作:
在 SSH 裡面依次輸入下面的命令:
1,下載最新的 yum-3.2.28.tar.gz 並解壓
wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz
tar xvf yum-3.2.28.tar.gz
2,進入目錄,執行安裝
cd yum-3.2.28
yummain.py install yum
結果提示錯誤: CRITICAL:yum.cli:Config Error: Error accessing file for config file:///etc/
後來經貓哥提醒,原來是缺少配置檔案。在 etc 目錄下面新建 yum.conf 檔案,然後再次執行 yummain.py install yum,順利完成安裝。
3,最後更新系統,全部搞定,收工。^_^
yum check-update
yum update
yum clean all
1.yum 的安裝與配置
(1)yum 的安裝
檢查 yum 是否已經安裝:
[root@localhost~]# rpm -qa|grep yum
如果沒有任何顯示,表示系統中還沒有安裝 yum 工具,yum 安裝包在 centos 系統光碟中可以找到,執行如下指令進行安裝:
[root@localhost~]# rpm -ivh yum-*.noarch.rpm
安裝 yum 需要 python-elementtree 、 python-sqlite 、 urlgrabber 、 yumconf 等站群軟體包的支援,這些站群軟體包在 Centos Linux 系統安裝光碟均可找到,如果在安裝 yum 過程中出現站群軟體包之間的依賴性,只需按照依賴提示尋找相應站群軟體包安裝即可,直到 yum 包安裝成功。
下面是某個環境的安裝示例:
[root@localhost~]# rpm -ivh yum-2.4.3-1.c4.noarch.rpm
warning:yum-2.4.3-1.c4.noarch.rpm: V3 DSA signature:NOKEY, key ID 443e1821
error:Failed dependencies:
python-elementtree is needed by yum-2.4.3-1.c4.noarch
python-sqlite is needed by yum-2.4.3-1.c4.noarch
urlgrabber is needed by yum-2.4.3-1.c4.noarch
yumconf is needed by yum-2.4.3-1.c4.noarch
[root@localhost~]# rpm -ivh python-elementtree-1.2.6-4.2.1.i386.rpm
warning:python-elementtree-1.2.6-4.2.1.i386.rpm: V3 DSAsignature: NOKEY, key ID 443e1821
Preparing… ########################################### [100%]
1:python-elementtree ###########################################[100%]
http://www.uplook.cn/?a=index&m=index&c=iframe&url=mailto%3Aroot%40localhost ~]#rpm -ivh sqlite-3.3.3-1.2.i386.rpm
warning:sqlite-3.3.3-1.2.i386.rpm: V3 DSA signature:NOKEY, key ID 443e1821
Preparing… ########################################### [100%]
1:sqlite ########################################### [100%]
[root@localhost~]# rpm -ivh python-sqlite-1.1.7-1.2.i386.rpm
warning:python-sqlite-1.1.7-1.2.i386.rpm: V3 DSAsignature: NOKEY, key ID 443e1821
Preparing… ########################################### [100%]
1:python-sqlite ########################################### [100%]
[root@localhost~]# rpm -ivh python-urlgrabber-2.9.8-2.noarch.rpm
warning:python-urlgrabber-2.9.8-2.noarch.rpm: V3 DSAsignature: NOKEY, key ID 443e1821
Preparing… ########################################### [100%]
1:python-urlgrabber ########################################### [100%]
http://www.uplook.cn/?a=index&m=index&c=iframe&url=mailto%3Aroot%40localhost ~]#rpm -ivh centos-yumconf-4-4.5.noarch.rpm
warning:centos-yumconf-4-4.5.noarch.rpm: V3 DSA signature: NOKEY, key ID 443e1821
Preparing… ########################################### [100%]
1:centos-yumconf ########################################### [100%]
[root@localhost~]# rpm -ivh yum-2.4.3-1.c4.noarch.rpm
warning:yum-2.4.3-1.c4.noarch.rpm: V3 DSA signature:NOKEY, key ID 443e1821
Preparing… ########################################### [100%]
1:yum ########################################### [100%]
(2)yum 的配置
yum 工具安裝完畢,接下來的工作是進行 yum 的配置,yum 的配置檔案有主配置檔案/etc/yum.conf 、資源庫配置目錄/etc/yum.repos.d,yum 安裝後,預設的一些資源庫配置可能無法使用,因此需要進行修改,下面是/etc/yum.repos.d/CentOS-Base.repo 資源庫配置檔案各項的詳細含義:
[root@localhost~]#/etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-4- Base
#name 就是發行版的名稱,其格式表示 “作業系統名和釋出版本”,“base” 是表明此段尋找的是 base 包資訊。
baseurl=http://mirror.centos.org/centos/4/os/$basearch/
#baseurl” 表示 yum 在網際網際網路上查詢升級檔案的 URL 地址。其中 “$basearch” 代表了系統的硬體構架如 “i386” 、 “x86-64 等,同時,yum 在資源更新時,會檢查 baseurl/repodata/repomd.xml 檔案。 “repomd.xml” 是一個索引檔案,它的作用是提供了更新 rpm 包檔案的下載資訊和 SHA 校驗值。 “repomd.xml” 包括了 3 個檔案,分別為 “other.xml.gz” 、”filelists.xml.gz” 和”primary.xml.gz”,表示的含義依次是 “其它更新包列表” 、 “更新檔案集中列表” 和 “主要更新包列表” 。
gpgcheck=1
#gpgcheck 表示是否啟用 gpg 檢查,1 表示啟用,0 表示不啟用校驗,如果啟用,就是需要在配置檔案裡註明 GPG-RPM-KEY 的位置,可以看到下面 gpgkey 欄位,指定了 GPG-RPM-KEY 驗證檔案的位置。
#releasedupdates
[update]
#本段是 updates 更新模組要用到的部分配置。
name=CentOS-4- Updates
baseurl=http://mirror.centos.org/centos/4/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
#gpgkey 指定 GPG 金鑰的地址
#packagesused/produced in the build but not released
#本段指定的是尚未釋出的站群軟體包部分(addons)配置
[addons]
name=CentOS-4- Addons
baseurl=http://mirror.centos.org/centos/4/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
#additionalpackages that may be useful
#本段指定的是有用的額外站群軟體包部分(extras)配置
[extras]
name=CentOS-4- Extras
baseurl=http://mirror.centos.org/centos/4/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
#additionalpackages that extend functionality of existing packages
#本段指定的是擴充套件的額外站群軟體包部分(centosplus)配置
[centosplus]
name=CentOS-4- Plus
baseurl=http://mirror.centos.org/centos/4/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4
#contrib- packages by Centos Users
#這裡是 contrib 部分
[contrib]
name=CentOS-4- Contrib
baseurl=http://mirror.centos.org/centos/4/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4