修改CentOS的YUM源


CentOS配置本地yum源/阿里雲yum源/163yuan源並配置yum源的優先級

1.查看本地yum源

 

 2.把默認yum源備份

mkdir /opt/centos-yum.bak

mv /etc/yum.repos.d/* /opt/centos-yum.bak/

一、用Centos鏡像搭建本地yum源

1.掛載CentOS鏡像文件

mount -t iso9660 /dev/sr0 /opt/centos

2.寫repo文件並指向鏡像的掛載目錄

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

[ local ]
name= local
baseurl= file : ///opt/centos
enabled=1
gpgcheck=0
 
3.清除緩存
yum clean all
yum makecache   
yum list   
 
二、把默認的CentOS yum源修改成國內的aliyun yum源(yum install wget -y )
1.下載aliyun yum源repo文件(對應自己的系統版本下載即可)
#各系統版本repo文件對應的下載操作
CentOS 5
wget -O /etc/yum .repos.d /CentOS-Base .repo http: //mirrors .aliyun.com /repo/Centos-5 .repo
CentOS 6
wget -O /etc/yum .repos.d /CentOS-Base .repo http: //mirrors .aliyun.com /repo/Centos-6 .repo
CentOS 7
wget -O /etc/yum .repos.d /CentOS-Base .repo http: //mirrors .aliyun.com /repo/Centos-7 .repo
 
2.  cat /etc/redhat-release        //查看系統的版本

 

 

3.下載對應的YUM源

 

 4.清除緩存

yum clean all
yum makecache   
yum list 
 
 
三、把默認的CentOS yum源修改成國內的163源
1.下載163 yum源repo文件
#各系統版本repo文件對應的下載操作
CentOS 5
wget -O /etc/yum .repos.d /CentOS5-Base-163 .repo http: //mirrors .163.com/.help /CentOS5-Base-163 .repo
CentOS 6
wget -O /etc/yum .repos.d /CentOS6-Base-163 .repo http: //mirrors .163.com/.help /CentOS6-Base-163 .repo
CentOS 7
wget -O /etc/yum .repos.d /CentOS7-Base-163 .repo http: //mirrors .163.com/.help /CentOS7-Base-163 .repo
 
2. cat /etc/redhat-release    //查看系統的版本
3.下載對應的YUM源
 
 
 

 4.清除緩存

yum clean all
yum makecache   
yum list 
 
 
四、修改yum源的優先級
1.查看系統是否安裝了優先級的插件
rpm -qa | grep yum-plugin-
2.用search查看是否有此插件可用(yum search yum-plugin-priorities),如果沒有就安裝yum-plugin-priorities.noarch插件

 

 3.查看插件是否啟用

cat /etc/yum/pluginconf.d/priorities.conf

 

 4.修改本地yum源優先使用

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

priority=1
// 在原基礎上加入priority=1 ;數字越小優先級越高
// 可以繼續修改其他源的priority值,經測試僅配置本地源的優先級為priority=1就會優先使用本地源了
 
 
參考文獻:https://www.jb51.net/article/169208.htm
阿里雲官方教程: http://mirrors.aliyun.com/help/centos


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM