CentOS8跟换阿里源时使用yum makecache时下载巨慢,最后失败的解决办法
froatmop 于 2020-11-20 23:00:01 发布 1504 收藏 3
文章标签: linux centos
版权
CentOS8跟换阿里源时使用yum makecache时下载巨慢,最后失败的解决办法
本来想装个CentOS 8虚拟机,费了半天劲才装好,装好之后想更换阿里源
准备照着下面的步骤做
博主连接:centos8更换国内源(阿里源)
#备份旧的配置文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
#下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
#并替换部分字段(非阿里云机器需要做)
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
vim CentOS-Base.repo 把$releasever改成8-stream
#生成缓存
yum makecache
但是当我执行到yum makecache时下载这个东西是巨慢->(8.7 kB/s)<-CentOS-8 - AppStream 6% [==- ] 8.7 kB/s……如下
[root@CentOS]# yum makecache
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
CentOS-8 - AppStream 6% [==- ] 8.7 kB/s | 388 kB 10:37 ETCentOS-8 - AppStream 6.5 kB/s | 388 kB 00:59
# 最后慢的都失败了,试了好几次都不行
Error: Failed to download metadata for repo 'AppStream': Librepo was interrupted by a signal
# 下面还有些错误信息,被我弄丢了…………………………
解决办法
最后终于找到了解决办法,小白果然解决要半天,找到之后就明白了,是CentOS-AppStream.repo的镜像还没改:
博主连接:Centos8 安装软件 Failed to synchronize cache for repo ‘AppStream’, ignoring this repo.
直接修改这个文件
vim /etc/yum.repos.d/CentOS-AppStream.repo
# CentOS-AppStream.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.
#
#
[AppStream]
name=CentOS-$releasever - AppStream
# 加上这一条就行了
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
# 把原来的这两条注释掉
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
把$releasever改成8-stream
这个mirrorlist我找的解决办法里面也没提,我也不知道怎么改,索性注释掉,知道的可以分享一下
然后
yum clean all
yum makecache
速度嗖嗖嗖就起来了,爽哉,原来的慢的我都快崩溃了,原来的速度(8.7 kB/s),现在的(3.3 MB/s)。
[root@CentOS]# yum makecache
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
CentOS-8 - AppStream 3.3 MB/s | 5.8 MB 00:01
CentOS-8 - Base - mirrors.aliyun.com 2.1 MB/s | 2.2 MB 00:01
CentOS-8 - Extras - mirrors.aliyun.com 19 kB/s | 8.6 kB 00:00