YUM更换源--yum找不到安装包(转)
公司提供的CentOS VM中,/etc/yum.repos.d 下 只有一个build.repo,其中提供的yum 源只有公司内部的几个源,很多包在这些源中都找不到。于是要添加别的源,下面的帖子中介绍了如何在CentOS中添加中科大、搜狐和163的yum源:http://www.husw.net/blog/post/1386/。摘录如下:
本文章介绍的yum源支持的版本是CentOS 6系列,理论上支持RHEL6系列。
更新方法如下:
先进入yum源配置目录
备份系统自带的yum源
下载其他更快的yum源
中科大的yum源:
163的yum源:
sohu的yum源
更新完yum源后,建议更新一下,使操作立即生效
Loaded plugins: fastestmirrorRepository base is listed more than once in the configurationRepository updates is listed more than once in the configurationRepository extras is listed more than once in the configurationRepository centosplus is listed more than once in the configurationRepository contrib is listed more than once in the configurationLoading mirror speeds from cached hostfile* addons: mirrors.163.com* base: mirror.metrocast.net* extras: mirror.beyondhosting.net* fasttrack: centos.vipernetworksystems.com* updates: centos.vipernetworksystems.comhttp://mirrors.163.com/centos/6/addons/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"Trying other mirror.http://mirror.centos.org/centos/6/addons/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404"Trying other mirror.Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again
#[addons]#name=CentOS-$releasever - Addons - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons#baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/#gpgcheck=1#pgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#[addons]#name=CentOS-$releasever - Addons - sohu.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons#baseurl=http://mirrors.sohu.com/centos/$releasever/addons/$basearch/#gpgcheck=1#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5CentOS-Base-sohu.repo
vim-X11.x86_64 : The VIM version of the vi editor for the X Window Systemvim-common.x86_64 : The common files needed by any version of the VIM editorvim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancementsvim-minimal.x86_64 : A minimal version of the VIM editor
使用 yum 程序安装所需开发包(以下为标准的rpm包名称)
yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel
zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel
freetype-devel pam-devel openssl-devel libxml2-devel gettext-devel pcre-devel mysql-devel net-snmp-devel
curl-devel perl-DBI
执行yum源更新
[root@localhost ~]# yum clean all [root@localhost ~]# yum makecache [root@localhost ~]# yum update
注意:
更新为163的源后,yum的时候报错:GPG key retrieval failed: [Errno 14] Could not open/read file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5.
解决方案:vi /etc/yum.repos.d/CentOS-Base.repo
把文件里所有的RPM-GPG-KEY-CentOS-5更改为RPM-GPG-KEY-CentOS-6就可以了
vim 替换 :%s/RPM-GPG-KEY-CentOS-5/RPM-GPG-KEY-CentOS-6