16.3. 管理集中式 OSTree 镜像
对于生产环境,有一个提供所有提交的集中式 OSTree 镜像具有多个优点,包括:
- 去重和最小化磁盘存储
- 使用静态 delta 更新优化对客户端的更新
- 为部署生命周期指向一个 OSTree 镜像。
要管理集中式 OSTree 镜像,您必须将镜像构建器中的每个提交拉取到可供您的用户使用的集中式存储库中。
您还可以使用 infra.osbuild
Ansible 集合自动管理 OSTree 镜像。请参阅 osbuild.infra Ansible。
要创建一个集中式存储库,您可以直接在 web 服务器上运行以下命令:
流程
创建一个空蓝图,对其定制为使用 "rhel-92" 作为发行版:
name = "minimal-rhel92" description = "minimal blueprint for ostree commit" version = "1.0.0" modules = [] groups = [] distro = "rhel-92"
将蓝图推送到服务器:
# composer-cli blueprints push minimal-rhel92.toml
从您创建的蓝图中构建 RHEL for Edge Commit (
.tar
)镜像:# composer-cli compose start-ostree minimal-rhel92 edge-commit
检索
.tar criule
,并将其解压缩到磁盘:# composer-cli compose image _<rhel-92-uuid> $ tar -xf <rhel-92-uuid>.tar -C /usr/share/nginx/html/
磁盘上的
/usr/share/nginx/html/repo
位置将成为所有 refs 和 commit 的一个 OSTree 存储库。创建另一个空蓝图,对其定制为使用 "rhel-87" 作为 发行版:
name = "minimal-rhel87" description = "minimal blueprint for ostree commit" version = "1.0.0" modules = [] groups = [] distro = "rhel-87"
推送蓝图,并创建另一个 RHEL for Edge Commit (
.tar
)镜像:# composer-cli blueprints push minimal-rhel87.toml # composer-cli compose start-ostree minimal-rhel87 edge-commit
检索
.tar criule
,并将其解压缩到磁盘:# composer-cli compose image <rhel-87-uuid> $ tar -xf <rhel-87-uuid>.tar
将提交拉取到本地存储库。通过使用
ostree pull-local
,您可以将提交数据从一个本地存储库复制到另一个本地存储库。# ostree --repo=/usr/share/nginx/html/repo pull-local repo
可选:检查 OSTree 存储库的状态。以下是一个输出示例:
$ ostree --repo=/usr/share/nginx/html/repo refs rhel/8/x86_64/edge rhel/9/x86_64/edge $ ostree --repo=/usr/share/nginx/html/repo show rhel/8/x86_64/edge commit f7d4d95465fbd875f6358141f39d0c573df6a321627bafde68c73850667e5443 ContentChecksum: 41bf2f8b442a770e9bf03e096a46a286f5836e0a0702b7c3516ef4e0acec2dea Date: 2023-09-15 16:17:04 +0000 Version: 8.7 (no subject) $ ostree --repo=/usr/share/nginx/html/repo show rhel/9/x86_64/edge commit 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9 ContentChecksum: 70235bfb9cae82c53f856183750e809becf0b9b076122b19c40fec92fc6d74c1 Date: 2023-09-15 15:30:24 +0000 Version: 9.2 (no subject)
更新 RHEL 9.2 蓝图,以使其包含新软件包并构建新提交,例如:
name = "minimal-rhel92" description = "minimal blueprint for ostree commit" version = "1.1.0" modules = [] groups = [] distro = "rhel-92" [[packages]] name = "strace" version = "*"
推送更新的蓝图并创建一个新的 RHEL for Edge Commit (
.tar
)镜像,将 compose 指向现有的 OSTree 存储库:# composer-cli blueprints push minimal-rhel92.toml # composer-cli compose start-ostree minimal-rhel92 edge-commit --url http://localhost/repo --ref rhel/9/x86_64/edge
检索
.tar
文件,并将其解压缩到磁盘上:# rm -rf repo # composer-cli compose image <rhel-92-uuid> # tar -xf <rhel-92-uuid>.tar
将提交拉取到存储库:
# ostree --repo=/usr/share/nginx/html/repo pull-local repo
可选:再次检查 OSTree 存储库状态:
$ ostree --repo=/usr/share/nginx/html/repo refs rhel/8/x86_64/edge rhel/9/x86_64/edge $ ostree --repo=/usr/share/nginx/html/repo show rhel/8/x86_64/edge commit f7d4d95465fbd875f6358141f39d0c573df6a321627bafde68c73850667e5443 ContentChecksum: 41bf2f8b442a770e9bf03e096a46a286f5836e0a0702b7c3516ef4e0acec2dea Date: 2023-09-15 16:17:04 +0000 Version: 8.7 (no subject) $ ostree --repo=/usr/share/nginx/html/repo show rhel/9/x86_64/edge commit a35c3b1a9e731622f32396bb1aa84c73b16bd9b9b423e09d72efaca11b0411c9 Parent: 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9 ContentChecksum: 2335930df6551bf7808e49f8b35c45e3aa2a11a6c84d988623fd3f36df42a1f1 Date: 2023-09-15 18:21:31 +0000 Version: 9.2 (no subject) $ ostree --repo=/usr/share/nginx/html/repo log rhel/9/x86_64/edge commit a35c3b1a9e731622f32396bb1aa84c73b16bd9b9b423e09d72efaca11b0411c9 Parent: 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9 ContentChecksum: 2335930df6551bf7808e49f8b35c45e3aa2a11a6c84d988623fd3f36df42a1f1 Date: 2023-09-15 18:21:31 +0000 Version: 9.2 (no subject) commit 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9 ContentChecksum: 70235bfb9cae82c53f856183750e809becf0b9b076122b19c40fec92fc6d74c1 Date: 2023-09-15 15:30:24 +0000 Version: 9.2 (no subject) $ rpm-ostree db diff --repo=/usr/share/nginx/html/repo 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9 a35c3b1a9e731622f32396bb1aa84c73b16bd9b9b423e09d72efaca11b0411c9 ostree diff commit from: 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9 ostree diff commit to: a35c3b1a9e731622f32396bb1aa84c73b16bd9b9b423e09d72efaca11b0411c9 Added: elfutils-default-yama-scope-0.188-3.el9.noarch elfutils-libs-0.188-3.el9.x86_64 strace-5.18-2.el9.x86_64