问题描述
我已经成功启动了新的AWS RDS PostgreSQL v10 实例,并且需要在Amazon Linux EC2实例上安装PostgreSQL v10客户端。
I have successfully launched new AWS RDS PostgreSQL v10 instance and need to install PostgreSQL v10 client on Amazon Linux EC2 instance.
我有尝试使用 yum
进行安装,但找不到v10的软件包:
I have tried to install it with yum
, but it cant find the package for v10:
[ec2-user@ip-X-X-X-X ~]$ sudo yum install -y postgresql10
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main | 2.1 kB 00:00:00
amzn-updates | 2.5 kB 00:00:00
No package postgresql110 available.
Error: Nothing to do
以前,我设法通过以下方式安装PostgreSQL客户端v9.5:
Previously I managed to install PostgreSQL client v9.5 with:
[ec2-user@ip-X-X-X-X ~]$ sudo yum install -y postgresql95
我想我需要添加Postgres yum存储库,如。但是我应该为Amazon Linux选择什么平台? Red Hat吗?
I guess I need to add Postgres yum repository, as mentioned in https://www.postgresql.org/download/linux/redhat/. But what Platform should I choose for Amazon Linux? Red Hat?
推荐答案
旨在与RedHat一起使用的Packages / Repos也可以在Amazon Linux上运行,Amazon Linux最小-RHEL安装版本。如果为以下步骤选择旧版本的Amazon Linux(Amazon linux 1),则可能会遇到兼容性问题,否则在最新版本的Amazon Linux 2中应该可以正常工作。
Packages/Repos which is designed to work of RedHat will work on Amazon Linux also, Amazon Linux is a minimal-install version of RHEL. You may run into compatibility issues if you select old version of Amazon Linux (Amazon linux 1) for the below steps, otherwise it should work fine in the latest version Amazon Linux 2.
检查Amazon Linux版本
[ec2-user ~]$ cat /etc/system-release
Amazon Linux release 2.0 (2017.12) LTS Release Candidate
安装RHEL 7 PostgreSQL的yum仓库
[ec2-user ~]$ sudo yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm
[ec2-user ~]$ sudo sed -i "s/rhel-\$releasever-\$basearch/rhel-latest-x86_64/g" "/etc/yum.repos.d/pgdg-10-redhat.repo"
安装PostgreSQL客户端v10
[ec2-user ~]$ sudo yum install -y postgresql10
[ec2-user ~]$ psql --version
psql (PostgreSQL) 10.3
详细了解
注意! Amazon Linux 2通过( amazon-linux-extras
)((仅限客户端))。由于postgresql10尚不可用,因此,今天唯一的解决方案是添加额外的yum回购。
Note! Amazon Linux 2 provides additional package installation through Amazon Linux Extras Repository (amazon-linux-extras
) ((client only)). Since postgresql10 is not yet available, adding extra yum repo is the only solution per today.
UDATE 2019May
看到
要求:/ etc / redhat-release
Requires: /etc/redhat-release
仍可以逐步安装所有依赖项,并使用以下命令安装服务器:
may still install step by step all dependencies and the server with:
yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-latest-x86_64/postgresql10-libs-10.7-2PGDG.rhel7.x86_64.rpm
yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-latest-x86_64/postgresql10-10.7-2PGDG.rhel7.x86_64.rpm
yum install -y https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-latest-x86_64/postgresql10-server-10.7-2PGDG.rhel7.x86_64.rpm
这篇关于在AWS Amazon Linux(EC2)AMI上安装PostgreSQL Client v10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!