Sco*_*ott 5 django postgresql amazon-web-services amazon-elastic-beanstalk
我在将我的第一个应用程序部署到Elastic Beanstalk时遇到了麻烦,真的可以使用一些帮助。尽管RDS正式支持Postgres11,但我无法安装它。
问题
如果我运行,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: ...
Run Code Online (Sandbox Code Playgroud)
我想我需要添加回购吗?很公平。接下来,我尝试添加回购协议,就像我在互联网上的其他帖子中所发现的那样:
[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
Run Code Online (Sandbox Code Playgroud)
从这里我被困住了。我试过/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: []
Run Code Online (Sandbox Code Playgroud)
requirements.txt
Django==2.2
psycopg2==2.8.2
pytz==2019.1
sqlparse==0.3.0
Run Code Online (Sandbox Code Playgroud)
[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
Run Code Online (Sandbox Code Playgroud)
对于 AWS Elastic Beanstalk 上的 Django 2.1 项目,我在使用 PostgreSQL 10 时遇到了同样的问题。
该问题于上周于 2019 年 4 月 17 日左右引入,以确保操作系统是实际的 Red Hat 版本(Amazon Linux 不是)。我在 PostgreSQL 邮件列表中找到了一些详细信息:
“实际上,亚马逊 Linux 支持在几年前就被删除了。我只是确保我们的 repo 文件反映了这一点。”
( BUG #15768: 删除了 rpms,现在需要 /etc/redhat-release )
邮件列表上的一张海报建议进行以下修复:
“我们通过使用 rpm 并明确忽略存储库依赖项暂时缓解了这个问题,但这似乎是解决真正问题的创可贴,即依赖项不应该存在。”
就我个人而言,我和你一样,斯科特,我只是恢复到 AWS 直接提供的 PostgreSQL 9.6 客户端包。只要 Django 和 psycopg 支持该版本,就可以正常工作。
然而,AWS 的长期解决方案是最终为平台提供 Amazon Linux 2...
这是我针对最新 Amazon Linux 2 ami 的特立独行解决方案:
sudo su
cd /etc/yum.repos.d
nano pgdg.repo
Run Code Online (Sandbox Code Playgroud)
然后我将其粘贴到 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
Run Code Online (Sandbox Code Playgroud)
进一步的命令是:
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"
Run Code Online (Sandbox Code Playgroud)
创建一个新的 PostgreSQL 数据库集群:
/usr/pgsql-11/bin/postgresql-11-setup initdb
Run Code Online (Sandbox Code Playgroud)
现在执行以下命令来启动和启用 postgresql 服务:
systemctl enable postgresql-11
systemctl start postgresql-11
Run Code Online (Sandbox Code Playgroud)
不过,请记住此地址的注释: Link to Postgresql.org
Amazon 尚未提供 PostgreSQL 11,但 PostgreSQL 10 提供。我正在使用由cat /etc/system-release. 要启用安装:
$ sudo amazon-linux-extras enable postgresql10
Run Code Online (Sandbox Code Playgroud)
启用此额外功能后,您将通过 yum 看到许多可正常安装的 PostgreSQL 10 软件包:
$ 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
Run Code Online (Sandbox Code Playgroud)
小智 5
或者,您可以从源代码构建 posgresql:
wget https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz
tar zxvf postgresql-11.5.tar.gz
cd postgresql-11.5
./configure --without-readline
make
make install
| 归档时间: |
|
| 查看次数: |
2287 次 |
| 最近记录: |