不小心误删除了 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