前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >centos 镜像源_孩子镜像问题怎么解决

centos 镜像源_孩子镜像问题怎么解决

作者头像
全栈程序员站长
发布2022-09-27 11:07:32
7130
发布2022-09-27 11:07:32
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

CentOS8新镜像源【解决路径弃用问题】

方案1(脚本中会清空yum.repo.d内的文件)

==防盗标识:本文源文地址,未授权禁止转载https://blog.csdn.net/weixin_44331765/article/details/123068623

创建一个脚本文件cetos.sh

写入以下内容

执行bash centos.sh即可

代码语言:javascript
复制
#!/bin/bash
cp -r /etc/yum.repo.d /etc/yum.repo.d.bak
rm -rf /etc/yum.repo.d/*
cat >> /etc/yum.repo.d/CentOS-Base.repo << EOF # 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-8.5.2111 - Base - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/ gpgcheck=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official #additional packages that may be useful [extras] name=CentOS-8.5.2111 - Extras - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/extras/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/extras/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/extras/\$basearch/os/ gpgcheck=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official #additional packages that extend functionality of existing packages [centosplus] name=CentOS-8.5.2111 - Plus - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/centosplus/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/centosplus/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/centosplus/\$basearch/os/ gpgcheck=0 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official [PowerTools] name=CentOS-8.5.2111 - PowerTools - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/PowerTools/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/PowerTools/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/PowerTools/\$basearch/os/ gpgcheck=0 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official [AppStream] name=CentOS-8.5.2111 - AppStream - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/AppStream/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/AppStream/\$basearch/os/ gpgcheck=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official EOF

yum clean all && yum makecache

方案2替换原有的路径

  1. 手动替换:
代码语言:javascript
复制
替换CentOS-Linux-AppStream.repo中的内容
1. 注释#mirrorlist=xxxxx
2. 启用baseurl=xxx,并把baseurl中的http路径修改为:baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/extras/$basearch/os/
3. 同理替换CentOS-Linux-BaseOS.repo中的mirrorlist=xxx和baseurl并把地址换了即可
  1. 脚本执行:执行方法同1 centos.sh文件内容替换为
代码语言:javascript
复制
#!/bin/bash
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cat >> /etc/yum.repo.d/CentOS-Base.repo << EOF # 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-8.5.2111 - Base - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/BaseOS/\$basearch/os/ gpgcheck=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official #additional packages that may be useful [extras] name=CentOS-8.5.2111 - Extras - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/extras/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/extras/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/extras/\$basearch/os/ gpgcheck=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official #additional packages that extend functionality of existing packages [centosplus] name=CentOS-8.5.2111 - Plus - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/centosplus/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/centosplus/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/centosplus/\$basearch/os/ gpgcheck=0 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official [PowerTools] name=CentOS-8.5.2111 - PowerTools - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/PowerTools/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/PowerTools/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/PowerTools/\$basearch/os/ gpgcheck=0 enabled=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official [AppStream] name=CentOS-8.5.2111 - AppStream - mirrors.aliyun.com baseurl=http://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/\$basearch/os/ http://mirrors.aliyuncs.com/centos-vault/8.5.2111/AppStream/\$basearch/os/ http://mirrors.cloud.aliyuncs.com/centos-vault/8.5.2111/AppStream/\$basearch/os/ gpgcheck=0 gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official EOF
minorver=8.5.2111
sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^#baseurl=http://mirror.centos.org/&dollar;contentdir/&dollar;releasever/AppStream/&dollar;basearch/os/|baseurl=http://mirrors.aliyun.com/centos-vault/$minorver/extras/$basearch/os/|g" \
-i.bak \
/etc/yum.repos.d/CentOS-Linux-AppStream.repo

sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^#baseurl=http://mirror.centos.org/&dollar;contentdir/&dollar;releasever/BaseOS/&dollar;basearch/os/|baseurl=http://mirrors.aliyun.com/centos-vault/$minorver/extras/$basearch/os/|g" \
-i.bak \
/etc/yum.repos.d/CentOS-Linux-BaseOS.repo
dnf clean all
dnf makecache

参考连接1 参考连接2

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/179217.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • CentOS8新镜像源【解决路径弃用问题】
    • 方案1(脚本中会清空yum.repo.d内的文件)
      • 方案2替换原有的路径
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档