centos7的yum镜像源设置
sudo yum repolist
查看镜像源连接情况,not found即为连接失败
sudo cp -r /etc/yum.repos.d /etc/yum.repos.d.backup
备份镜像源文件
sudo nano /etc/yum.repos.d/CentOS-Base.repo
进入镜像源文件编辑内容
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
将文件内容更新如图所示,阿里的镜像源(使用了官方的好像不行,也是需要改文件即可)
Ctrl+o为保存内容
Ctrl+x为退出编辑
sudo yum clean all
sudo yum repolist enabled #查看一下镜像源列表,sudo是针对于特殊文件用户,可取消试试
sudo yum makecache
sudo yum update
清除yum缓存并更新内容
直至出现完毕!即为更新成功