4.13. 将外部数据库与 Satellite 搭配使用
作为红帽卫星的安装过程的一部分,satellite-installer 命令会在与 Satellite 相同的服务器上安装 PostgreSQL 数据库。在某些卫星部署中,使用外部数据库而不是默认的本地数据库可帮助服务器负载。
红帽不提供支持或工具进行外部数据库维护。这包括备份、升级和数据库调整。您必须具有自己的数据库管理员才能支持和维护外部数据库。
要在 Satellite 中创建和使用外部数据库,您必须完成以下步骤:
- 第 4.13.2 节 “为外部数据库准备主机”.准备红帽企业 Linux 7 服务器以托管外部数据库。
- 第 4.13.3 节 “安装 PostgreSQL”.使用卫星、Candlepin 和 Pulp 为 PostgreSQL 准备 PostgreSQL,以及拥有它们的专用用户。
-
第 4.13.4 节 “将 Satellite 配置为使用外部数据库”.编辑
satellite-installer参数以指向新数据库,并运行satellite-installer。
4.13.1. PostgreSQL 作为外部数据库注意事项 复制链接链接已复制到粘贴板!
Foreman、Katello 和 Candlepin 使用 PostgreSQL 数据库。如果要将 PostgreSQL 用作外部数据库,则以下信息可帮助您确定此选项是否适合您的卫星配置:Satellite 支持 PostgreSQL 版本 12.1。
外部 PostgreSQL 的优点:
- 增加 Satellite 上的可用内存和可用 CPU
-
将 PostgreSQL 数据库上的
shared_buffers设置为高灵活性,不会造成与 Satellite 上的其他服务干扰的风险 - 在不影响 Satellite 操作的情况下,调整 PostgreSQL 服务器系统的灵活性
外部 PostgreSQL 的缺点
- 增加部署复杂性,这会增加故障排除的难度
- 外部 PostgreSQL 服务器是另一个要修补和维护的系统
- 如果 Satellite 或 PostgreSQL 数据库服务器出现硬件或存储故障,则 Satellite 无法正常工作
- 如果卫星服务器和数据库服务器之间存在延迟,性能可能会受到影响
如果您怀疑 Satellite 中的 PostgreSQL 数据库造成性能问题,请使用 Satellite 6 中的信息:如何启用 postgres 查询日志记录来检测运行较慢的查询,以确定您是否有缓慢的查询。超过一秒的查询通常是由大型安装的性能问题导致的,并移到外部数据库可能并不能提供帮助。如果您的查询缓慢,请联系红帽支持。
4.13.2. 为外部数据库准备主机 复制链接链接已复制到粘贴板!
使用最新的 Red Hat Enterprise Linux 7 服务器安装一个新的置备系统,以托管外部数据库。
Red Hat Software Collections 和 Red Hat Enterprise Linux 的订阅不提供将 Satellite 与外部数据库搭配使用的正确服务级别协议。您还必须将 Satellite 订阅附加到要用于外部数据库的基础操作系统。
前提条件
- 红帽企业 Linux 7 服务器必须满足卫星 的存储要求。
流程
- 使用 Attaching Satellite Infrastructure Subscription 中的说明将 Satellite 订阅附加到您的服务器。
禁用所有软件仓库并只启用以下软件仓库:
# subscription-manager repos --disable '*' # subscription-manager repos --enable=rhel-server-rhscl-7-rpms \ --enable=rhel-7-server-rpms --enable=rhel-7-server-satellite-6.10-rpms
4.13.3. 安装 PostgreSQL 复制链接链接已复制到粘贴板!
在内部数据库安装过程中,您只能安装使用 satellite-installer 工具安装的 PostgreSQL 版本。只要支持版本,您可以使用 Red Hat Enterprise Linux Server 7 软件仓库或从外部来源安装 PostgreSQL。Satellite 支持 PostgreSQL 版本 12.1。
流程
要安装 PostgreSQL,请输入以下命令:
# yum install rh-postgresql12-postgresql-server \ rh-postgresql12-syspaths \ rh-postgresql12-postgresql-evr要初始化 PostgreSQL,请输入以下命令:
# postgresql-setup initdb编辑
/var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf文件:# vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/postgresql.conf删除
#和 edit 以侦听入站连接:listen_addresses = '*'Edit the
/var/opt/rh/rh-postgresql12/lib/pgsql/data/pg_hba.conffile:# vi /var/opt/rh/rh-postgresql12/lib/pgsql/data/pg_hba.conf在文件中添加以下行:
host all all Satellite_ip/24 md5要启动并启用 PostgreSQL 服务,请输入以下命令:
# systemctl start postgresql # systemctl enable 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.13.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 --foreman-proxy-content-pulpcore-postgresql-ssl true --foreman-proxy-content-pulpcore-postgresql-ssl-root-ca <path_to_CA>