当前位置: 首页 > news >正文

Centos 修改 yum 源为阿里云

参考

https://serverfault.com/questions/1161816/mirrorlist-centos-org-no-longer-resolve

修改 Centos 的 yum 源为阿里云

去阿里云 yum 镜像源官网:

https://developer.aliyun.com/mirror/

选择自己对应的操作系统,这里以 centos7 演示:

先备份原 yum 配置文件:

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

下载了阿里云提供的 CentOS 7 的 Yum 源配置文件,并将其覆盖到系统中的 /etc/yum.repos.d/CentOS-Base.repo 文件:

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo# 或使用 curl 下载文件
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

清除旧缓存:

sudo yum clean all

生成新缓存:

sudo yum makecache

检验新配置是否生效:

yum repolist

提示不能解析 mirrorlist.centos.org

Could not retrieve mirrorlist http://mirrorlist.centos.org?arch=x86_64&release=7&repo=sclo-rh error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"One of the configured repositories failed (未知),and yum doesn't have enough cached data to continue. At this point the onlysafe thing yum can do is fail. There are a few ways to work "fix" this:1. Contact the upstream for the repository and get them to fix the problem.2. Reconfigure the baseurl/etc. for the repository, to point to a workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=<repoid> ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable <repoid>orsubscription-manager repos --disable=<repoid>5. Configure the failing repository to be skipped, if it is unavailable.Note that yum will try to contact the repo. when it runs most commands,so will have to try and fail each time (and thus. yum will be be muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

执行如下命令:

sudo sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/CentOS-*.repo
sudo sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/CentOS-*.repo
sudo sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/CentOS-*.repo
http://www.lryc.cn/news/518047.html

相关文章:

  • Qt之Cannot create children for a parent that is in a different thread问题分析
  • 均值滤波从图像复原角度的解释
  • Tableau数据可视化与仪表盘搭建-数据连接
  • VsCode对Arduino的开发配置
  • 2024版idea 插件无法加载
  • VLMs之Agent之CogAgent:CogAgent的简介、安装和使用方法、案例应用之详细攻略
  • Unity3D仿星露谷物语开发19之库存栏丢弃及交互道具
  • Kafka优势剖析-消费者组、并行消费
  • Docker+Jmeter+InfluxDB+Grafana 搭建性能监控平台
  • Maven 详细配置:Maven settings 配置文件的详细说明
  • 【文本分类】bert二分类
  • 单例模式-如何保证全局唯一性?
  • 设计模式学习笔记——结构型模式
  • WEB攻防-通用漏洞_文件上传_黑白盒审计流程
  • RabbitMQ基本介绍及简单上手
  • 服务器证书不受信任是什么问题?
  • spring mvc源码学习笔记之十
  • Ubuntu 下载安装 elasticsearch7.17.9
  • Qt笔记:网络编程Tcp
  • C++单例模式跨DLL调用问题梳理
  • oracle闪回版本查询
  • C#用winform窗口程序操作服务+不显示Form窗体,只显示右下角托盘图标+开机时自启动程序【附带项目地址】
  • UOS系统和windows系统wps文档显示差异问题解决
  • JS中函数基础知识之查漏补缺(写给小白的学习笔记)
  • 蓝桥杯训练
  • 前端学习DAY33(外边距的折叠)
  • asp.net core mvc的 ViewBag , ViewData , Module ,TempData
  • Linux驱动学习之第二个驱动程序(LED点亮关闭驱动程序-分层设计思想,使其能适应不同的板子-驱动程序模块为多个源文件怎么写Makefile)
  • 手写@EnableTransactionalManagement
  • 【Vue】:解决动态更新 <video> 标签 src 属性后视频未刷新的问题