设计为在RedHat上运行的软件包/仓库也可以在Amazon Linux上使用,Amazon Linux是RHEL的精简安装版本。如果您选择旧版本的Amazon Linux(Amazon Linux 1),则可能会遇到兼容性问题,否则它应该可以在最新版本的Amazon Linux 2中正常工作。
检查Amazon Linux版本
[ec2-user ~]$ cat /etc/system-release
Amazon Linux release 2.0 (2017.12) LTS Release Candidate
安装 RHEL 7 yum repo 以安装 PostgreSQL
[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 2 可通过 Amazon Linux Extras Repository (amazon-linux-extras
)(仅客户端)提供其他软件包安装。由于尚未提供postgresql10,因此今天唯一的解决方案是添加额外的yum repo。
更新2019年5月:
那些看到以下错误:
错误:软件包:pgdg-redhat-repo-42.0-4.noarch
(/pgdg-redhat-repo-latest.noarch)
需要:/etc/redhat-release
可以按步骤安装所有依赖项和服务器:
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
postgresql11
和postgresql12
。 - RicHincapie