【问题标题】:Postgres Command in UserData for CloudFormationCloudFormation 的 UserData 中的 Postgres 命令
【发布时间】:2016-05-04 01:13:06
【问题描述】:

我的服务器上启动了一个 postgres 服务器,用于创建云形成模板。问题是我不确定如何让它在运行时加载文件,正确的用户或命令是什么:

我试过这个:

May  2 13:50:16 ip-10-205-0-135 cloud-init: 2016-05-02 13:50:16 (31.1 MB/s) - ‘psqlCloudera.sql’ saved [876/876]
May  2 13:50:16 ip-10-205-0-135 cloud-init: psql -U postgres -a -f psqlCloudera.sql
May  2 13:50:16 ip-10-205-0-135 cloud-init: psql: FATAL:  Peer authentication failed for user "postgres"

和这样有点不同:

它在我的用户数据中涉及“su - postgres \n”。

May  2 13:31:05 ip-10-205-0-135 cloud-init: Saving to: ‘psqlCloudera.sql’
May  2 13:31:05 ip-10-205-0-135 cloud-init: 0K                                                       100% 36.2M=0s
May  2 13:31:05 ip-10-205-0-135 cloud-init: 2016-05-02 13:31:05 (36.2 MB/s) - ‘psqlCloudera.sql’ saved [876/876]
May  2 13:31:05 ip-10-205-0-135 cloud-init: psql -a -f psqlCloudera.sql
May  2 13:31:05 ip-10-205-0-135 cloud-init: psql: FATAL:  role "root" does not exist

在启动时加载 postgres 的正确方法是什么?

【问题讨论】:

    标签: postgresql amazon-cloudformation


    【解决方案1】:

    我发现只要您编辑 pg_hba.conf 并使其信任本地连接,那么第一段代码就可以工作,因此您不需要在云形成运行时通过 postgres 用户进行身份验证。第二个选项将不起作用,因为在 CF 中显然当您切换到不同的用户时,您需要将命令链接在一起,否则 CF 会注意到该用户无事可做并退出该用户。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-02
      • 2017-04-14
      • 1970-01-01
      • 2017-11-30
      • 1970-01-01
      • 2017-01-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多