How to install PostgeSQL 11 on AWS Amazon Linux AMI 2?
Asked Answered
G

4

14

I want to install PostgreSQL 11 on an EC2 instance, based on the Amazon Linux AMI 2 image. Following posts, SO questions, and finding the latest Postgresl yum repository, I tried:

sudo yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

I get this error:

--> 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

I'm stuck.. is there a clean way to overcome this problem?

Gritty answered 17/9, 2019 at 8:54 Comment(0)
C
17

Aman,

It may help you: https://mcmap.net/q/659843/-deploy-postgres11-to-elastic-beanstalk-requires-etc-redhat-release

Moreover, if you think PostgreSQL v10 can resolve your issues. You can try these commands:

sudo yum update -y

sudo amazon-linux-extras enable postgresql10

After having PostgreSQL in your repository, now you can install:

yum clean metadata

yum install postgresql

Thanks!

Colonic answered 17/9, 2019 at 11:57 Comment(4)
Thanks, but I need PostgreSQL 11 because it must be the same version for the client and the server (wich is 11). I will give a try to the post you're pointing at.Gritty
Thanks, the SO answer you pointed me to worked for me (almost).Gritty
Glad it helped you.Colonic
For those looking for Postgres 12 qiita.com/tmiki/items/00d22edc6a554f61bd04Antiphony
C
16

I successfully installed 11.5 on Amazon Linux using

sudo amazon-linux-extras install postgresql11
Confuse answered 1/4, 2020 at 12:26 Comment(3)
How about 12.2? Is it available?Washstand
At least until now there is only 9.6 10 and 11Toffey
This command always installs psql (PostgreSQL) 9.2.24Homemaking
F
0

I had issues with the Amazon Linux 2 AMI for CodeBuild using Python 3 but amazon-linux-extras only using Python 2 (totally bizarre considering Python 2 has been sunset, I know). From this thread you can copy the amazon_linux_extras from the Python 2 site-packages to the Python 3 one.

To find the location of amazon-linux-extras use

find -type d -name "amazon_linux_extras"     # note the underscore (_), not dash (-)

To find the Python 3 site-packages directory

find -type d -name "site-packages"

To copy across

cp -r /path/to/amazon_linux_extras /path/to/python3/site-packages

Once I had done that, I used @Hassan's answer to upgrade to PostgreSQL 11.

Fawkes answered 8/2, 2021 at 3:58 Comment(0)
G
-3

You can install PostgreSQL by running the following command:

$ sudo yum install postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs

Out of curiosity why are you not using PostgreSQL on AWS RDS?

Globoid answered 17/9, 2019 at 9:3 Comment(3)
Thanks for your answer, but the above command doesn't work as postgresql is not in the repos supported by Amazon Linux AMI 2. This is why I need to add the repo first. I am already using AWS RDS for the server side, but I want to install the client on an EC2 instance, mainly to manage dumps.Gritty
@Gritty I see. Try the instructions from this blog, see how it goes.Globoid
It's already what I did... just changed the repo with a more recent one (but also tried with the one in the blog post, with the same error).Gritty

© 2022 - 2024 — McMap. All rights reserved.