Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Amazon EC2 instance based on Amazon Linux AMI 2014.03. I installed PostresSQL from their repos:

yum install postgresql-libs postgresql postgresql-server postgresql-devel

I've read about Amazon's unexpected upgrade from 9.1 to 9.2, so I added this line to the end of /etc/yum.conf so hopefully I can control any upgrades:


So far so good. Now I'm setting up continuous archiving and I want to run pg_archivecleanup. However I can't find the postgresql-contrib package on the Amazon distro, and it's not listed in the packages:

Is there someplace else to get that pre-compiled? I tried the following to compile it myself:

sudo su - cd /usr/local/src wget tar -xzf postgresql-9.2.7.tar.gz cd /usr/local/src/postgresql-9.2.7 ./configure --without-readline # fails until you add --without-readline cd /usr/local/src/postgresql-9.2.7/contrib/pg_archivecleanup gmake gmake install

but the gmake fails:

gcc -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard pg_archivecleanup.o -L../../src/port -Wl,--as-needed -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags -lpgport -lz -lcrypt -ldl -lm -o pg_archivecleanup /usr/bin/ld: cannot find -lpgport collect2: error: ld returned 1 exit status gmake: *** [pg_archivecleanup] Error 1

Trying to figure out the -lpgport issue led me to some very obscure bug reports here and here. Tracking bugs in Linux itself seems a little extreme just to compile one file.

What is my best option?

  1. Find another source for the contrib package - where?
  2. Find a way to compile this module - how?
  3. Ditch Amazon Linux and start from scratch with an Ubuntu AMI.
  4. Forget pg_archivecleanup and write a script to delete old WAL files.


I'm using Elastic Beanstalk with some pretty tight integration to the Amazon AMI. I'm sure it could be made to work with another AMI, but I expect there would be other gotchas. What about this option, adapted from this post:

# Change to home directory to download the software
cd ~/
# Get the right postgresql package (Redhat 64 Bit)
# Install the package
sudo rpm -ivh pgdg-redhat92-9.2-7.noarch.rpm
sudo yum install postgresql92-contrib

Does that give me the best of both worlds, an Amazon AMI with an official Postgres repo? If necessary, I could completely re-install Postgres from that RHEL repo.

share|improve this question
pg_archivecleanup requires other bits of PostgreSQL, specifically libpgport. You'd have to compile the top-level source directory first ("make"), before attempting to compile pg_archivecleanup. Personally I'd take option #5 - use a better distro, and then use or packages. – Craig Ringer Jun 20 '14 at 1:45
Thanks for the info on libpgport. I've updated the question after some more research on using a different repo. – Mark Berry Jun 20 '14 at 22:19
up vote 0 down vote accepted

With the help of this AWS forum thread, I realized that this line in /etc/yum.conf


excludes not only updates but installs. Once I commented that out (temporarily), I was able to use

sudo yum install postgresql-contrib

to install postgresql-contrib directly from the Amazon repo--no need for changing the repository or the operating system.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.