tencent cloud

云服务器

动态与公告
产品动态
公共镜像更新动态
操作系统官方停止维护计划
产品公告
产品简介
云服务器概述
产品优势
基本概念
地域和可用区
新手指引
Service Regions and Service Providers
产品计费
计费概述
计费方式
计费项
转换计费方式
购买实例
变配费用说明
欠费说明
快速入门
通过自定义配置购买 Linux 云服务器
通过自定义配置购买 Windows 云服务器
用户指南
操作指南总览
使用限制总览
实例
竞价实例
预留实例
镜像
存储
备份与恢复
网络
安全
密码/密钥
监控与告警
运维管理
便捷功能
迁移服务器
在线迁移
迁移咨询
故障处理
无法登录云服务器问题处理思路
Windows 实例登录相关故障
Linux 实例登录相关故障
其他实例登录相关故障
实例运行故障
Linux 实例内存故障
网络故障
实践教程
云服务器选型建议
搭建环境
搭建网站
搭建应用
搭建可视化界面
本地文件上传到云服务器
网络性能测试
其他实践教程
API 文档
History
Introduction
API Category
Making API Requests
Region APIs
Instance APIs
Cloud Hosting Cluster APIs
Image APIs
Instance Launch Template APIs
Placement Group APIs
Key APIs
Security Group APIs
Network APIs
Data Types
Error Codes
安全与合规
访问管理
网络
常见问题
地域和可用区相关
计费相关
实例相关
存储相关
镜像相关
服务器迁移相关
网络相关
安全相关
操作系统相关
运维和监控相关
访问管理相关
NTP 服务相关
应用场景相关
服务协议
CVM Service Level Agreements
Red Hat Enterprise Linux 镜像服务协议
Public IP Service Level Agreement
词汇表

CentOS 6 切换 YUM 源

PDF
聚焦模式
字号
最后更新时间: 2024-01-06 17:38:11

操作背景

CentOS 6操作系统版本生命周期(EOL)于2020年11月30日结束,Linux 社区不再维护该操作系统版本。按照社区规则,CentOS 6的源地址 http://mirror.centos.org/centos-6/ 内容已移除,且目前第三方的镜像站中均已移除 CentOS 6的源。腾讯云的源 http://mirrors.tencent.com/http://mirrors.tencentyun.com/ 也无法同步到 CentOS 6的源,当您在腾讯云上继续使用默认配置的 CentOS 6的源会发生报错。
说明:
建议您升级操作系统至 CentOS 7及以上,如果您的业务过渡期仍需要使用 CentOS 6操作系统中的一些安装包,请根据本文提供的信息切换 CentOS 6的源。

操作步骤

1. 使用标准方式登录 Linux 实例(推荐)。您也可以根据实际操作习惯,选择其他不同的登录方式:
2. 执行以下命令,查看当前操作系统 CentOS 版本。
cat /etc/centos-release
返回结果如下图所示,则说明当前操作系统版本为 CentOS 6.9。


3. 执行以下命令,编辑 CentOS-Base.repo 文件。
vim /etc/yum.repos.d/CentOS-Base.repo
4. i 进入编辑模式,根据 CentOS 版本及网络环境修改 baseurl。
说明:
您可参考 内网服务公网服务 判断实例需使用的源:
内网访问需切换为:http://mirrors.tencentyun.com/centos-vault/6.x/ 源。
公网访问需切换为:http://mirrors.tencent.com/centos-vault/6.x/ 源。
本文以实例操作系统为 CentOS 6.9,使用内网访问为例。修改完成后 CentOS-Base.repo 文件如下图所示:

配置如下,您可按需获取:
[extras]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-6
enabled=1
baseurl=http://mirrors.tencentyun.com/centos-vault/6.9/extras/$basearch/
name=Qcloud centos extras - $basearch
[os]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-6
enabled=1
baseurl=http://mirrors.tencentyun.com/centos-vault/6.9/os/$basearch/
name=Qcloud centos os - $basearch
[updates]
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/centos/RPM-GPG-KEY-CentOS-6
enabled=1
baseurl=http://mirrors.tencentyun.com/centos-vault/6.9/updates/$basearch/
name=Qcloud centos updates - $basearch
5. ESC 输入 :wq 后,按 Enter 保存修改。
6. 执行以下命令,修改 CentOS-Epel.repo 文件。
vim /etc/yum.repos.d/CentOS-Epel.repo
7. i 进入编辑模式,根据实例网络环境修改 baseurl。 本文以使用内网访问为例,则将 baseurl=http://mirrors.tencentyun.com/epel/$releasever/$basearch/ 修改为 baseurl=http://mirrors.tencentyun.com/epel-archive/6/$basearch/ 即可。修改完成后如下图所示:

配置如下,您可按需获取:
[epel]
name=epel for redhat/centos $releasever - $basearch
failovermethod=priority
gpgcheck=1
gpgkey=http://mirrors.tencentyun.com/epel/RPM-GPG-KEY-EPEL-6
enabled=1
baseurl=http://mirrors.tencentyun.com/epel-archive/6/$basearch/
8. ESC 输入 :wq 后,按 Enter 保存修改。
9. 至此已完成 YUM 源切换,您可使用 yum install 命令安装所需软件。

帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