如何在 Satellite/Katello/Foreman 上同步 CentOS 8 存储库
在本指南中,我们将学习如何在 Foreman Katello 和 Red Hat Satellite 上同步和存储 CentOS 8 BaseOS 和 AppStream 存储库。 Foreman 是一个开源应用程序,用于物理和虚拟系统的配置和生命周期管理。
Foreman 是红帽卫星核心功能的基础。 Katello 是一个用于订阅和存储库管理的 Foreman 插件。它允许您在本地存储存储库,并提供订阅这些存储库和下载内容的方法。
如果您没有 Foreman/Red Hat Satellite,请检查:
如何使用 Rsync 和 Nginx 创建 CentOS 8 本地存储库镜像
第 1 步:创建产品
我们首先创建一个产品,这是在 CLI 或 Web 控制台上完成的。
从 CLI:
- 列出组织:
hammer organization list
- 创建产品
hammer product create --organization-id 1 \
--name "CentOS 8 Linux for x86_64" \
--description "Repositories to use with CentOS 8 Linux"
从 Web 控制台
转到产品> 创建产品
输入产品详细信息并单击保存按钮以创建产品。
步骤2:导入CentOS 8 GPG密钥
从 CLI
mkdir /etc/pki/rpm-gpg/import/
cd /etc/pki/rpm-gpg/import/
wget https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
hammer gpg create --organization-id 1 \
--key "RPM-GPG-KEY-CentOS-Official" \
--name "RPM-GPG-KEY-CentOS-8"
要从 Web 控制台创建,请导航至内容 > 凭据 > 新内容凭据
提供关键信息 - 名称、键入并粘贴关键内容或使用浏览按钮上传。
第 3 步:创建存储库
添加产品和内容凭据后,您现在可以将 CentOS 8 的存储库添加到创建的产品中。
Hammer CLI
- BaseOS存储库
hammer repository create --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 Base RPMS" \
--label "CentOS_8_Base_RPMS" \
--content-type "yum" \
--download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \
--url "http://centos.mirror.liquidtelecom.com/8/BaseOS/x86_64/os/" \
--mirror-on-sync "no"
- AppStream 存储库
hammer repository create --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 AppStream RPMS" \
--label "CentOS_8_AppStream_RPMS" \
--content-type "yum" \
--download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \
--url "http://centos.mirror.liquidtelecom.com/8/AppStream/x86_64/os/" \
--mirror-on-sync "no"
- PowerTools 存储库
hammer repository create --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 PowerTools RPMS" \
--label "CentOS_8_PowerTools_RPMS" \
--content-type "yum" \
--download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \
--url "http://centos.mirror.liquidtelecom.com/8/PowerTools/x86_64/os/" \
--mirror-on-sync "no"
- Centosplus 存储库
hammer repository create --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 centosplus RPMS" \
--label "CentOS_8_centosplus_RPMS" \
--content-type "yum" \
--download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \
--url "http://centos.mirror.liquidtelecom.com/8/centosplus/x86_64/os/" \
--mirror-on-sync "no"
- 额外存储库
hammer repository create --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 extras RPMS" \
--label "CentOS_8_extras_RPMS" \
--content-type "yum" \
--download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \
--url "http://centos.mirror.liquidtelecom.com/8/extras/x86_64/os/" \
--mirror-on-sync "no"
要查看产品中的存储库,请运行命令。
$ hammer repository list --organization-id 1 --product "CentOS 8 Linux for x86_64"
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
ID | NAME | PRODUCT | CONTENT TYPE | URL
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
65 | CentOS 8 AppStream RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/AppStream/x86_64/os/
64 | CentOS 8 Base RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/BaseOS/x86_64/os/
67 | CentOS 8 centosplus RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/centosplus/x86_64/os/
68 | CentOS 8 extras RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/extras/x86_64/os/
66 | CentOS 8 PowerTools RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/PowerTools/x86_64/os/
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
从 Web 控制台
可以通过 产品 > 存储库下的 Foreman/Satellite 网络仪表板实现相同的效果
第 4 步:同步存储库
添加存储库后,启动同步以将存储库内容拉取到本地 Satellite/Katello 服务器。
Hammer CLI:
- 列出存储库
$ hammer repository list --organization-id 1 --product "CentOS 8 Linux for x86_64"
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
ID | NAME | PRODUCT | CONTENT TYPE | URL
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
65 | CentOS 8 AppStream RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/AppStream/x86_64/os/
64 | CentOS 8 Base RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/BaseOS/x86_64/os/
67 | CentOS 8 centosplus RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/centosplus/x86_64/os/
68 | CentOS 8 extras RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/extras/x86_64/os/
66 | CentOS 8 PowerTools RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/PowerTools/x86_64/os/
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
记下ID,然后循环同步存储库。
for i in $(seq 64 68); do \
hammer repository synchronize --async --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--id "$i"; \
done
一段时间后确认同步状态。
$ hammer product list --name "CentOS 8 Linux for x86_64" --organization-id 1
---|---------------------------|----------------------------------------|---------------|--------------|------------------
ID | NAME | DESCRIPTION | ORGANIZATION | REPOSITORIES | SYNC STATE
---|---------------------------|----------------------------------------|---------------|--------------|------------------
37 | CentOS 8 Linux for x86_64 | Repositories for CentOS 8 Linux x86_64 | Mycompany LTD | 5 | Syncing Complete.
---|---------------------------|----------------------------------------|---------------|--------------|------------------
还可以在 Web 管理仪表板上启动同步。
第 5 步:创建内容视图
从 CLI 或 Web 控制台创建内容视图。
hammer content-view create --organization-id 1 \
--name "CentOS_8" \
--description "Content view for CentOS 8"
第 6 步:将存储库添加到内容视图
将存储库添加到创建的内容视图中。
for i in $(seq 64 68); do \
hammer content-view add-repository --organization-id 1 \
--name "CentOS_8" \
--product "CentOS 8 Linux for x86_64" \
--repository-id "$i"; \
done
第 7 步:发布内容视图
发布内容视图。
hammer content-view publish --organization-id 1 \
--name "CentOS_8" \
--description "Publishing repositories"
第 8 步:创建激活密钥
获取可用的生命周期环境:
$ hammer lifecycle-environment list --organization-id 1
---|---------|------
ID | NAME | PRIOR
---|---------|------
1 | Library |
---|---------|------
创建激活密钥
$ hammer activation-key create --organization-id 1 \
--name "centos8" \
--description "CentOS 8 Activation Key" \
--lifecycle-environment "Library" \
--content-view "CentOS_8" \
--unlimited-hosts
$ hammer activation-key list --organization-id 1
---|-----------------|------------------|-----------------------|--------------------------
ID | NAME | HOST LIMIT | LIFECYCLE ENVIRONMENT | CONTENT VIEW
---|-----------------|------------------|-----------------------|--------------------------
1 | centos7 | 0 of Unlimited | |
2 | centos8 | 0 of Unlimited | |
---|-----------------|------------------|-----------------------|--------------------------
第 9 步:将订阅添加到激活密钥
列出组织中的订阅
$ hammer subscription list --organization-id 1
将上面的订阅添加到我们的激活密钥中:
hammer activation-key add-subscription --organization-id 1 \
--name "centos8" \
--quantity "1" \
--subscription-id "164"
其中 164 是最后一个命令显示的订阅 ID。
第10步:将CentOS 8机器订阅到Satellite/Foreman (Katello)
我们的存储库现在可供 CentOS 8 客户端使用。我们有一份指南您也可以参考:
如何向 Katello/Foreman 订阅 CentOS 服务器
有关 CentOS 8 的更多信息:
使用 Cockpit 管理 CentOS 8
如何在 OpenStack 上创建 CentOS 8 KVM 镜像模板
在 CentOS 8/RHEL 8 上启用自动软件更新