将CentOS的yum源更换为国内镜像源

1.备份

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

.2.下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/

CentOS6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo



wget 命令 -O 参数含义:

    -O  --output-document=文件,将数据写入此文件中。

    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

    的含义即为

    将 http://mirrors.aliyun.com/repo/Centos-7.repo 文件中的数据写入到/etc/yum.repos.d/CentOS-Base.repo文件中,CentOS-Base.repo文件不需要事先创建。

    参考链接:wget命令详解 https://www.jianshu.com/p/2e2ba8ecc22a



3.之后运行yum makecache生成缓存

yum makecache

这一步还是比较耗时的,而且速度不快几k到几十k每秒之间,可以不执行。


最终效果

最终效果yum源更换为国内阿里镜像源后,yum 安装或更新包的速度非常快,保持在 几MB/s

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容