且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CentOS添加多个yum源(转)

更新时间:2022-10-01 13:19:18

yum源设置路径

/etc/yum.repos.d/

新建或复制一个文件  后缀名为repo再倒入key即可

以中国科技大学源为例

新建ustc.repo

内容为

#centos-ustc-edu-cn.repo
#
# 中国科技大学,速度不错
# rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# 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-5 - Base
repo=os
baseurl=http://centos.ustc.edu.cn/centos/5.6/os/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[update]
name=CentOS-5 - Updates
baseurl=http://centos.ustc.edu.cn/centos/5.6/updates/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[addons]
name=CentOS-5 - Addons
baseurl=http://centos.ustc.edu.cn/centos/5.6/addons/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[extras]
name=CentOS-5 - Extras
baseurl=http://centos.ustc.edu.cn/centos/5.6/extras/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[centosplus]
name=CentOS-5 - Plus
baseurl=http://centos.ustc.edu.cn/centos/5.6/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

[contrib]
name=CentOS-5 - Contrib
baseurl=http://centos.ustc.edu.cn/centos/5.6/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5


导入key rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-5

 

源都添加完了之后,再装个插件,yum install yum-fastestmirror -y,这个会自动选择快的那个源。


如果我在那个目录里放了很多源,怎么知道当前用的是那个呢?如果你没有改yum.conf,那么看/var/cache/yum/文件夹里的一个time开头的文件,就知道了

 

 

 

如果在使用yum install安装找不到某些包的时候,可以使用下面办法试试

wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

 

来源:http://singlegod.blog.51cto.com/1909710/557566

本文转自孤舟夜航之家博客51CTO博客,原文链接http://blog.51cto.com/cysky/557743如需转载请自行联系原作者


cysky