【问题标题】:PostgreSQL on Elastic Beanstalk (Amazon Linux 2)Elastic Beanstalk 上的 PostgreSQL (Amazon Linux 2)
【发布时间】:2020-07-23 16:54:02
【问题描述】:

对于上一代的 Amazon Linux,我只需在 .ebextensions 中添加以下内容即可使用 PostgreSQL:

packages:
    yum:
        postgresql93-devel: []

现在,当我使用以下平台在 EB 上进行部署时: 在 64 位 Amazon Linux 2/3.0.0 上运行的 Python 3.7

我在部署时收到以下错误:

[ERROR] Error occurred during build: Yum does not have postgresql93-devel available for installation

因此无法部署,因为我需要连接到 RDS 中的 PostgreSQL 数据库。

我需要在 .ebextensions 中进行哪些配置?

【问题讨论】:

标签: linux postgresql amazon-web-services amazon-elastic-beanstalk yum


【解决方案1】:

以下作品:

packages:
    yum:
        amazon-linux-extras: []

commands:
    01_postgres_activate:
        command: sudo amazon-linux-extras enable postgresql10
    02_postgres_install:
        command: sudo yum install -y postgresql-devel

【讨论】:

  • 02_postgres_install 的内容放在一个配置文件中,该文件将使用包配置密钥(您为 amazon-linux-extras 执行的操作)执行,但它不起作用。必须作为命令执行。谢谢!!
  • postgresql10 中的 10 是多少?是RDS的postgres版本吗?如果我的 RDS 中的 postgres 版本是 12.5,我应该声明 postgresql12 而不是 postgresql10?
【解决方案2】:

postgresql93-devel 已经很老了。 The yum PostgreSQL repository 从 9.5 开始。根据您的需要,您可能希望至少升级到 9.5。 PostgreSQL 12 是最新的生产版本。

编辑

至于 @jordanm 的评论 - 没错,AWS Linux 2 环境确实有 PostgreSQL 9.2.24 可用。如果你对那个版本没问题,那么你可以安装postgresql-devel。将您的 .ebextensions 更改为运行:

packages:
    yum:
        postgresql-devel: []

这将为 9.2.24 安装 devel 包。

如果您想要一些更新的东西,那显然会更难。我无法让它适用于 devel 包。如果您将 .ebextensions 更改为包含类似(未经测试!):

container_commands:
    command: 'amazon-linux-extras install -y postgresql9.6'

然后您将获得 PostgreSQL 9.6,但它似乎没有可用的 devel 包。

似乎无法使用来自https://yum.postgresql.org/ 的 RPM,因为不支持 AWS Linux 2。尝试 CentOS 或 RHEL 会出错。

9.2 可用于您的环境吗?

【讨论】:

  • 我尝试过:postgresql11-devel: [] 但也失败了
  • 我也遇到了同样的问题
【解决方案3】:

对我使用 Amazon Linus 1 有帮助的一点是,在插入 RDS 服务并将 Postgres 指定为驱动程序时,我根本不需要安装 Postgres。对于遇到这个问题的人来说,这只是一个想法。但也许只是尝试不显式安装 Postgres。

我还没有验证默认安装哪个版本。

【讨论】:

    【解决方案4】:

    此配置适用于 ElasticBeanstalk 环境(在 64 位 Amazon Linux 上运行的 Python 3.6)。在此之后,我能够使用 requirements.txt 安装 psycopg2

    packages:
        yum:
            libicu-devel: []
    
    commands:
        01_postgres_libs:
            command: rpm -ivh --force https://yum.postgresql.org/10/redhat/rhel-6.9-x86_64/postgresql10-libs-10.7-1PGDG.rhel6.x86_64.rpm
        02_postgres_install:
            command: rpm -ivh --force https://yum.postgresql.org/10/redhat/rhel-6.9-x86_64/postgresql10-10.7-1PGDG.rhel6.x86_64.rpm
        03_symink_pg_config:
            command: sudo ln -sf /usr/pgsql-10/bin/pg_config /usr/bin/pg_config
        04_postgres_devel:
            command: sudo rpm -ivh --force https://yum.postgresql.org/10/redhat/rhel-6.9-x86_64/postgresql10-devel-10.7-1PGDG.rhel6.x86_64.rpm
    

    【讨论】:

      猜你喜欢
      • 2022-07-23
      • 2013-06-12
      • 1970-01-01
      • 2020-09-25
      • 2023-03-17
      • 2021-03-21
      • 2021-01-12
      • 2020-11-08
      • 2020-11-02
      相关资源
      最近更新 更多