Centos添加其他yum源

本文详细介绍了如何在CentOS系统中安装并设置YUM源优先级插件,包括设置默认YUM源的优先级,以及安装EPel和REMI等第三方YUM源,并调整其优先级,确保系统更新和软件包安装的稳定性和安全性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、安装CentOS yum源优先级插件yum-priorities

yum install yum-priorities   #输入y安装

二、设置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的优先级为199,设置为1即优先级最高,1-10为系统保留,第三方yum源的优先级从11-99

三、安装epel yum(转载自http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x 

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm



然后    vi    /etc/yum.repos.d/epel.repo   将其优先级设置为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



[epel-debuginfo]

name=Extra Packages for Enterprise Linux 6 - $basearch - Debug

#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

gpgcheck=1

priority=11



[epel-source]

name=Extra Packages for Enterprise Linux 6 - $basearch - Source

#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

gpgcheck=1



priority=11

 

 

四:安装remi源:

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

导入key

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi

更改优先级: 

vi /etc/yum.repos.d/remi.repo 

如下将优先级设置为 12   

[remi]

name=Les RPM de remi pour Enterprise Linux 6 - $basearch

#baseurl=http://rpms.famillecollet.com/enterprise/6/remi/$basearch/

mirrorlist=http://rpms.famillecollet.com/enterprise/6/remi/mirror

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

priority=12



[remi-test]

name=Les RPM de remi en test pour Enterprise Linux 6 - $basearch

#baseurl=http://rpms.famillecollet.com/enterprise/6/test/$basearch/

mirrorlist=http://rpms.famillecollet.com/enterprise/6/test/mirror

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi



priority=12





[remi-debuginfo]

name=Les RPM de remi pour Enterprise Linux 6 - $basearch - debuginfo

baseurl=http://rpms.famillecollet.com/enterprise/6/debug-remi/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi



[remi-test-debuginfo]

name=Les RPM de remi en test pour Enterprise Linux 6 - $basearch - debuginfo

baseurl=http://rpms.famillecollet.com/enterprise/6/debug-test/$basearch/

enabled=0

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-remi

priority=12

 

 

nux源

http://li.nux.ro/repos.html

转载于:https://www.cnblogs.com/jiahu-Blog/p/3527422.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值