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/

Sign up to request clarification or add additional context in comments.

2 Comments

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
this doesnt work.. I just get the error "Cannot open xyz.rpm"
18
sudo yum update
sudo amazon-linux-extras install postgresql11

1 Comment

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.
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 Comment

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.
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 Comment

How can i start the service of postgresql?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.