How to install PostgreSQL 10 on Amazon EC2 (Amazon Linux)

Install PostgreSQL 10 on Amazon EC2

In this tutorial, we will show you How to install PostgreSQL 10 on Amazon EC2. You will see how to Install PostgreSQL 10 on Amazon Linux is very easy and quick to install and use.

Amazon Linux 2 is the next generation of Amazon Linux, a Linux server operating system from Amazon Web Services (AWS). It provides a secure, stable, and high-performance execution environment to develop and run cloud and enterprise applications. With Amazon Linux 2, you get an application environment that offers long term support with access to the latest innovations in the Linux ecosystem. Amazon Linux 2 is provided at no additional charge.

install PostgreSQL 10 on amazon ec2

 

PostgreSQL, often simply Postgres, is an open source object-relational database management system (ORDBMS) with an emphasis on extensibility and standards compliance. It can handle workloads ranging from small single-machine applications to large Internet-facing applications (or for data warehousing) with many concurrent users. It is the default database on macOS Server and is available for Microsoft Windows and Linux (supplied in most distributions).

Read Also: How to install PostgreSQL 11 on Mac OS X via brew

Step 1. Add PGDG Repo

Firstly we need to add the pgdg repository in Amazon Linux

yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

yum update

Now we need to change the release server to redhat so we can use this repository.

sed -i "s/rhel-\$releasever-\$basearch/rhel-7.5-x86_64/g" "/etc/yum.repos.d/pgdg-10-centos.repo"

Step 2. Install PostgreSQL 10 Client

To install PostgreSQL us the following command. It will install complete postgreSQL Database group.

yum install postgresql10

Step 3. Install PostgreSQL 10

yum install postgresql10-server

Create a new Postgres database cluster

/usr/pgsql-10/bin/postgresql-10-setup initdb
Initializing database ... OK

Step 4. Restart the services of Postgres

Now execute the following command to start and enable the postgres services.

systemctl enable postgresql-10
systemctl start postgresql-10

How to install postgresql 9.6 on Mac

Step 5. Login into Database

PostgreSQL installation is done. If you want to use the Database log in Postgres account by typing following command

su - postgres

You can get into Postgres console by typing

psql

Now use the Postgres as you want to use. To get the help use the \h command.

Read Also: Useful s3 commands

If you have any problem using this tutorial feel free to comment.

3 Comments Posted

  1. Hi,

    This gives me an error. Please help. Thanks.

    [ec2-user@ip-172-31-16-173 ~]$ sudo yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/p
    gdg-centos10-10-2.noarch.rpm
    Loaded plugins: priorities, update-motd, upgrade-helper
    pgdg-centos10-10-2.noarch.rpm | 5.6 kB 00:00:00
    Examining /var/tmp/yum-root-3pEhlc/pgdg-centos10-10-2.noarch.rpm: pgdg-redhat-repo-42.0-4.noarch
    Marking /var/tmp/yum-root-3pEhlc/pgdg-centos10-10-2.noarch.rpm to be installed
    Resolving Dependencies
    amzn-main/2018.03 | 2.1 kB 00:00:00
    amzn-updates/2018.03 | 2.5 kB 00:00:00
    –> Running transaction check
    —> Package pgdg-redhat-repo.noarch 0:42.0-4 will be installed
    –> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-4.noarch
    –> Processing Dependency: /etc/redhat-release for package: pgdg-redhat-repo-42.0-4.noarch
    –> Finished Dependency Resolution
    Error: Package: pgdg-redhat-repo-42.0-4.noarch (/pgdg-centos10-10-2.noarch)
    Requires: /etc/redhat-release
    You could try using –skip-broken to work around the problem
    You could try running: rpm -Va –nofiles –nodigest

Leave a Reply

Your email address will not be published.


*