13

How do I install Postgresql 11 on Amazon Linux 2018.03 (specifically, not AMZ Linux 2) on Elastic Beanstalk?

I want to install a package and not manually build a binary. If an autoscale machine boots and has to build the entire PG binary, it'll take significantly longer on a t2/t3.micro.

I'm looking for pg_dump.

[Edit] Making more verbose, explain why building does not work for my situation.

4 Answers 4

33

The key was the PGDG is no longer available to Amazon Linux's yum since 9.3 so the individual pieces must be installed.

  # Remove old Postgres
  yum remove -y postgresql postgresql-server

  # Install Postgres 11
  yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-libs-11.4-1PGDG.rhel6.x86_64.rpm
  yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-11.4-1PGDG.rhel6.x86_64.rpm
  yum install -y https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/postgresql11-server-11.4-1PGDG.rhel6.x86_64.rpm

[edit] Replace the 11.4 in each link above with any version you need available at https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-6-x86_64/

2
  • 6
    For Postgresql 12 tools you can run this: sudo yum install -y https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-6-x86_64/postgresql12-12.2-2PGDG.rhel6.x86_64.rpm https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-6-x86_64/postgresql12-libs-12.2-2PGDG.rhel6.x86_64.rpm
    – johnthuss
    Commented May 5, 2020 at 21:20
  • this doesnt work.. I just get the error "Cannot open xyz.rpm"
    – SatheeshJM
    Commented Feb 13, 2023 at 10:10
17
sudo yum update
sudo amazon-linux-extras install postgresql11
1
  • 1
    This only works for AMZ Linux 2 which has the amazon-linux-extras. It is the default OS for ElasticBeanstalk today though, so very valid.
    – nitsujri
    Commented May 19, 2021 at 2:03
5

Looks like there's no PostgreSQL 11 pre-built binary distribution for Amazon Linux. The way I solve it was to build from source code:

wget https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz

tar zxvf postgresql-11.5.tar.gz

cd postgresql-11.5

./configure --without-readline

make

make install

By default, it will install pg_dump into /usr/local/pgsql/bin/pg_dump.

1
  • I wanted to avoid building it if it was at all possible since it's a small machine (t3.nano) and that can take time.
    – nitsujri
    Commented Sep 14, 2019 at 1:04
4

This is an extended version of @nitsujri answer. I can't comment their comment, so I will create new answer here.

Install prerequisites:

sudo yum install readline-devel
sudo yum group install "Development Tools"

Download PostgreSQL source code and install the distro:

wget https://ftp.postgresql.org/pub/source/v11.5/postgresql-11.5.tar.gz
tar zxvf postgresql-11.5.tar.gz
cd postgresql-11.5
./configure
make
sudo make install

Add this line to your ~/.bashrc. After that relogin to an EC2 instance.

export PATH=/usr/local/pgsql/bin:$PATH
1
  • How can i start the service of postgresql? Commented Feb 2, 2021 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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