Linux centos添加源+网易163源+搜狐源

默认centos自带的源少了很多好软件,所以需要添加第三方源


一、安装CentOS yum源优先级插件yum-priorities
yum install yum-plugin-priorities.noarch


二、设置CentOS默认yum源的优先级为最高
cd /etc/yum.repos.d/ #进入yum源目录
vi CentOS-Base.repo #在[base]、[updates]、[extras]组下面添加priority=1,在[centosplus]、[contrib]组下面添加priority=2


################################################################ 
[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1

[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1

[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=1

[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=2

[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
priority=2
############################################################### 
备注:priority的优先级为1到99,设置为1即优先级最高,1-10为系统保留,第三方yum源的优先级从11-99


当 Fedora 项目的维护人员发现可以采用管理 Fedora 项目的方法,来管理针对企业版 Linux 的附加软件包项目时,一个新的伟大的项目诞生了!项目诞生之初只是加入了一些在 RHEL 维护 Fedora 的工具。随着时间的发展,EPEL 仓库越来越丰富,成为一个大型的软件收集仓库


安装epel源的好处就是epel这个项目是由fedora维护的,在维护的这个源中包含许多新的软件

 [root@localhost tmp]# wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

正在解析主机 dl.fedoraproject.org... 209.132.181.24, 209.132.181.25, 209.132.181.26, ...
正在连接 dl.fedoraproject.org|209.132.181.24|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:14540 (14K) [application/x-rpm]
正在保存至: “epel-release-6-8.noarch.rpm”

100%[======================================>] 14,540 72.4K/s in 0.2s

 16:29:52 (72.4 KB/s) - 已保存 “epel-release-6-8.noarch.rpm” [14540/14540])

[root@localhost tmp]# rpm -ivh epel-release-6-8.noarch.rpm
warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]
epel安装完之后只是在/etc/yum.repos.d/生成了两个文件,一个是epel.repo,一个是epel-testing.repo
[root@localhost ~]# ls /etc/yum.repos.d/
CentOS-Base.repo CentOS-Media.repo epel.repo

CentOS-Debuginfo.repo CentOS-Vault.repo epel-testing.repo

vi /etc/yum.repos.d/epel.repo (具体根据实际源目录地址,注意字母大小写,有的CENTOS系统是大小写交叉的)  

#修改epel yum源优先级,priority=11

###############################################################
[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
priority=11

安装atomic yum源
wget http://www.atomicorp.com/installers/atomic #下载
sh ./atomic #安装
  vi /etc/yum.repos.d/atomic.repo #修改atomic yum源优先级,priority=12
##############################################################
[atomic]
name = CentOS / Red Hat Enterprise Linux $releasever - atomicrocketturtle.com
mirrorlist = http://www.atomicorp.com/mirrorlist/atomic/centos-6-$basearch
#mirrorlist = http://www.atomicorp.com/channels/atomic/centos/6/mirrors-atomic
enabled = 1
priority = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
gpgcheck = 1
priority=12
##############################################################

添加163+网易源使用如下方法:

首先备份/etc/yum.repos.d/CentOS-Base.repo
Mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)

当然更简单的办法是wget

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

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

然后运行yum makecache生成缓存


最后安装好第三方源时记得 更新yum软件包
yum check-update



来源:http://blog.csdn.net/zqtsx/article/details/39207069

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值