本想替换成国内的yum源,可是国内的yum源只有最新版本目录有内容,其他版本目录下仅有readme文件 。因此决定采用官网的yum源,详细可到http://vault.centos.org/查看发行列表。
更新yum源的时候发生错误。
[root@localhost yum.repos.d]# yum makecache
[root@localhost yum.repos.d]# yum check-update
查看系统版本,以便获取对应版本的CentOS-Base.repo文件
[root@localhost yum.repos.d]# cat /etc/issue
CentOS release 5.7 (Final)
[root@localhost yum.repos.d]# lsb_release -a
查看官网系统发行列表
列表中包含了Centos完整的发行列表,这里我们只需要版本5.7目录中的内容。
替换CentOS-Base.repo内容
根据查询到的系统版本5.7,将/etc/yum.repos.d/CentOS-Base.repo中内容替换如下:
# CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-$releasever - Base baseurl=http://vault.centos.org/5.7/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #released updates [updates] name=CentOS-$releasever - Updates baseurl=http://vault.centos.org/5.7/updates/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #packages used/produced in the build but not released [addons] name=CentOS-$releasever - Addons baseurl=http://vault.centos.org/5.7/addons/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that may be useful [extras] name=CentOS-$releasever - Extras baseurl=http://vault.centos.org/5.7/extras/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-$releasever - Plus baseurl=http://vault.centos.org/5.7/centosplus/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 #contrib - packages by Centos Users [contrib] name=CentOS-$releasever - Contrib baseurl=http://vault.centos.org/5.7/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
保存文件后,运行yum clean all
执行yum check-update测试
重新加载新缓存yum makecache
显示所有已经安装和可以安装的程序包 yum list
题外话:解除yum被锁定
Existing lock /var/run/yum.pid: another copy is running as pid 13264.
rm -f /var/run/yum.pid
完成以上的yum源的配置就可以使用yum命令对软件进行安装、更新等操作。
以下是yum命令的参数:
install:安装rpm软件包; update:更新rpm软件包; check-update:检查是否有可用的更新rpm软件包; remove:删除指定的rpm软件包; list:显示软件包的信息; search:检查软件包的信息; info:显示指定的rpm软件包的描述信息和概要信息; clean:清理yum过期的缓存; shell:进入yum的shell提示符; resolvedep:显示rpm软件包的依赖关系; localinstall:安装本地的rpm软件包; localupdate:显示本地rpm软件包进行更新; deplist:显示rpm软件包的所有依赖关系。
yum命令使用
安装 yum install #全部安装 yum install package1 #安装指定的安装包package1 yum groupinsall group1 #安装程序组group1 更新和升级 yum update #全部更新 yum update package1 #更新指定程序包package1 yum check-update #检查可更新的程序 yum upgrade package1 #升级指定程序包package1 yum groupupdate group1 #升级程序组group1 查找和显示 yum info package1 #显示安装包信息package1 yum list #显示所有已经安装和可以安装的程序包 yum list package1 #显示指定程序包安装情况package1 yum groupinfo group1 #显示程序组group1信息yum search string 根据关键字string查找安装包 删除程序 yum remove package1 #删除程序包package1 yum groupremove group1 #删除程序组group1 yum deplist package1 #查看程序package1依赖情况 清除缓存 yum clean packages #清除缓存目录下的软件包 yum clean headers #清除缓存目录下的 headers yum clean oldheaders #清除缓存目录下旧的 headers
继续阅读
微信公众号
分享IT信息技术、北海生活的网站。提供北海本地化的信息技术服务。