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