公司提供的CentOS VM中,/etc/yum.repos.d 下 只有一个build.repo,其中提供的yum 源只有公司内部的几个源,很多包在这些源中都找不到。于是要添加别的源,下面的帖子中介绍了如何在CentOS中添加中科大、搜狐和163的yum源:http://www.husw.net/blog/post/1386/。摘录如下:

本文章介绍的yum源支持的版本是CentOS 6系列,理论上支持RHEL6系列。
更新方法如下:
先进入yum源配置目录

cd /etc/yum.repos.d

备份系统自带的yum源

mv CentOS-Base.repo CentOS-Base.repo.save

下载其他更快的yum源
中科大的yum源:

wget http://centos.ustc.edu.cn/CentOS-Base.repo

163的yum源:

wget http://mirrors.163.com/.help/CentOS-Base-163.repo

sohu的yum源

wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo

更新完yum源后,建议更新一下,使操作立即生效

yum makecache
 
[yasi]:
在执行最后一步,即yum makecache的时候,遇到错误:
Loaded plugins: fastestmirror
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository contrib is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * addons: mirrors.163.com
 * base: mirror.metrocast.net
 * extras: mirror.beyondhosting.net
 * fasttrack: centos.vipernetworksystems.com
 * updates: centos.vipernetworksystems.com
http://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
原因是,http://mirrors.163.com/centos/6/addons/x86_64/repodata/repomd.xml和 http://mirror.centos.org/centos/6/addons/x86_64/repodata/repomd.xml 确实不存在,可能被更新掉了。解决办法是,找到可用的URL替换之,或者把相应的.repo文件中的项整个注释掉。这里我采用后者。
 
例如,在CentOS-Base-163.repo中,注释掉整个addon项
#[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
 
在CentOS-Base-sohu.repo中注释掉下面的内容
#[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
 
然后,再执行yum makecache。之后,yum就可以找到我要安装的包了,比如gdb, subversion, gcc-c++ 等。
 
注意:
有时用yum list xxx找不到某个包,可用尝试用yum search xxx
如,yum list vim 就报告 Error: No matching Packages to list。而 yum search vim 则返回:
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements
vim-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

YUM更换源--yum找不到安装包(转)的更多相关文章

  1. Linux系列教程(十三)——Linux软件包管理之源码包、脚本安装包

    上篇博客我们讲解了网络yum源和光盘yum源的搭建步骤,然后详细介绍了相关的yum命令,yum 最重要是解决了软件包依赖性问题.在安装软件时,我们使用yum命令将会简单方便很多.我们知道yum命令只能 ...

  2. Linux软件包管理之源码包、脚本安装包

    目录 1.源码包和RPM包的区别 RPM包和源码包默认安装位置: 由于安装位置不同带来的影响 2.源码包安装 ①.安装准备 ②.安装注意事项 ③.安装源码包 3.源码包卸载 4.脚本安装包 5.总结 ...

  3. YUM更换源(1)--yum找不到安装包

    公司提供的CentOS VM中,/etc/yum.repos.d 下 只有一个build.repo,其中提供的yum 源只有公司内部的几个源,很多包在这些源中都找不到.于是要添加别的源,下面的帖子中介 ...

  4. yum更换源配置

    今天安装mysql5.7的时候出现了点问题,最后更换yum源解决了,把这个记录一下 yum源配置(阿里云源) 1) 安装wget yum install -y wget 2) 备份/etc/yum.r ...

  5. Linux(CentOS7)yum安装卸载命令,离线下载安装包

    一.Linux版本 二.yum安装 比如安装vim编辑器,y是自动应答,即默认一路确认,不用中途确认 yum install -y vim 三.yum卸载 比如卸载掉刚刚安装的vim yum eras ...

  6. centos7 下解决mysql-server找不到安装包问题

    第一步:安装从网上下载文件的wget命令 [root@master ~]# yum -y install wget 第二步:下载mysql的repo源 [root@master ~]# wget ht ...

  7. linux 源码包之脚本安装包的安装

    脚本安装包 脚本安装包并不是独立的软件包类型,常见的实际是源码包.是人为地把安装过程写成了自动安装脚本,只要执行脚本,定义简单的参数,就可以完成安装.非常类似于windows软件的安装方式.在linu ...

  8. 解决rhel相关系统下yum找不到安装包的解决方法

    最近重新安装了Linux,用的版本是CentOS 5.1.但老是出现很多包找不到的情况. [root@toughhou /]# yum install rlwrap Loaded plugins: f ...

  9. 更换pip源,解决pip install安装包慢的问题

    而pip是很强大的Python包安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以最好是将使用的pip源更换一下,这样就能解决被墙导致的装不上库的问题.网上有很多可用的源,例如豆瓣:http ...

随机推荐

  1. js的function中的指向自身的属性

    1,arguments.callee 2,方法的constructor

  2. 初学者必看:精心整理的Javascript操作JSON总结

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...

  3. EcStore中的App是什么东西?

    Ecstore中的App不是手机上的App,它是一个Web应用包,集合了Web应用的后端PHP程序.Mysql数据表定义,以及前端HTML+CSS+JS展现,通常是实现某个业务功能,如购物车.促销.支 ...

  4. 玩转Firefox侧栏

    偶然看到煎蛋网的"玩转firefox侧栏",才注意到它. Firefox侧栏有啥不一样? Firefox可以在侧栏中打开网页. 于是,一系列玩法就出来了... 侧栏打开在线应用 G ...

  5. C# unsafe code

    (*) unsafe 和 fixed unsafe {                    ];     ; i < array.Length; i++)     {         arra ...

  6. 几道C语言的题目!

    注:编译环境 VC2010,系统WIN7 64位,其他编译环境和系统未测试   1-1. 编程,输入n,输出如下例(n=5)所示的图形: ***** ***** ***** ***** ***** # ...

  7. WIN7_64位系统安装oracle以及PLSQL方法(不用装32位oracle客户端)

    一.oracle10g安装,比较简单 1.去Oracle网站下载Vista版的Oracle:Oracle Database 10g Release 2 (10.2.0.4) for Microsoft ...

  8. LeeCode-Sqrt(x)

    Implement int sqrt(int x). Compute and return the square root of x. int mySqrt(int x) { ) ; /* for(i ...

  9. 格而知之8:我所理解的Runtime(3)

    关联对象 14.使用Category对类进行拓展的时候,只能添加方法,而不适合添加属性(可以添加属性,也可以正常使用get方法和set方法,只是不会自动生成以下划线开头命名的成员变量). 可以通过关联 ...

  10. ubuntu下安装xlrd模块,Mysqldb模块

    Python中安装xlrd模块 1.从 https://pypi.python.org/pypi/xlrd  下载压缩包 2.解压所下载的压缩包 3.CD到解压文件夹,运行 sudo python s ...