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


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

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

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

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

3.10.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.10.2. 为外部数据库准备主机

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

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

先决条件

流程

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

    # subscription-manager repos --disable '*'
    # subscription-manager repos \
    --enable=satellite-6.15-for-rhel-8-x86_64-rpms \
    --enable=satellite-maintenance-6.15-for-rhel-8-x86_64-rpms \
    --enable=rhel-8-for-x86_64-baseos-rpms \
    --enable=rhel-8-for-x86_64-appstream-rpms
  3. 启用以下模块:

    # 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 Application Streams 生命周期

3.10.3. 安装 PostgreSQL

您只能在内部数据库安装过程中安装 satellite-installer 工具安装的相同版本的 PostgreSQL。Satellite 支持 PostgreSQL 版本 12。

流程

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

    # dnf install postgresql-server postgresql-evr postgresql-contrib
  2. 要初始化 PostgreSQL,请输入以下命令:

    # postgresql-setup initdb
  3. 编辑 /var/lib/pgsql/data/postgresql.conf 文件:

    # vi /var/lib/pgsql/data/postgresql.conf

    请注意,需要调整外部 PostgreSQL 的默认配置才能使用 Satellite。基础推荐的外部数据库配置调整如下:

    • checkpoint_completion_target: 0.9
    • max_connections: 500
    • shared_buffers: 512MB
    • work_mem: 4MB
  4. 删除 # 并编辑以侦听入站连接:

    listen_addresses = '*'
  5. 编辑 /var/lib/pgsql/data/pg_hba.conf 文件:

    # vi /var/lib/pgsql/data/pg_hba.conf
  6. 在文件中添加以下行:

      host  all   all   Satellite_ip/32   md5
  7. 要启动并启用 PostgreSQL 服务,请输入以下命令:

    # systemctl enable --now postgresql
  8. 在外部 PostgreSQL 服务器上打开 postgresql 端口:

    # firewall-cmd --add-service=postgresql
  9. 使更改持久:

    # firewall-cmd --runtime-to-permanent
  10. 切换到 postgres 用户并启动 PostgreSQL 客户端:

    $ su - postgres -c psql
  11. 创建三个数据库和专用角色:一个用于 Satellite,一个用于 Candlepin,另一个用于 Pulp:

    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;
  12. 连接到 Pulp 数据库:

    postgres=# \c pulpcore
    You are now connected to database "pulpcore" as user "postgres".
  13. 创建 hstore 扩展:

    pulpcore=# CREATE EXTENSION IF NOT EXISTS "hstore";
    CREATE EXTENSION
  14. 退出 postgres 用户:

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

    # 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.10.4. 将 Satellite 服务器配置为使用外部数据库

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

前提条件

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

流程

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

    # satellite-installer \
    --foreman-db-database foreman \
    --foreman-db-host postgres.example.com \
    --foreman-db-manage false \
    --foreman-db-password Foreman_Password \
    --foreman-proxy-content-pulpcore-manage-postgresql false \
    --foreman-proxy-content-pulpcore-postgresql-db-name pulpcore \
    --foreman-proxy-content-pulpcore-postgresql-host postgres.example.com \
    --foreman-proxy-content-pulpcore-postgresql-password Pulpcore_Password \
    --foreman-proxy-content-pulpcore-postgresql-user pulp \
    --katello-candlepin-db-host postgres.example.com \
    --katello-candlepin-db-name candlepin \
    --katello-candlepin-db-password Candlepin_Password \
    --katello-candlepin-manage-db false

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

    --foreman-db-root-cert <path_to_CA>
    --foreman-db-sslmode verify-full
    --foreman-proxy-content-pulpcore-postgresql-ssl true
    --foreman-proxy-content-pulpcore-postgresql-ssl-root-ca <path_to_CA>
    --katello-candlepin-db-ssl true
    --katello-candlepin-db-ssl-ca <path_to_CA>
    --katello-candlepin-db-ssl-verify true
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.