3.12. 在 Satellite 中使用外部数据库


作为 Red Hat Satellite 的安装过程的一部分,satellite-installer 命令会在与 Satellite 相同的服务器上安装 PostgreSQL 数据库。在某些 Satellite 部署中,使用外部数据库而不是默认的本地数据库可帮助进行服务器负载。

红帽不提供对外部数据库维护的支持或工具。这包括备份、升级和数据库调优。您必须具有自己的数据库管理员才能支持和维护外部数据库。

要为 Satellite 创建和使用外部数据库,您必须完成以下步骤:

  1. 第 3.12.2 节 “为外部数据库准备主机”.准备一个 Red Hat Enterprise Linux 8 或 Red Hat Enterprise Linux 7 服务器来托管外部数据库。
  2. 第 3.12.3 节 “安装 PostgreSQL”.使用 Satellite 的数据库准备 PostgreSQL,使用拥有他们的专用用户 Candlepin 和 Pulp。
  3. 第 3.12.4 节 “配置 Satellite 服务器以使用外部数据库”.编辑 satellite-installer 的参数以指向新数据库,并运行 satellite-installer

3.12.1. PostgreSQL 作为外部数据库注意事项

Foreman、Katello 和 Candlepin 使用 PostgreSQL 数据库。如果要将 PostgreSQL 用作外部数据库,则以下信息可帮助您确定此选项是否适合您的 Satellite 配置。Satellite 支持 PostgreSQL 版本 12。

外部 PostgreSQL 的优点:

  • 在 Satellite 上增加可用内存和可用 CPU
  • 在 PostgreSQL 数据库上设置 shared_buffers 的灵活性,使其没有与 Satellite 上的其他服务干扰的风险
  • 在不影响 Satellite 操作的情况下灵活地调整 PostgreSQL 服务器系统

外部 PostgreSQL 的缺点

  • 增加部署复杂性,使故障排除变得更加困难
  • 外部 PostgreSQL 服务器是一个额外的系统来修补和维护
  • 如果 Satellite 或 PostgreSQL 数据库服务器都存在硬件或存储故障,则 Satellite 无法正常工作
  • 如果 Satellite 服务器和数据库服务器之间有延迟,则性能可能会下降

如果您怀疑 Satellite 上的 PostgreSQL 数据库导致性能问题,请在 Satellite 6 中使用信息:如何启用 postgres 查询日志记录来检测运行较慢的查询,以确定您是否有缓慢的查询。超过一秒的查询通常是由于大型安装出现性能问题导致的,而迁移到外部数据库可能并不有所帮助。如果您的查询缓慢,请联系红帽支持团队。

3.12.2. 为外部数据库准备主机

使用最新的 Red Hat Enterprise Linux 8 或 Red Hat Enterprise Linux 7 服务器安装一个全新的置备系统,以托管外部数据库。

Red Hat Software Collections 和 Red Hat Enterprise Linux 的订阅不提供将 Satellite 与外部数据库使用的正确服务级别协议。您还必须将 Satellite 订阅附加到要用于外部数据库的基本操作系统。

先决条件

流程

  1. 按照 附加 Satellite Infrastructure 订阅 中的说明,将 Satellite 订阅附加到您的服务器。
  2. 禁用所有软件仓库并只启用以下软件仓库:

    • Red Hat Enterprise Linux 7:

      Copy to Clipboard Toggle word wrap
      # subscription-manager repos --disable '*'
      # subscription-manager repos --enable=rhel-server-rhscl-7-rpms \
      --enable=rhel-7-server-rpms --enable=rhel-7-server-satellite-6.11-rpms
    • Red Hat Enterprise Linux 8:

      Copy to Clipboard Toggle word wrap
      # subscription-manager repos --disable '*'
      # subscription-manager repos \
      --enable=satellite-6.11-for-rhel-8-x86_64-rpms \
      --enable=rhel-8-for-x86_64-baseos-rpms \
      --enable=rhel-8-for-x86_64-appstream-rpms
  3. 在 Red Hat Enterprise Linux 8 中启用以下模块:

    Copy to Clipboard Toggle word wrap
    # dnf module enable satellite:el8
    注意

    启用模块 satellite:el8 会警告与 postgresql:10ruby:2.5 冲突,因为这些模块被设置为 Red Hat Enterprise Linux 8 上的默认模块版本。模块 satellite:el8 具有模块 postgresql:12ruby:2.7 的依赖项,它将通过 satellite:el8 模块启用。这些警告不会导致安装过程失败,因此可以安全地忽略。有关 Red Hat Enterprise Linux 8 模块和生命周期流的更多信息,请参阅 Red Hat Enterprise Linux 应用程序流生命周期

