EPEL 与额外仓库是什么
EPEL(Extra Packages for Enterprise Linux)是社区为 RHEL 系系统提供的补充仓库,收录基础仓库没有的常用软件。dnf config-manager 用于启用、禁用、新增仓库并查看生效状态,属于 dnf-plugins-core 提供的插件命令。
基本信息
| 适用平台 | RHEL / CentOS / Rocky / AlmaLinux / Fedora 等 dnf 系系统 |
|---|---|
| 命令语法 | dnf config-manager --set-enabled|--set-disabled 仓库 / --add-repo URL |
| 依赖 | config-manager 由 dnf-plugins-core 提供,精简系统上可能未预装 |
| 查看命令 | dnf repolist --enabled / dnf repolist --all |
典型使用场景
- 安装基础仓库没有的软件:fail2ban、certbot 等常用运维工具靠 EPEL 提供
- 接入内网镜像源:--add-repo 添加公司 Nexus 或 Artifactory 的 .repo 地址
- 临时禁用仓库排障:第三方仓库引发依赖冲突时先禁用再复现问题
- 确认仓库可用:装完报 404 或 GPG 错误时,用 repolist 与 makecache 定位问题层
- 统一分发仓库配置:把仓库定义交给配置管理工具,避免各机器手工维护
常用示例
常用示例
dnf install -y epel-release # 首选:官方包自带 GPG 公钥与仓库定义
dnf config-manager --set-enabled epel # 启用已安装但未启用的仓库
dnf config-manager --set-disabled epel # 排查依赖冲突时临时禁用
dnf config-manager --add-repo https://repo.example.com/nexus.repo # 新增内网仓库
dnf repolist --enabled # 确认仓库列表与包数量
dnf makecache # 刷新元数据,顺带验证仓库连通性
dnf --disablerepo=epel install nginx # 单次安装不带某仓库常用操作对照
| 操作 | 命令 | 说明 |
|---|---|---|
| 安装 EPEL | dnf install epel-release | 首选方式,含 GPG 公钥导入与仓库定义 |
| 启用/禁用 | dnf config-manager --set-enabled / --set-disabled | 临时排障或按策略控制 |
| 新增仓库 | dnf config-manager --add-repo URL | 内网镜像、第三方软件源 |
| 查看状态 | dnf repolist --all | 确认仓库名、启用状态与包数量 |
| 控制优先级 | priority=N(需 priority 插件) | 数字小优先级高,决定同名包来源 |
优先用 epel-release 包而不是手写 .repo 文件:官方包同时带上公钥导入与仓库定义,能省掉两类最常见的错误。
第三方仓库长期开启有风险:同一软件在多个仓库有不同构建,dnf 可能选到版本号更高但与本机库不兼容的包,陷入依赖地狱。
较新的 dnf5(RHEL 10 系等)中 config-manager 的参数形式有变化,操作前先 dnf config-manager --help 确认当前语法。