centos7.repo配置解读
centos.repo 是 CentOS 系统中用于定义软件仓库的配置文件。它指定了系统从哪里获取软件包和更新
cloud-mirror
1.部分配置样例
...
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
....
[extras] 默认是开启的(enabled=1 default)
2.完整配置centos7.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
配置文件 centos.repo
是 CentOS 系统中用于定义软件仓库的配置文件。它指定了系统从哪里获取软件包和更新。
1. 配置文件结构
配置文件由多个部分组成,每个部分定义了一个软件仓库。每个仓库的配置以 [section_name]
开头,后面跟着一系列的键值对。
2. 主要配置项
- [base]: 定义了 CentOS 的基础软件仓库。
- [updates]: 定义了 CentOS 的更新软件仓库。
- [extras]: 定义了额外的软件包仓库。
- [centosplus]: 定义了扩展功能的软件包仓库。
- [contrib]: 定义了由 CentOS 用户贡献的软件包仓库。
3. 配置项详解
- name: 仓库的名称,用于标识仓库。
- failovermethod: 指定了当主镜像不可用时,如何选择备用镜像。
priority
表示按优先级选择。 - baseurl: 指定了仓库的 URL 地址。可以有多个 URL,系统会按顺序尝试访问。
- gpgcheck: 指定是否启用 GPG 检查。
1
表示启用,0
表示禁用。 - gpgkey: 指定用于验证软件包的 GPG 密钥的 URL。
- enabled: 指定是否启用该仓库。
1
表示启用,0
表示禁用。
4. 具体配置解读
[base]: 基础仓库,包含了 CentOS 的核心软件包。
baseurl
指定了阿里云的镜像地址,系统会从这些地址下载基础软件包。gpgcheck=1
表示启用 GPG 检查,确保软件包的完整性和来源可信。gpgkey
指定了 GPG 密钥的地址,用于验证软件包。
[updates]: 更新仓库,包含了 CentOS 的更新软件包。
baseurl
指定了阿里云的镜像地址,系统会从这些地址下载更新软件包。gpgcheck=1
表示启用 GPG 检查。gpgkey
指定了 GPG 密钥的地址。
[extras]: 额外仓库,包含了一些可能有用的额外软件包。
baseurl
指定了阿里云的镜像地址,系统会从这些地址下载额外软件包。gpgcheck=1
表示启用 GPG 检查。gpgkey
指定了 GPG 密钥的地址。
[centosplus]: 扩展功能仓库,包含了一些扩展功能的软件包。
baseurl
指定了阿里云的镜像地址,系统会从这些地址下载扩展功能软件包。gpgcheck=1
表示启用 GPG 检查。enabled=0
表示默认禁用该仓库。gpgkey
指定了 GPG 密钥的地址。
[contrib]: 用户贡献仓库,包含了由 CentOS 用户贡献的软件包。
baseurl
指定了阿里云的镜像地址,系统会从这些地址下载用户贡献的软件包。gpgcheck=1
表示启用 GPG 检查。enabled=0
表示默认禁用该仓库。gpgkey
指定了 GPG 密钥的地址。
5. 变量说明
$releasever
: 表示 CentOS 的版本号(如 7、8 等)。$basearch
: 表示系统的基础架构(如 x86_64)。
6. 总结
这个配置文件定义了 CentOS 系统从阿里云镜像站点获取软件包的多个仓库。每个仓库都有多个镜像地址,系统会按顺序尝试访问这些地址。GPG 检查被启用以确保软件包的安全性。部分仓库(如 centosplus
和 contrib
)默认是禁用的,需要手动启用。