centos7配置网络源


现在配置yum源都是下载什么什么就好了不能自定义 今天我就遇到了这个问题
就是这种 丝毫没有配置的快乐

获取阿里yum源配置文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 

备份一下当前的源

cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.bak

然后就是寻找源centos在centos官网
找到了就是复制地址
这个是我配置好的https://mirrors.cat.net/centos/ 地址是这个对着默认的看就懂了

# 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
#mirrorlist=https://mirrors.cat.net/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://mirrors.cat.net/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://mirrors.cat.net/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://mirrors.cat.net/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://mirrors.cat.net/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

这里解释一下都要换

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
这一句应该是通过官网获取最近的镜像地址 但是我们是手动配置所以需要注释
baseurl=https://mirrors.cat.net/centos/$releasever/os/$basearch/
这一句最开始是注释的因为他是自动选择源这里https://mirrors.cat.net/centos/ 换成你找的源就好了

清理旧包

yum clean all

生成yum源缓存并更新yum源

yum makecache
yum update

然后就好了

声明:小小博客|版权所有,违者必究|如未注明,均为原创|本网站采用BY-NC-SA协议进行授权

转载:转载请注明原文链接 - centos7配置网络源


Carpe Diem and Do what I like