Postgresql – How to install PostgreSQL 9.6 and plperl on Amazon Linux 2

amazon-linux-2postgresql

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

Best Answer

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.