4.14. 将外部数据库与 Satellite 搭配使用
作为 Red Hat Satellite 安装过程的一部分,satellite-installer 命令会在与 Satellite 相同的服务器上安装 PostgreSQL 数据库。在某些卫星部署中,使用外部数据库而不是默认的本地数据库可以帮助服务器加载。
红帽不提供对外部数据库维护的支持或工具。这包括备份、升级和数据库调整。您必须具有自己的数据库管理员才能支持和维护外部数据库。
要为 Satellite 创建和使用外部数据库,您必须完成以下步骤:
- 第 4.14.2 节 “为外部数据库准备主机”.准备 Red Hat Enterprise Linux 8 服务器来托管外部数据库。
- 第 4.14.3 节 “安装 PostgreSQL”.使用拥有它们的专用用户准备 PostgreSQL、Candlepin 和 Pulp。
-
第 4.14.4 节 “将 Satellite 服务器配置为使用外部数据库”.编辑
satellite-installer的参数以指向新数据库,并运行satellite-installer。
4.14.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 查询日志来检测运行缓慢的查询,以确定您是否具有缓慢的查询。花费超过一秒的查询通常是由大型安装的性能问题导致的,而移至外部数据库可能并不可以帮助。如果您有缓慢的查询,请联系红帽支持团队。
4.14.2. 为外部数据库准备主机
使用最新的 Red Hat Enterprise Linux 8 安装最新置备的系统来托管外部数据库。
Red Hat Enterprise Linux 的订阅不提供将 Satellite 与外部数据库搭配使用的正确服务级别协议。您还必须将 Satellite 订阅附加到要用于外部数据库的基本操作系统。
前提条件
- 准备的主机必须满足卫星 的存储要求。
流程
- 使用 附加 Satellite 基础架构订阅 中的说明,将 Satellite 订阅附加到您的服务器。
禁用所有软件仓库并只启用以下软件仓库:
# subscription-manager repos --disable '*' # subscription-manager repos \ --enable=satellite-6.13-for-rhel-8-x86_64-rpms \ --enable=satellite-maintenance-6.13-for-rhel-8-x86_64-rpms \ --enable=rhel-8-for-x86_64-baseos-rpms \ --enable=rhel-8-for-x86_64-appstream-rpms
启用以下模块:
# dnf module enable satellite:el8
注意启用模块
satellite:el8会警告与postgresql:10和ruby:2.5冲突,因为这些模块在 Red Hat Enterprise Linux 8 中被设置为默认模块版本。模块satellite:el8依赖于模块postgresql:12和ruby:2.7,它将通过satellite:el8模块启用。这些警告不会导致安装过程失败,因此可以安全地忽略。有关 Red Hat Enterprise Linux 8 中的模块和生命周期流的更多信息,请参阅 Red Hat Enterprise Linux Application Streams 生命周期。
4.14.3. 安装 PostgreSQL
您只能安装在内部数据库安装过程中使用 satellite-installer 工具安装的相同版本的 PostgreSQL。Satellite 支持 PostgreSQL 版本 12。
流程
要安装 PostgreSQL,请输入以下命令:
# dnf install postgresql-server postgresql-evr
要初始化 PostgreSQL,请输入以下命令:
# postgresql-setup initdb
编辑
/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
删除
#并编辑 以侦听入站连接:listen_addresses = '*'
编辑
/var/lib/pgsql/data/pg_hba.conf文件:# vi /var/lib/pgsql/data/pg_hba.conf
在文件中添加以下行:
host all all Satellite_ip/32 md5要启动并启用 PostgreSQL 服务,请输入以下命令:
# systemctl enable --now postgresql
打开外部 PostgreSQL 服务器上的 postgresql 端口:
# firewall-cmd --add-service=postgresql # firewall-cmd --runtime-to-permanent
切换到
postgres用户并启动 PostgreSQL 客户端:$ su - postgres -c psql
创建三个数据库和专用角色:一个用于 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;
退出
postgres用户:# \q
从卫星服务器,测试您可以访问数据库。如果连接成功,命令会返回
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"
4.14.4. 将 Satellite 服务器配置为使用外部数据库
使用 satellite-installer 命令将 Satellite 配置为连接到外部 PostgreSQL 数据库。
前提条件
- 您已在 Red Hat Enterprise Linux 服务器上安装和配置了 PostgreSQL 数据库。
流程
要为 Satellite 配置外部数据库,请输入以下命令:
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)协议,请添加以下选项:
--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>