centos7 modify the source yum Ali mirror

Reference blog:

You need to operate under the root account

  • The new system may need to open the network configuration, as follows
ip address
#查看网络连接设备
#可以看到两个设备: 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue 
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 
#那么,有线网就是叫enp1s0啦,(虚拟机一般为 ens33 )

// 打开有线网配置 
vi /etc/sysconfig/network-scripts/ifcfg-enp1s0  
// 最后一行,修改为YES 
ONBOOT=YES 
// 重启网络服务 
systemctl restart network.service
  • The backup system image source
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  • Download Ali mirror source, if not wget, use yum install wgetthe installation
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  • Run yum makecache generate cache
yum makecache
  • Then update
yum update
  • Increase epal source
// 安装epel源
yum install epel-release
// 修改为阿里的epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

// 安装yum源优先级管理工具
yum install -y yum-priorities
// 添加优先级(数字越小优先级越高)
vim /etc/yum.repo.d/epel.repo
priority=88
// 添加优先级(这个数要小于epel里的88即可)
vim /etc/yum.repo.d/Centos-7.repo
priority=6

// 开启yum源优先级功能
vim /etc/yum/pluginconf.d/priorities.conf
// 确保文件内容包含如下:
[main]
enabled=1

Guess you like

Origin www.cnblogs.com/raisok/p/11270629.html