13

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?

Community
  • 1
  • 1
scandel
  • 1,692
  • 3
  • 20
  • 39

4 Answers4

17

Aman,

It may help you: https://stackoverflow.com/a/55883490/7541412

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!

Community
  • 1
  • 1
Hassan Murtaza
  • 963
  • 6
  • 15
16

I successfully installed 11.5 on Amazon Linux using

sudo amazon-linux-extras install postgresql11
Andrew Lynch
  • 1,297
  • 3
  • 14
  • 25
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.

aydow
  • 3,673
  • 2
  • 23
  • 40
-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?

Aman B
  • 2,276
  • 1
  • 18
  • 26
  • 1
    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. – scandel Sep 17 '19 at 09:07
  • @scandel I see. Try the instructions from this [blog](https://installvirtual.com/how-to-install-postgresql-11-on-amazon-ec2-amazon-linux/), see how it goes. – Aman B Sep 17 '19 at 09:23
  • 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). – scandel Sep 17 '19 at 10:40