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

0
50344
views

Let’s divide this into two parts, first will install PSQL client on EC2 instance and then will try connecting RDS

Install PSQL client on EC2 instance

1. We need to first add the pgdg repository in Amazon Linux

amazon-linux-extras install postgresql10 vim epel

2. Now, install postgresql 10

yum install -y postgresql-server postgresql-devel

/usr/bin/postgresql-setup –-initdb

4. Start the postgres service

systemctl enable postgresql

systemctl start postgresql

5. To check if the postgres service is running or not

systemctl status postgresql

Now we are all good to connect to our database cluster using psql client tool

Fire the below command to connect to the rds cluster

psql -h cluster-endpoint -p 5432 -U username -d dbname

Cluster-endpoint – is the database endpoint that is used to connect database

username – a name which you gave at the time of cluster creation

dbname – Database name that you want to connect within the cluster

Example :-

psql -h testdatabase-gp-instance-1.cgwbzekfvqhi.us-east 1.rds.amazonaws.com -p 5432 -U greenpg -d postgres