当 razor 用户可以登录数据库时,razor-admin 迁移数据库因 IDENT 错误而失败

razor-admin migrate-database failing on IDENT Error when razor user can log in to the database

https://gist.github.com/predatorian3/fbf6d34b0a9958212c3c

我最近尝试使用此处提供的文档设置 Razor Server:

  1. https://github.com/puppetlabs/razor-server/wiki/Installation
  2. https://docs.puppetlabs.com/pe/latest/razor_prereqs.html
  3. https://docs.puppetlabs.com/pe/latest/razor_install.html

我开始在 Vagrant 上全新安装 CentOS 6,并安装了 PostgreSQL 服务器和客户端。然后我从文档中安装了 puppet-labs RPM。我使用以下方法创建了用户:

su - postgres
createuser -P razor
createdb -O razor razor_prd

然后我编辑了 /etc/razor/config.yml 文件以在 database_url 中反映 razor 用户的 razor 密码用于生产。然后,当我以 root、postgres 和 razor 身份执行数据库迁移时,问题开头的 Gist 中列出了不同的错误。

[vagrant@centos6 ~]$ sudo su - razor -c "razor-admin --environment production migrate-database"
Sequel::DatabaseConnectionError: Java::OrgPostgresqlUtil::PSQLException: FATAL: Ident authentication failed for user "razor"
                              make_new at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/connection_pool.rb:99
                              make_new at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/connection_pool/threaded.rb:158
                             available at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/connection_pool/threaded.rb:137
                               acquire at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/connection_pool/threaded.rb:127
                                  sync at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/connection_pool/threaded.rb:194
                           synchronize at org/jruby/ext/thread/Mutex.java:149
                                  sync at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/connection_pool/threaded.rb:194
                               acquire at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/connection_pool/threaded.rb:126
                                  hold at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/connection_pool/threaded.rb:94
                           synchronize at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/database/connecting.rb:234
                        server_version at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/adapters/shared/postgres.rb:442
  supports_create_table_if_not_exists? at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/adapters/shared/postgres.rb:458
                         create_table? at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/database/schema_methods.rb:211
                        schema_dataset at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/extensions/migration.rb:585
                            initialize at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/extensions/migration.rb:443
                            initialize at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/extensions/migration.rb:505
                                   run at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/extensions/migration.rb:390
                                 apply at /opt/razor/vendor/bundle/jruby/1.9/gems/sequel-4.9.0/lib/sequel/extensions/migration.rb:361
                                (root) at /opt/razor/bin/razor-admin:41
                                  call at org/jruby/RubyProc.java:271
                                (root) at /opt/razor/bin/razor-admin:84

但是我可以以 razor 用户身份登录数据库并四处查看,并且我已将 razor 用户的密码重置为 postgres,并且仍然可以以 razor 用户身份登录。但是,我将 运行 保留为上面列出的错误。我究竟做错了什么?

--编辑 2015-08-18-- 我在 pg_hba.conf

中的其他条目上方添加了这些行
# TYPE  DATABASE        USER            ADDRESS                METHOD
local   all             all                                    trust
host    all             all             127.0.0.1/32           trust

现在,我收到 SQL 错误提示:

E, [2015-08-19T16:26:10.028000 #2203] ERROR -- razor.sequel: Java::OrgPostgresqlUtil::PSQLException: ERROR: syntax error at or near "DEFERRABLE"
  Position: 95: ALTER TABLE "policies" DROP CONSTRAINT "policies_rule_number_key", ADD UNIQUE ("rule_number") DEFERRABLE INITIALLY DEFERRED
I, [2015-08-19T16:26:10.046000 #2203]  INFO -- razor.sequel: (0.003000s) ROLLBACK
Sequel::DatabaseError: Java::OrgPostgresqlUtil::PSQLException: ERROR: syntax error at or near "DEFERRABLE"
  Position: 95

我认为这与 Razor 中的 SQL 有关。

我要做的就是将数据库更新到最新版本。 CentOS 默认存储库中的 PostgreSQL 版本为 8.4,已弃用。然后我还必须再次将本地和主机设置列入白名单以获得信任。然后重启 PostgreSQL,迁移成功。