3.12.3. 安装 PostgreSQL

您只能在内部数据库安装过程中安装 satellite-installer 工具安装的相同版本的 PostgreSQL。您可以使用 Red Hat Enterprise Linux 8 或 Red Hat Enterprise Linux Server 7 软件仓库安装 PostgreSQL。Satellite 支持 PostgreSQL 版本 12。

3.12.3.1. 在 Red Hat Enterprise Linux 8 上安装 PostgreSQL

流程

  1. 要安装 PostgreSQL,请输入以下命令:

    Copy to Clipboard Toggle word wrap
    # dnf install postgresql-server postgresql-evr
  2. 要初始化 PostgreSQL,请输入以下命令:

    Copy to Clipboard Toggle word wrap
    # postgresql-setup initdb
  3. 编辑 /var/lib/pgsql/data/postgresql.conf 文件:

    Copy to Clipboard Toggle word wrap
    # vi /var/lib/pgsql/data/postgresql.conf
  4. 删除 # 并编辑以侦听入站连接:

    Copy to Clipboard Toggle word wrap
    listen_addresses = '*'
  5. 编辑 /var/lib/pgsql/data/pg_hba.conf 文件:

    Copy to Clipboard Toggle word wrap
    # vi /var/lib/pgsql/data/pg_hba.conf
  6. 在文件中添加以下行:

    Copy to Clipboard Toggle word wrap
      host  all   all   Satellite_ip/24   md5
  7. 要启动并启用 PostgreSQL 服务,请输入以下命令:

    Copy to Clipboard Toggle word wrap
    # systemctl start postgresql
    # systemctl enable postgresql
  8. 在外部 PostgreSQL 服务器上打开 postgresql 端口:

    Copy to Clipboard Toggle word wrap
    # firewall-cmd --add-service=postgresql
    # firewall-cmd --runtime-to-permanent
  9. 切换到 postgres 用户并启动 PostgreSQL 客户端:

    Copy to Clipboard Toggle word wrap
    $ su - postgres -c psql
  10. 创建三个数据库和专用角色:一个用于 Satellite,一个用于 Candlepin,另一个用于 Pulp:

    Copy to Clipboard Toggle word wrap
    CREATE USER "foreman" WITH PASSWORD 'Foreman_Password';
    CREATE USER "candlepin" WITH PASSWORD 'Candlepin_Password';
    CREATE USER "pulp" WITH PASSWORD 'Pulpcore_Password';
    CREATE DATABASE foreman OWNER foreman;
    CREATE DATABASE candlepin OWNER candlepin;
    CREATE DATABASE pulpcore OWNER pulp;
  11. 退出 postgres 用户:

    Copy to Clipboard Toggle word wrap
    # \q
  12. 从 Satellite 服务器中,测试您可以访问数据库。如果连接成功,命令会返回 1

    Copy to Clipboard Toggle word wrap
    # PGPASSWORD='Foreman_Password' psql -h postgres.example.com  -p 5432 -U foreman -d foreman -c "SELECT 1 as ping"
    # PGPASSWORD='Candlepin_Password' psql -h postgres.example.com -p 5432 -U candlepin -d candlepin -c "SELECT 1 as ping"
    # PGPASSWORD='Pulpcore_Password' psql -h postgres.example.com -p 5432 -U pulp -d pulpcore -c "SELECT 1 as ping"

3.12.3.2. 在 Red Hat Enterprise Linux 7 上安装 PostgreSQL

