1

With the official repositories, the RHEL6 packages get installed which happen to work on Amazon Linux 2 (RHEL7 clone). You might run into a dependency hell if you want to install the plperl extension later on, as it requires Perl 5.10 which is only available for RHEL6:

    ---> Package postgresql96-plperl.x86_64 0:9.6.11-1PGDG.rhel6 will be installed
--> Processing Dependency: perl(:MODULE_COMPAT_5.10.1) for package: postgresql96-plperl-9.6.11-1PGDG.rhel6.x86_64
--> Finished Dependency Resolution
Error: Package: postgresql96-plperl-9.6.11-1PGDG.rhel6.x86_64 (pgdg96)
           Requires: perl(:MODULE_COMPAT_5.10.1)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
mrg2k8
  • 91
  • 3
  • 6

2 Answers2

3

I would not recommend using PGDG with AL2. Not to mention, that it now refuses to install on AL2 because it can't find /etc/redhat-release. You can still setup a repo file for yum, but again, I don't recommend it.

AL2 comes with a amazon-linux-extras tool. https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras

PostgreSQL 9.6 and 10 are included, as is PL/Perl.

You may have to do a bit more work to get the server setup, but you shouldn't have dependency issues since these packages are provided by the Amazon Linux team.

1

A slightly modified version of the Amazon Linux YUM repository can be used to install the correct (el7) version of postgresql-server and thus, plperl:

[pgdg96]
name=PostgreSQL 9.6 - Amazon Linux 2 - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96

[pgdg96-source]
name=PostgreSQL 9.6 - Amazon Linux 2 - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/9.6/redhat/rhel-7-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96

[pgdg96-updates-testing]
name=PostgreSQL 9.6 - Amazon Linux 2 - $basearch
baseurl=https://download.postgresql.org/pub/repos/yum/testing/9.6/redhat/rhel-7-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96

[pgdg96-source-updates-testing]
name=PostgreSQL 9.6 - Amazon Linux 2 - $basearch - Source
failovermethod=priority
baseurl=https://download.postgresql.org/pub/repos/yum/srpms/testing/9.6/redhat/rhel-7-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-96

Installed packages:

$ rpm -qa | grep postgresql96
postgresql96-contrib-9.6.12-1PGDG.rhel7.x86_64
postgresql96-plperl-9.6.12-1PGDG.rhel7.x86_64
postgresql96-9.6.12-1PGDG.rhel7.x86_64
postgresql96-server-9.6.12-1PGDG.rhel7.x86_64
postgresql96-libs-9.6.12-1PGDG.rhel7.x86_64

L.E. Now, Postgres 9.6 is available in the amazon-linux-extras packages:

# amazon-linux-extras | grep postgres
  5  postgresql9.6            available    [ =9.6.6  =9.6.8 ]
  6  postgresql10             available    [ =10 ]

To enable the repository, you can do a amazon-linux-extras enable postgresql9.6.

mrg2k8
  • 91
  • 3
  • 6
  • Note well that _none_ of these packages are guaranteed to work with Amazon Linux. Even if they happen to work now, they may break in the future. If you need to be sure that it works, you should use a different distribution, e.g. the actual RHEL 7 for which they are packaged. – Michael Hampton Feb 27 '19 at 16:48
  • Thanks for the heads-up. I had to configure an environment for testing only. – mrg2k8 Feb 27 '19 at 23:24