5.6.3. 为自动化中心 PostgreSQL 数据库启用 hstore 扩展
数据库迁移脚本使用 hstore 字段来存储信息,因此在自动化中心 PostgreSQL 数据库中必须启用 hstore 扩展。
使用 Ansible Automation Platform 安装程序和受管 PostgreSQL 服务器时,此过程是自动的。
如果 PostgreSQL 数据库是外部的,则必须在安装前在自动化中心 PostgreSQL 数据库中手动启用 hstore 扩展。
如果在安装过程中没有启用 hstore 扩展,在数据库迁移过程中会出现一个失败。
流程
检查 PostgreSQL 服务器上是否有扩展(自动化 hub 数据库)。
$ psql -d <automation hub database> -c "SELECT * FROM pg_available_extensions WHERE name='hstore'"其中 <
automation hub database>的默认值为automationhub。带有
hstore可用的输出示例 :name | default_version | installed_version |comment ------+-----------------+-------------------+--------------------------------------------------- hstore | 1.7 | | data type for storing sets of (key, value) pairs (1 row)带有
hstore不可用的输出示例 :name | default_version | installed_version | comment ------+-----------------+-------------------+--------- (0 rows)在基于 RHEL 的服务器上,h
store扩展包含在postgresql-contribRPM 软件包中,该软件包不会在安装 PostgreSQL 服务器 RPM 软件包时自动安装。要安装 RPM 软件包,请使用以下命令:
dnf install postgresql-contrib使用以下命令将
hstorePostgreSQL 扩展加载到自动化中心数据库中:$ psql -d <automation hub database> -c "CREATE EXTENSION hstore;"在以下输出中,
installed_version字段列出了使用的hstore扩展,表示启用了hstore。name | default_version | installed_version | comment -----+-----------------+-------------------+------------------------------------------------------ hstore | 1.7 | 1.7 | data type for storing sets of (key, value) pairs (1 row)