PostgreSQL 12 in Amazon Linux AMI 2

0

Hi for all.

PostgreSQL 12 is now available in RDS but in Amazon Linux AMI 2 client is still at 11.2.
This causes a version mismatch issue for us in pg_dump.
Anybody has any suggestion or know if is there any forecast to make PostgreSQL 12 available in Amazon Linux AMI 2?

Regards.

https://aws.amazon.com/about-aws/whats-new/2020/03/amazon-rds-now-supports-postgresql-12/?nc1=h_ls

asked 4 years ago3901 views
6 Answers
0

I would be really interested in the answer to this

answered 4 years ago
0

Hi Fernando,

Next are the step to install PostgreSQL 12.X on your environment:

1.- Create an EBS snapshot of your system (highly recommended)
2.- Create a new repo for "PostgreSQL 12 for RHEL/CentOS 7 - x86_64" with the following command:

$ sudo tee /etc/yum.repos.d/pgdg.repo<<EOF
[pgdg12]
name=PostgreSQL 12 for RHEL/CentOS 7 - x86_64
baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64
enabled=1
gpgcheck=0
EOF

3.- Generate the metadata cache (this can take a while)
$ sudo yum makecache

4.- Install PostgreSQL 12.x
$ sudo yum install postgresql12.x86_64 postgresql12-libs.x86_64 postgresql12-server.x86_64

5.- Initialize the database for PostgreSQL 12.x
$ sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
Initializing database ... OK

6.- Start the PostgreSQL 12 engine
$ sudo systemctl start postgresql-12.service
$ sudo systemctl status postgresql-12.service
● postgresql-12.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-12-01 15:53:22 UTC; 1s ago
Docs: https://www.postgresql.org/docs/12/static/
Process: 4519 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 4525 (postmaster)
CGroup: /system.slice/postgresql-12.service
├─4525 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/
├─4527 postgres: logger
├─4529 postgres: checkpointer
├─4530 postgres: background writer
├─4531 postgres: walwriter
├─4532 postgres: autovacuum launcher
├─4533 postgres: stats collector
└─4534 postgres: logical replication launcher

Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Starting PostgreSQL 12 database server...
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.393 UTC [4525] LOG: starting PostgreS...-bit
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.394 UTC [4525] LOG: listening on IPv4...5432
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.395 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.397 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] LOG: redirecting log o...cess
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] HINT: Future log outpu...og".
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Started PostgreSQL 12 database server.
Hint: Some lines were ellipsized, use -l to show in full.

Have a good day!

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:56 AM

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:57 AM

answered 3 years ago
0

RamonResendiz-AWS wrote:
Hi Fernando,

Next are the step to install PostgreSQL 12.X on your environment:

1.- Create an EBS snapshot of your system (highly recommended)
2.- Create a new repo for "PostgreSQL 12 for RHEL/CentOS 7 - x86_64" with the following command:

$ sudo tee /etc/yum.repos.d/pgdg.repo<<EOF
[pgdg12]
name=PostgreSQL 12 for RHEL/CentOS 7 - x86_64
baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64
enabled=1
gpgcheck=0
EOF

3.- Generate the metadata cache (this can take a while)
$ sudo yum makecache

4.- Install PostgreSQL 12.x
$ sudo yum install postgresql12.x86_64 postgresql12-libs.x86_64 postgresql12-server.x86_64

5.- Initialize the database for PostgreSQL 12.x
$ sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
Initializing database ... OK

6.- Start the PostgreSQL 12 engine
$ sudo systemctl start postgresql-12.service
$ sudo systemctl status postgresql-12.service
● postgresql-12.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-12-01 15:53:22 UTC; 1s ago
Docs: https://www.postgresql.org/docs/12/static/
Process: 4519 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 4525 (postmaster)
CGroup: /system.slice/postgresql-12.service
├─4525 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/
├─4527 postgres: logger
├─4529 postgres: checkpointer
├─4530 postgres: background writer
├─4531 postgres: walwriter
├─4532 postgres: autovacuum launcher
├─4533 postgres: stats collector
└─4534 postgres: logical replication launcher

Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Starting PostgreSQL 12 database server...
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.393 UTC [4525] LOG: starting PostgreS...-bit
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.394 UTC [4525] LOG: listening on IPv4...5432
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.395 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.397 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] LOG: redirecting log o...cess
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] HINT: Future log outpu...og".
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Started PostgreSQL 12 database server.
Hint: Some lines were ellipsized, use -l to show in full.

