Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Install Postgresql 11 in Amazon Linux AMI?

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.

like image 839
nitsujri Avatar asked Jul 31 '19 12:07

nitsujri


4 Answers

sudo yum update
sudo amazon-linux-extras install postgresql11
like image 76
Khaled AbuShqear Avatar answered Oct 17 '22 21:10

Khaled AbuShqear


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/

like image 42
nitsujri Avatar answered Oct 17 '22 20:10

nitsujri


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.

like image 5
citymonkeymao Avatar answered Oct 17 '22 21:10

citymonkeymao


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
like image 4
Andrew Saushkin Avatar answered Oct 17 '22 21:10

Andrew Saushkin