【centos8 镜像修改】centos8 镜像修改阿里云

要将 CentOS 8 的镜像源修改为阿里云镜像,你需要编辑 /etc/yum.repos.d/ 目录下的 .repo 文件。以下是具体的步骤:

  1. 备份原始的 .repo 文件

    在编辑之前,建议备份原始的 .repo 文件,以便在出现问题时可以恢复。

    bash 复制代码
    sudo cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    sudo cp -a /etc/yum.repos.d/CentOS-Stream-*.repo /etc/yum.repos.d/CentOS-Stream-*.repo.backup
  2. 编辑 .repo 文件

    使用文本编辑器打开每个 .repo 文件,并替换 mirrorlistbaseurl,使用阿里云的镜像地址。

    bash 复制代码
    sudo vi /etc/yum.repos.d/CentOS-Base.repo
    sudo vi /etc/yum.repos.d/CentOS-Stream-AppStream.repo
    sudo vi /etc/yum.repos.d/CentOS-Stream-BaseOS.repo

    对于每个文件,找到 [BaseOS][AppStream] 部分,并修改为:

    ini 复制代码
    [BaseOS]
    name=CentOS Stream $releasever - BaseOS
    baseurl=http://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    
    [AppStream]
    name=CentOS Stream $releasever - AppStream
    baseurl=http://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

    确保每个 [BaseOS][AppStream] 部分都使用了 baseurl 而不是 mirrorlist,并且 baseurl 设置为阿里云的地址。

  3. 清除缓存并测试

    修改完 .repo 文件后,清除 YUM 缓存并尝试重新同步仓库:

    bash 复制代码
    sudo dnf clean all
    sudo dnf makecache
    sudo dnf update

    这将清除缓存,重新生成缓存,并尝试更新系统。

  4. 验证修改

    你可以使用以下命令来检查当前使用的仓库源:

    bash 复制代码
    sudo dnf repolist

    这将列出所有已启用的仓库及其URL,确保它们都是指向阿里云的地址。

通过以上步骤,你应该能够成功将 CentOS 8 的镜像源修改为阿里云镜像。如果遇到任何问题,请检查 .repo 文件的语法是否正确,以及网络连接是否正常。

相关推荐
天翼云开发者社区11 分钟前
数字先锋 | 竞技科研蓝海,中南大学先“算”一步!
云计算·智算·算力建设
KubeSphere 云原生6 小时前
云原生周刊:K8s引领潮流
云计算·k8s·容器平台·kubesphere
Linux运维老纪14 小时前
K8s 分布式存储后端(K8s Distributed Storage Backend)
服务器·分布式·云原生·容器·kubernetes·云计算·运维开发
wzx_Eleven1 天前
利用腾讯云cloud studio云端免费部署deepseek-R1
人工智能·云计算·腾讯云
weixin_307779131 天前
Apache Hudi数据湖技术应用在网络打车系统中的系统架构设计、软硬件配置、软件技术栈、具体实现流程和关键代码
系统架构·云计算·aws
ALISHENGYA2 天前
并行计算、分布式计算与云计算:概念剖析与对比研究(表格对比)
云计算·并行计算
Anna_Tong2 天前
DataWorks 与传统数据治理方案相比有哪些优势?
大数据·数据库·阿里云·云计算·数据安全·dataworks
知识点集锦2 天前
【无标题】
网络·学习·microsoft·华为·云计算
facaixxx20242 天前
DeepSeek-R1大模型一键部署安装教程by腾讯云HAI,0基础免安装
人工智能·云计算·腾讯云
weixin_307779133 天前
在AWS上使用Flume搜集分布在不同EC2实例上的应用程序日志具体流程和代码
python·flask·云计算·flume·aws