Have a good day!

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:56 AM

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:57 AM
RamonResendiz-AWS wrote:
Hi Fernando,

Next are the step to install PostgreSQL 12.X on your environment:

1.- Create an EBS snapshot of your system (highly recommended)
2.- Create a new repo for "PostgreSQL 12 for RHEL/CentOS 7 - x86_64" with the following command:

$ sudo tee /etc/yum.repos.d/pgdg.repo<<EOF
[pgdg12]
name=PostgreSQL 12 for RHEL/CentOS 7 - x86_64
baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64
enabled=1
gpgcheck=0
EOF

3.- Generate the metadata cache (this can take a while)
$ sudo yum makecache

4.- Install PostgreSQL 12.x
$ sudo yum install postgresql12.x86_64 postgresql12-libs.x86_64 postgresql12-server.x86_64

5.- Initialize the database for PostgreSQL 12.x
$ sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
Initializing database ... OK

6.- Start the PostgreSQL 12 engine
$ sudo systemctl start postgresql-12.service
$ sudo systemctl status postgresql-12.service
● postgresql-12.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-12-01 15:53:22 UTC; 1s ago
Docs: https://www.postgresql.org/docs/12/static/
Process: 4519 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 4525 (postmaster)
CGroup: /system.slice/postgresql-12.service
├─4525 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/
├─4527 postgres: logger
├─4529 postgres: checkpointer
├─4530 postgres: background writer
├─4531 postgres: walwriter
├─4532 postgres: autovacuum launcher
├─4533 postgres: stats collector
└─4534 postgres: logical replication launcher

Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Starting PostgreSQL 12 database server...
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.393 UTC [4525] LOG: starting PostgreS...-bit
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.394 UTC [4525] LOG: listening on IPv4...5432
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.395 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.397 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] LOG: redirecting log o...cess
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] HINT: Future log outpu...og".
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Started PostgreSQL 12 database server.
Hint: Some lines were ellipsized, use -l to show in full.

Have a good day!

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:56 AM

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:57 AM
RamonResendiz-AWS wrote:
Hi Fernando,

Next are the step to install PostgreSQL 12.X on your environment:

1.- Create an EBS snapshot of your system (highly recommended)
2.- Create a new repo for "PostgreSQL 12 for RHEL/CentOS 7 - x86_64" with the following command:

$ sudo tee /etc/yum.repos.d/pgdg.repo<<EOF
[pgdg12]
name=PostgreSQL 12 for RHEL/CentOS 7 - x86_64
baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64
enabled=1
gpgcheck=0
EOF

3.- Generate the metadata cache (this can take a while)
$ sudo yum makecache

4.- Install PostgreSQL 12.x
$ sudo yum install postgresql12.x86_64 postgresql12-libs.x86_64 postgresql12-server.x86_64

5.- Initialize the database for PostgreSQL 12.x
$ sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
Initializing database ... OK

6.- Start the PostgreSQL 12 engine
$ sudo systemctl start postgresql-12.service
$ sudo systemctl status postgresql-12.service
● postgresql-12.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-12-01 15:53:22 UTC; 1s ago
Docs: https://www.postgresql.org/docs/12/static/
Process: 4519 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 4525 (postmaster)
CGroup: /system.slice/postgresql-12.service
├─4525 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/
├─4527 postgres: logger
├─4529 postgres: checkpointer
├─4530 postgres: background writer
├─4531 postgres: walwriter
├─4532 postgres: autovacuum launcher
├─4533 postgres: stats collector
└─4534 postgres: logical replication launcher

Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Starting PostgreSQL 12 database server...
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.393 UTC [4525] LOG: starting PostgreS...-bit
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.394 UTC [4525] LOG: listening on IPv4...5432
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.395 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.397 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] LOG: redirecting log o...cess
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] HINT: Future log outpu...og".
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Started PostgreSQL 12 database server.
Hint: Some lines were ellipsized, use -l to show in full.

