Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
380 views
in Technique[技术] by (71.8m points)

Installing PostgreSQL Client v10 on AWS Amazon Linux (EC2) AMI

I have successfully launched new AWS RDS PostgreSQL v10 instance and need to install PostgreSQL v10 client on Amazon Linux EC2 instance.

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

Previously I managed to install PostgreSQL client v9.5 with:

[ec2-user@ip-X-X-X-X ~]$ sudo yum install -y postgresql95

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?

question from:https://stackoverflow.com/questions/49573258/installing-postgresql-client-v10-on-aws-amazon-linux-ec2-ami

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

Check Amazon Linux version

[ec2-user ~]$ cat /etc/system-release
Amazon Linux release 2.0 (2017.12) LTS Release Candidate

Install RHEL 7 yum repo for 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"

Install PostgreSQL Client v10

[ec2-user ~]$ sudo yum install -y postgresql10
[ec2-user ~]$ psql --version
psql (PostgreSQL) 10.3

Read more about Amazon Linux 2

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

those who see

Error: Package: pgdg-redhat-repo-42.0-4.noarch (/pgdg-redhat-repo-latest.noarch)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...