3.14. 将外部数据库与 Satellite 搭配使用
作为 Red Hat Satellite 安装过程的一部分,satellite-installer 命令会将 PostgreSQL 数据库安装到与 Satellite 相同的服务器上。在某些 Satellite 部署中,使用外部数据库而不是默认本地数据库可帮助服务器加载。
红帽不提供对外部数据库维护的支持或工具。这包括备份、升级和数据库调整。您必须具有自己的数据库管理员才能支持和维护外部数据库。
要为 Satellite 创建并使用外部数据库,您必须完成以下步骤:
- 第 3.14.2 节 “为外部数据库准备主机”.准备 Red Hat Enterprise Linux 8 服务器以托管外部数据库。
- 第 3.14.3 节 “安装 PostgreSQL”.使用具有所属卫星、Candlepin 和 Pulp 的数据库准备 PostgreSQL。
-
第 3.14.4 节 “配置卫星服务器以使用外部数据库”.编辑
satellite-installer
的参数以指向新数据库,并运行satellite-installer
。
3.14.1. PostgreSQL 作为外部数据库注意事项
Foreman、Karnish 和 Candlepin 使用 PostgreSQL 数据库。如果要使用 PostgreSQL 作为外部数据库,则以下信息可帮助您确定此选项是否适合您的 Satellite 配置。Satellite 支持 PostgreSQL 版本 12。
外部 PostgreSQL 的优点
- 增加 Satellite 中的可用内存和可用 CPU
-
在 PostgreSQL 数据库上将
shared_buffers
的灵活性设置为高数值,而不影响 Satellite 上的其他服务的风险 - 在不影响 Satellite 操作的情况下对 PostgreSQL 服务器系统进行灵活调整
外部 PostgreSQL 的缺陷
- 增加部署复杂性,使故障排除更困难
- 外部 PostgreSQL 服务器是补丁和维护的额外系统
- 如果 Satellite 或 PostgreSQL 数据库服务器遇到硬件或存储故障,卫星无法正常运行
- 如果 Satellite 服务器和数据库服务器之间存在延迟,性能可能会会受到影响
如果您怀疑 Satellite 上的 PostgreSQL 数据库导致性能问题,请使用 Satellite 6 中的信息:如何启用 postgres 查询日志来检测运行速度慢的问题,以确定您是否 有慢的问题查询。需要一秒钟的查询通常是由于大型安装出现性能问题,而移动到外部数据库的查询通常不是帮助。如果您有慢的查询,请联络红帽支持。
3.14.2. 为外部数据库准备主机
使用最新 Red Hat Enterprise Linux 8 安装一个最新置备的系统,以托管外部数据库。
Red Hat Enterprise Linux 的订阅不提供将 Satellite 与外部数据库一起使用的正确服务级别。您还必须将 Satellite 订阅附加到要用于外部数据库的基础操作系统中。
前提条件
- 准备好的主机必须满足卫星 的存储要求。
流程
- 使用 Attaching Satellite Infrastructure Subscription 中的说明将 Satellite 订阅附加到您的服务器。
禁用所有软件仓库并只启用以下软件仓库:
# subscription-manager repos --disable '*' # subscription-manager repos \ --enable=satellite-6.12-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 生命周期。
3.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"
3.14.4. 配置卫星服务器以使用外部数据库
使用 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>