Have a good day!

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:56 AM

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:57 AM
RamonResendiz-AWS wrote:
Hi Fernando,

Next are the step to install PostgreSQL 12.X on your environment:

1.- Create an EBS snapshot of your system (highly recommended)
2.- Create a new repo for "PostgreSQL 12 for RHEL/CentOS 7 - x86_64" with the following command:

$ sudo tee /etc/yum.repos.d/pgdg.repo<<EOF
[pgdg12]
name=PostgreSQL 12 for RHEL/CentOS 7 - x86_64
baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64
enabled=1
gpgcheck=0
EOF

3.- Generate the metadata cache (this can take a while)
$ sudo yum makecache

4.- Install PostgreSQL 12.x
$ sudo yum install postgresql12.x86_64 postgresql12-libs.x86_64 postgresql12-server.x86_64

5.- Initialize the database for PostgreSQL 12.x
$ sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
Initializing database ... OK

6.- Start the PostgreSQL 12 engine
$ sudo systemctl start postgresql-12.service
$ sudo systemctl status postgresql-12.service
● postgresql-12.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2020-12-01 15:53:22 UTC; 1s ago
Docs: https://www.postgresql.org/docs/12/static/
Process: 4519 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 4525 (postmaster)
CGroup: /system.slice/postgresql-12.service
├─4525 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/
├─4527 postgres: logger
├─4529 postgres: checkpointer
├─4530 postgres: background writer
├─4531 postgres: walwriter
├─4532 postgres: autovacuum launcher
├─4533 postgres: stats collector
└─4534 postgres: logical replication launcher

Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Starting PostgreSQL 12 database server...
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.393 UTC [4525] LOG: starting PostgreS...-bit
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.394 UTC [4525] LOG: listening on IPv4...5432
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.395 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.397 UTC [4525] LOG: listening on Unix...432"
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] LOG: redirecting log o...cess
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal postmaster[4525]: 2020-12-01 15:53:22.407 UTC [4525] HINT: Future log outpu...og".
Dec 01 15:53:22 ip-10-0-1-48.ec2.internal systemd[1]: Started PostgreSQL 12 database server.
Hint: Some lines were ellipsized, use -l to show in full.

Have a good day!

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:56 AM

Edited by: RamonResendiz-AWS on Dec 1, 2020 7:57 AM
Actually @RamonResendiz-AWS

You have a typo in Step 2 -- you have the AWS Forum URL.

It should be not be:
[pdg12] that is the URL for the forums

It should be (had to escape the brackets to break URL):
sudo tee /etc/yum.repos.d/pgdg.repo<<EOF
\[pgdg12]
name=PostgreSQL 12 for RHEL/CentOS 7 - x86_64
baseurl=https://download.postgresql.org/pub/repos/yum/12/redhat/rhel-7-x86_64
enabled=1
gpgcheck=0
EOF

Otherwise all was good - thank you!  
  
John  
  
Edited by: jwalsh2me on Jan 16, 2021 9:56 AM
answered 3 years ago
0

Hello,
I have followed these instructions exactly, but I get the following result when I try to initialize the database:

-bash-4.2# sudo /usr/pgsql-12/bin/postgresql-12-setup initdb
Failed to get D-Bus connection: No such file or directory
failed to find PGDATA setting in postgresql-12.service

I am running Amazon Linux 2 under Windows Subsystem for Linux on a Windows 10 laptop.
I am not using docker.

Regards,

Iver

answered 3 years ago
0

Coming up on a year since this was asked for... rds now supports postgres 13, ec2 still only has postgres 11

bryanam
answered 3 years ago
0

Dupe post sorry

bryanam
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions