综合 CentOS 镜像源配置

2024-11-18 11:28:06 +0800 CST views 833

CentOS 镜像源配置

1. 基础镜像源配置

1.1 简介

CentOS 是基于 Red Hat Linux 提供的可自由使用源代码的企业级 Linux 发行版本,是一个稳定、可预测、可管理和可复制的免费企业级计算平台。

1.2 相关仓库

1.3 配置方法

通知:CentOS 8 操作系统版本结束了生命周期(EOL),Linux 社区已不再维护该操作系统版本。建议切换到 Anolis 或 Alinux。如果仍需使用 CentOS 8 系统中的一些安装包,可根据以下步骤切换到 CentOS 8 的源。

配置阿里云镜像源

  1. 备份原始文件:
sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. 下载阿里云镜像源配置文件:
  • CentOS 8(建议切换到 centos-vault 源):
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
# 或
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
  • CentOS 7
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
# 或
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
  • CentOS 6(建议切换到 centos-vault 源):
sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
# 或
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
  1. 清理缓存并生成新缓存:
sudo yum clean all
sudo yum makecache

解决非阿里云 ECS 用户提示问题

如果不是阿里云 ECS 用户,可能会出现 Couldn’t resolve host 'mirrors.cloud.aliyuncs.com' 信息,但不影响使用。你也可以删除相关配置:

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

1.4 相关链接

2. EPEL 源配置

2.1 简介

EPEL(Extra Packages for Enterprise Linux),是由 Fedora Special Interest Group 维护的 Enterprise Linux(RHEL、CentOS)中常用的额外软件包。

2.2 相关仓库

2.3 配置方法

  1. 备份现有 EPEL 配置(如已配置):
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
  1. 下载 EPEL 配置文件:
  • RHEL 8 / CentOS 8
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
  • 替换 EPEL 源地址为阿里云镜像站地址:
sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
  • RHEL 7 / CentOS 7
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
  • RHEL 6 / CentOS 6(建议切换到 epel-archive 源):
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-archive-6.repo

2.4 相关链接

3. 其他可用镜像源

复制全文 生成海报 Linux 操作系统 软件管理 开源

推荐文章

Vue3 vue-office 插件实现 Word 预览
2024-11-19 02:19:34 +0800 CST
404错误页面的HTML代码
2024-11-19 06:55:51 +0800 CST
Vue3中的v-slot指令有什么改变?
2024-11-18 07:32:50 +0800 CST
js一键生成随机颜色:randomColor
2024-11-18 10:13:44 +0800 CST
SQL常用优化的技巧
2024-11-18 15:56:06 +0800 CST
小技巧vscode去除空格方法
2024-11-17 05:00:30 +0800 CST
Vue3中如何处理权限控制?
2024-11-18 05:36:30 +0800 CST
纯CSS实现3D云动画效果
2024-11-18 18:48:05 +0800 CST
Elasticsearch 监控和警报
2024-11-19 10:02:29 +0800 CST
markdowns滚动事件
2024-11-19 10:07:32 +0800 CST
2025,重新认识 HTML!
2025-02-07 14:40:00 +0800 CST
windows下mysql使用source导入数据
2024-11-17 05:03:50 +0800 CST
【SQL注入】关于GORM的SQL注入问题
2024-11-19 06:54:57 +0800 CST
浅谈CSRF攻击
2024-11-18 09:45:14 +0800 CST
利用Python构建语音助手
2024-11-19 04:24:50 +0800 CST
如何在Vue中处理动态路由?
2024-11-19 06:09:50 +0800 CST
如何开发易支付插件功能
2024-11-19 08:36:25 +0800 CST
Vue3中的Slots有哪些变化?
2024-11-18 16:34:49 +0800 CST
jQuery `$.extend()` 用法总结
2024-11-19 02:12:45 +0800 CST
程序员茄子在线接单