流程

  1. 要安装 PostgreSQL,请输入以下命令:

    Copy to Clipboard Toggle word wrap
    # yum install rh-postgresql12-postgresql-server \
    rh-postgresql12-syspaths \
    rh-postgresql12-postgresql-evr
  2. 要初始化 PostgreSQL,请输入以下命令:

    Copy to Clipboard Toggle word wrap
    # postgresql-setup initdb
  3. 编辑 /var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf 文件:

    Copy to Clipboard Toggle word wrap
    # vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf
  4. 删除 # 并编辑以侦听入站连接:

    Copy to Clipboard Toggle word wrap
    listen_addresses = '*'
  5. 编辑 /var/opt/rh/rh-postgresql12/lib/pgsql/data/pg_hba.conf 文件:

    Copy to Clipboard Toggle word wrap
    # vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/pg_hba.conf
  6. 在文件中添加以下行:

    Copy to Clipboard Toggle word wrap
      host  all   all   Satellite_ip/24   md5
  7. 要启动并启用 PostgreSQL 服务,请输入以下命令:

    Copy to Clipboard Toggle word wrap
    # systemctl start postgresql
    # systemctl enable postgresql
  8. 在外部 PostgreSQL 服务器上打开 postgresql 端口:

    Copy to Clipboard Toggle word wrap
    # firewall-cmd --add-service=postgresql
    # firewall-cmd --runtime-to-permanent
  9. 切换到 postgres 用户并启动 PostgreSQL 客户端:

    Copy to Clipboard Toggle word wrap
    $ su - postgres -c psql
  10. 创建三个数据库和专用角色:一个用于 Satellite,一个用于 Candlepin,另一个用于 Pulp:

    Copy to Clipboard Toggle word wrap
    CREATE USER "foreman" WITH PASSWORD 'Foreman_Password';
    CREATE USER "candlepin" WITH PASSWORD 'Candlepin_Password';
    CREATE USER "pulp" WITH PASSWORD 'Pulpcore_Password';
    CREATE DATABASE foreman OWNER foreman;
    CREATE DATABASE candlepin OWNER candlepin;
    CREATE DATABASE pulpcore OWNER pulp;
  11. 退出 postgres 用户:

    Copy to Clipboard Toggle word wrap
    # \q
  12. 从 Satellite 服务器中,测试您可以访问数据库。如果连接成功,命令会返回 1

    Copy to Clipboard Toggle word wrap
    # PGPASSWORD='Foreman_Password' psql -h postgres.example.com  -p 5432 -U foreman -d foreman -c "SELECT 1 as ping"
    # PGPASSWORD='Candlepin_Password' psql -h postgres.example.com -p 5432 -U candlepin -d candlepin -c "SELECT 1 as ping"
    # PGPASSWORD='Pulpcore_Password' psql -h postgres.example.com -p 5432 -U pulp -d pulpcore -c "SELECT 1 as ping"

3.12.4. 配置 Satellite 服务器以使用外部数据库

使用 satellite-installer 命令,将 Satellite 配置为连接到外部 PostgreSQL 数据库。

前提条件

  • 您已在 Red Hat Enterprise Linux 服务器中安装并配置 PostgreSQL 数据库。

流程

  1. 要为 Satellite 配置外部数据库,请输入以下命令:

    Copy to Clipboard Toggle word wrap
    satellite-installer --scenario satellite \
      --foreman-db-host postgres.example.com \
      --foreman-db-password Foreman_Password \
      --foreman-db-database foreman \
      --foreman-db-manage false \
      --katello-candlepin-db-host postgres.example.com \
      --katello-candlepin-db-name candlepin \
      --katello-candlepin-db-password Candlepin_Password \
      --katello-candlepin-manage-db false \
      --foreman-proxy-content-pulpcore-manage-postgresql false \
      --foreman-proxy-content-pulpcore-postgresql-host postgres.example.com \
      --foreman-proxy-content-pulpcore-postgresql-db-name pulpcore \
      --foreman-proxy-content-pulpcore-postgresql-password Pulpcore_Password
      --foreman-proxy-content-pulpcore-postgresql-user pulp

    要为这些外部数据库启用安全套接字层(SSL)协议,请添加以下选项:

    Copy to Clipboard Toggle word wrap
    --foreman-db-sslmode verify-full
    --foreman-db-root-cert <path_to_CA>
    --katello-candlepin-db-ssl true
    --katello-candlepin-db-ssl-verify true
    --katello-candlepin-db-ssl-ca <path_to_CA>
    --foreman-proxy-content-pulpcore-postgresql-ssl true
    --foreman-proxy-content-pulpcore-postgresql-ssl-root-ca <path_to_CA>
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat, Inc.