PostgreSQL, or Postgres, is a relational database management system that provides an implementation of the SQL querying language. It is a popular choice for many small and large projects and has the advantage of being standards-compliant and having many advanced features like reliable transactions and concurrency without read locks.
During the COVID-19 Quarantine days, I started integrating the application consistency backup of PostgreSQL.
We will see how I implemented the Application consistency in my next blog, here we will see how to setup the PostgreSQL in Ubuntu in AWS EC2.
Launch the Instance
Launch a new instance in AWS EC2 and open the SSH port in the security group inbound rule.
Run the update
ubuntu@ip-172-31-84-77:~$ sudo apt update
Install the Package
Install the PostgreSQL package along with a postgresql-contrib package that adds some additional utilities and functionality
ubuntu@ip-172-31-84-77:~$ sudo apt install postgresql postgresql-contrib
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpq5 libsensors4 postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common ssl-cert sysstat
Suggested packages:
lm-sensors postgresql-doc locales-all postgresql-doc-10 libjson-perl openssl-blacklist isag
The following NEW packages will be installed:
libpq5 libsensors4 postgresql postgresql-10 postgresql-client-10 postgresql-client-common postgresql-common postgresql-contrib ssl-cert sysstat
0 upgraded, 10 newly installed, 0 to remove and 72 not upgraded.
Need to get 5344 kB of archives.
After this operation, 21.1 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Validate the Service
ubuntu@ip-172-31-84-77:~$ sudo service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2020-04-06 14:28:06 UTC; 1min 55s ago
Main PID: 2783 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 1152)
CGroup: /system.slice/postgresql.service
Apr 06 14:28:06 ip-172-31-84-77 systemd[1]: Starting PostgreSQL RDBMS...
Apr 06 14:28:06 ip-172-31-84-77 systemd[1]: Started PostgreSQL RDBMS.
Connect to the Server using the below command
ubuntu@ip-172-31-84-77:~$ sudo -u postgres psql
psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))
Type "help" for help.
postgres=#
At any time you can terminate from the session by running the \q command
Also published on Medium.