11.3. 管理集中式 OSTree 镜像


对于生产环境,有一个提供所有提交的集中式 OSTree 镜像有多个优点,包括:

  • 去重和最小化磁盘存储
  • 使用静态 delta 更新优化对客户端的更新
  • 为其部署生命周期指向一个 OSTree 镜像。

要管理集中式 OSTree 镜像,您必须将每个提交从 RHEL 镜像构建器拉取到可供您的用户使用的集中式存储库。

注意

您还可以使用 osbuild.infra Ansible 集合自动管理 OSTree 镜像。请参阅 osbuild.infra Ansible

要创建集中式存储库,您可以直接在 web 服务器上运行以下命令:

流程

  1. 创建一个空蓝图,对其进行自定义,以使用 "rhel-94" 作为 distro

    name = "minimal-rhel94"
    description = "minimal blueprint for ostree commit"
    version = "1.0.0"
    modules = []
    groups = []
    distro = "rhel-94"
    Copy to Clipboard Toggle word wrap
  2. 将蓝图推送到服务器:

    # composer-cli blueprints push minimal-rhel94.toml
    Copy to Clipboard Toggle word wrap
  3. 从您创建的蓝图中构建一个 RHEL for Edge Commit (.tar)镜像:

    # composer-cli compose start-ostree minimal-rhel94 edge-commit
    Copy to Clipboard Toggle word wrap
  4. 检索 .tar criule 并将其解压缩到磁盘上:

    # composer-cli compose image _<rhel-94-uuid>
    $ tar -xf <rhel-94-uuid>.tar -C /usr/share/nginx/html/
    Copy to Clipboard Toggle word wrap

    磁盘上的 /usr/share/nginx/html/repo 位置将成为所有 ref 和提交的一个 OSTree 存储库。

  5. 创建另一个空蓝图,对其进行自定义,以使用 "rhel-810" 作为 distro:

    name = "minimal-rhel810"
    description = "minimal blueprint for ostree commit"
    version = "1.0.0"
    modules = []
    groups = []
    distro = "rhel-810"
    Copy to Clipboard Toggle word wrap
  6. 推送蓝图并创建另一个 RHEL for Edge Commit (.tar)镜像:
# *composer-cli blueprints push minimal-rhel810.toml*
# *composer-cli compose start-ostree minimal-rhel810 edge-commit*
Copy to Clipboard Toggle word wrap
  1. 检索 .tar criule 并将其解压缩到磁盘上:

    # composer-cli compose image <rhel-810-uuid>
    $ tar -xf <rhel-810-uuid>.tar
    Copy to Clipboard Toggle word wrap
  2. 将提交拉取到本地存储库。通过使用 ostree pull-local,您可以将提交数据从一个本地存储库复制到另一个本地存储库。

    # ostree --repo=/usr/share/nginx/html/repo pull-local repo
    Copy to Clipboard Toggle word wrap
  3. 可选:检查 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.10
    (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.4
    (no subject)
    Copy to Clipboard Toggle word wrap
  4. 更新 RHEL 9.4 蓝图以包含新软件包,并构建新提交,例如:

    name = "minimal-rhel94"
    description = "minimal blueprint for ostree commit"
    version = "1.1.0"
    modules = []
    groups = []
    distro = "rhel-94"
    
    [[packages]]
    name = "strace"
    version = "*"
    Copy to Clipboard Toggle word wrap
  5. 推送更新的蓝图并创建一个新的 RHEL for Edge Commit (.tar)镜像,将 compose 指向现有的 OSTree 存储库:

    # composer-cli blueprints push minimal-rhel94.toml
    # composer-cli compose start-ostree minimal-rhel94 edge-commit --url http://localhost/repo --ref rhel/9/x86_64/edge
    Copy to Clipboard Toggle word wrap
  6. 检索 .tar 文件并将其解压缩到磁盘上:

    # rm -rf repo
    # composer-cli compose image <rhel-94-uuid>
    # tar -xf <rhel-94-uuid>.tar
    Copy to Clipboard Toggle word wrap
  7. 将提交拉取到存储库:

    # ostree --repo=/usr/share/nginx/html/repo pull-local repo
    Copy to Clipboard Toggle word wrap
  8. 可选:再次检查 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.10
    (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.4
    (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.4
    (no subject)
    
    commit 89290dbfd6f749700c77cbc434c121432defb0c1c367532368eee170d9e53ea9
    ContentChecksum:  70235bfb9cae82c53f856183750e809becf0b9b076122b19c40fec92fc6d74c1
    Date:  2023-09-15 15:30:24 +0000
    Version: 9.4
    (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
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat