postgresql 部署Postgres 11到Elastic Beanstalk -需要/etc/redhat-release

f5emj3cl  于 4个月前  发布在  PostgreSQL
关注(0)|答案(6)|浏览(63)

我有一个地狱的时间部署我的第一个应用程序到Elastic Beanstalk,真的需要一些帮助。我不能让Postgres 11安装,虽然它是官方支持与RDS。

问题

如果我运行eb deploy,我会得到一条消息,说pg_config可执行文件找不到。从源代码构建psycopg2需要它。

/usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
  warnings.warn(msg)
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

Error: pg_config executable not found.

pg_config is required to build psycopg2 from source.  Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option: ...

字符串
我想我需要添加repo?很好。接下来我尝试添加repo,就像我在互联网上的其他帖子中发现的那样:

[ec2-user@ip-... etc]$ sudo yum -y install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_64/pgdg-centos11-11-2.noarch.rpm
Loaded plugins: priorities, update-motd, upgrade-helper
pgdg-centos11-11-2.noarch.rpm                                          | 5.6 kB  00:00:00     
Examining /var/tmp/yum-root-cQJP_4/pgdg-centos11-11-2.noarch.rpm: pgdg-redhat-repo-42.0-4.noarch
Marking /var/tmp/yum-root-cQJP_4/pgdg-centos11-11-2.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-4 will be installed
--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-4.noarch
--> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-4.noarch
--> Finished Dependency Resolution
Error: Package: pgdg-redhat-repo-42.0-4.noarch (/pgdg-centos11-11-2.noarch)
           Requires: /etc/redhat-release

**从这里我 * 卡住 *.**我已经尝试过符号链接/etc/system-release -> /etc/redhat-release没有运气.似乎没有其他人有这个问题?我似乎也没有梦寐以求的amazon-linux-extras出于某种原因?

环境

**环境层:**Web服务器
**平台:**64位Amazon Linux/2.8.2上运行的Python 3.6

  • .ebextensions/packages.config*
packages:
  yum:
    postgresql11-devel: []

requirements.txt

Django==2.2
psycopg2==2.8.2
pytz==2019.1
sqlparse==0.3.0
[ec2-user@ip-... etc]$ cat /etc/os-release 
NAME="Amazon Linux AMI"
VERSION="2018.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2018.03"
PRETTY_NAME="Amazon Linux AMI 2018.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2018.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"

[ec2-user@ip-... etc]$ cat /etc/system-release 
Amazon Linux AMI release 2018.03

的字符串

eqqqjvef

eqqqjvef1#

或者,您可以从源代码构建posgresql:
第一个月
tar zxvf postgresql-11.5.tar.gz
cd postgresql-11.5
./configure --without-readline
make
make install

70gysomp

70gysomp2#

PostgreSQL 11还没有从Amazon上发布,但PostgreSQL 10已经发布了。我使用的是cat /etc/system-release报告的Amazon Linux release 2(Karoo)。要启用安装:

$ sudo amazon-linux-extras enable postgresql10

字符串
一旦你启用了这个额外的功能,你就会看到很多PostgreSQL 10的包可以通过yum正常安装:

$ yum list postgresql*
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Installed Packages
postgresql.x86_64                    10.4-5.amzn2.0.2    @amzn2extra-postgresql10
postgresql-devel.x86_64              10.4-5.amzn2.0.2    @amzn2extra-postgresql10
postgresql-libs.x86_64               10.4-5.amzn2.0.2    @amzn2extra-postgresql10
Available Packages
postgresql-contrib.x86_64            10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-docs.x86_64               10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-libs.i686                 10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-plperl.x86_64             10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-plpython.x86_64           10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-plpython3.x86_64          10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-pltcl.x86_64              10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-server.x86_64             10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-static.x86_64             10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-test.x86_64               10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-test-rpm-macros.x86_64    10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-upgrade.x86_64            10.4-5.amzn2.0.2    amzn2extra-postgresql10
postgresql-upgrade-devel.x86_64      10.4-5.amzn2.0.2    amzn2extra-postgresql10

