公司提供的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]:
在执行最后一步,即

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更换源(1)--yum找不到安装包的更多相关文章

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

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

  2. yum更换国内源 yum下载rpm包 源码包安装

    7.6 yum更换国内源 7.7 yum下载rpm包 7.8/7.9 源码包安装 yum更换国内源 cd  /etc/yum.repo.d/ 删除源 rm -f   dvd.repo rm -f  C ...

  3. Centos7使用yum安装程序软件时提示未找到安装包解决方法

    查找程序软件源,以sshd为例,假设sshd安装包无法找到,那么可以通过以下方法解决 yum provides sshd 然后我们就可以安装*.X86_64的程序软件源 例如yum install o ...

  4. yum,rpm等失效,使用系统安装包ISO文件降级程序恢复系统

    linux平台:REHL6.7 故障原因:由于不小心使用命令yum update nss误升级了工作平台中nss系列工具包导致系统中yum 和 rpm命令执行都报错. 由于yum rpm命令都不好用使 ...

  5. linux yum 下载至本地及使用本地缓存安装包

    由于网络安全的原因,服务器不允许上公网,有2种方案,解决这个问题 1.搭建yum服务器2.使用yum下载缓存进行封装,然后使用缓存安装 这里讲讲使用yum缓存封装 一.下载指定包及相关依赖 yum i ...

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

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

  7. yum更换源配置

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

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

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

  9. yum换源,rpm包下载,源码包安装

    一.yum更换源 yum自带源地址一般斗是国外的,可能下载速度略慢,我们可以自己换成国内的源,比如163等.比如配置163的yum源:1.先删除默认源文件dvd.repo # rm -f /etc/y ...

随机推荐

  1. 使用HttpUtils 上传视频文件

    private void shangchuan(){                 //文件的路径        //File file=new File(path);        File fi ...

  2. 解决 UNMOUNTABLE_BOOT_VOLUME 蓝屏【转载】

    现象:一台XP系统的机器,开机在滚动条阶段蓝屏,蓝屏代码大概是“UNMOUNTABLE_BOOT_VOLUME”. 用PE进系统后发现C盘的文件格式变为RAW,总容量等变为0 解决方法一:将故障机的硬 ...

  3. HDU - 5276 YJC tricks time

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5276   Sample Input 99000 0   Sample Output 00:01:30 ...

  4. 批量文件重命名工具-极力推荐 advanced renamer

    http://www.advancedrenamer.com/  功能太强大了,自己慢慢探索吧.

  5. 快速部署Python应用:Nginx+uWSGI配置详解

    在PHP里,最方便的就是deployment了,只要把php文件丢到支持PHP的路径里面,然后访问那个路径就能使用了:无论给主机添加多少PHP应用,只要把目录改好就没你的事了,完全不用关心php-cg ...

  6. DataBinding注意事项Error parsing XML: duplicate attribute以及如何在listview中使用DataBinding

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  7. Entity Framework 学习初级篇3-- LINQ TO Entities

    LINQ 技术(即 LINQ to Entities)使开发人员能够通过使用 LINQ 表达式和 LINQ 标准查询运算符,直接从开发环境中针对 实体框架对象上下文创建灵活的强类型查询.LINQ to ...

  8. 玩Mega8 智能充电器-12. 终于实现-dV检测(转)

    源:http://blog.chinaunix.net/uid-10701701-id-91873.html 2010.1.3 5:30终于补齐了. 电池充电的-dv 的检测系列图片请移步: http ...

  9. drawRect & layoutSubviews 调用时间

    首先两个方法都是异步执行.layoutSubviews方便数据计算,drawRect方便视图重绘.   layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSub ...

  10. (转)多个mapreduce工作相互依赖处理方法完整实例(JobControl)

    多个mapreduce工作相互依赖处理方法完整实例(JobControl) 原文地址:http://mntms.iteye.com/blog/2096456?utm_source=tuicool&am ...