6qftjkof

6qftjkof3#

我在AWS Elastic Beanstalk上的一个Django 2.1项目中遇到了同样的问题。
这个问题是上周在2019年4月17日左右引入的,以确保操作系统是实际的红帽版本(亚马逊Linux不是)。我在PostgreSQL邮件列表中找到了一些细节:
“Amazon Linux支持实际上在几年前就被删除了。我只是确保我们的repo文件反映了这一点。”

邮件列表中的一个帖子建议了以下修复方法:
“我们通过使用rpm并显式忽略存储库依赖关系暂时缓解了这个问题,但这似乎是解决真实的问题的权宜之计,即依赖关系不应该存在。”
就我个人而言,我已经做了和你一样的事情,Scott,我只是恢复到AWS直接提供的PostgreSQL 9.6客户端软件包。只要Django和psycopg支持该版本,这就可以正常工作。
然而,长期的解决方案是AWS最终提供带有Amazon Linux 2的平台。

b91juud3

b91juud34#

以下是我针对最新的Amazon Linux 2 ami的特立独行的解决方案:

sudo su
cd /etc/yum.repos.d
nano pgdg.repo

字符串
然后,我将其粘贴到nano编辑器中,其中包含新创建的pgdg.repo文件:

[pgdg11]
name=PostgreSQL 11 $releasever - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7.5-x86_64
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-11


其他命令包括:

sed -i "s/rhel-\$releasever-\$basearch/rhel-7.5-x86_64/g" "/etc/yum.repos.d/pgdg.repo"
yum groupinstall "PostgreSQL Database Server 11 PGDG"


创建一个新的PostgreSQL数据库集群:

/usr/pgsql-11/bin/postgresql-11-setup initdb


现在执行以下命令来启动并启用postgresql服务:

systemctl enable postgresql-11
systemctl start postgresql-11


不过,请记住这个地址的注解:链接到Postgresql.org

n3h0vuf2

n3h0vuf25#

我没有做的事情:

  1. Postgre10及以上版本在Amazon Linux 2上不可用。
  2. Amazon-linux-extras(public.ecr.aws/lambda/python:3.11) python3.11 lambda image for Amazon Linux上不可用2.所以你不能使用这个库在python3.11python3更好)lambda image for Amazon Linux 2中安装Postgres

我的做法:(在public.ecr.aws/lambda/python:3.11中安装postgres11),但底层Linux是Amazon Linux 2,因此适用于所有使用AL 2-EC2, Elastic Beanstalk等的示例。
Dockerfile:

FROM public.ecr.aws/lambda/python:3.11.2023.08.02.09-x86_64
# install dependencies
RUN yum -y groupinstall "Development Tools"
RUN yum -y update
RUN echo -e "\
[pgdg11] \n\
name            = PostgreSQL 11 $releasever - $basearch \n\
baseurl         = https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7.5-x86_64 \n\
enabled         = 1 \n\
gpgcheck        = 0 \n\
" > /etc/yum.repos.d/pgdg.repo

RUN sed "s/rhel-\$releasever-\$basearch/rhel-7.5-x86_64/g" "/etc/yum.repos.d/pgdg.repo"
RUN yum groupinstall "PostgreSQL Database Server 11 PGDG" -y
RUN yum install postgresql11 postgresql11-server -y
COPY systemctl.py /usr/bin/systemctl
RUN chmod a+x /usr/bin/systemctl
RUN systemctl enable postgresql11
RUN systemctl start postgresql11
RUN export PATH=/usr/pgsql-11/bin/psql:$PATH

字符串
现在,您需要在与Dockerfile相同的目录中创建名为systemctl.py的文件,并从here复制其中的内容

参考:this article

fdbelqdn

fdbelqdn6#

使用Docker:

  • sudo yum install docker*
  • sudo systemctl start docker*
  • sudo docker run --name some-postgres -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=your_password -e POSTGRES_DB=virtual_office -p 5432:5432 -d postgres*

完成后,转到服务器:5432

相关问题