How to Install PostgreSQL on Linux
Installation of PostgreSQL on Linux
In this article, you will learn how to install PostgreSQL on Linux using rpm packages. Most Linux platforms such as Debian, Oracle Linux, Red Hat / CentOS, SUSE, and Ubuntu have PostgreSQL integrated with their package management.
It is recommended that you install PostgreSQL this way since it ensures a proper integration with the operating system including automatic patching and other update management functionality.
In this tutorial, we’ll show you how to install PostgreSQL on Oracle Linux version 8.2
Installation using RPMS:
Below URL can be used to download rpms of PostgreSQL version 15.1 for Linux platforms.
https://download.postgresql.org/pub/repos/yum/15/redhat/rhel-8.2-x86_64/
For smooth installation, below listed rpms are required:
- postgresql15-devel-15.1-1PGDG.rhel8.x86_64.rpm
- postgresql15-contrib-15.1-1PGDG.rhel8.x86_64.rpm
- postgresql15-libs-15.1-1PGDG.rhel8.x86_64.rpm
- postgresql15-server-15.1-1PGDG.rhel8.x86_64.rpm
- postgresql15-15.1-1PGDG.rhel8.x86_64.rpm
- Install libs rpm first as below::
yum localinstall /tmp/postgresql15-15.1-1PGDG.rhel8.x86_64.rpm
yum localinstall /tmp/postgresql15-devel-15.1-1PGDG.rhel8.x86_64.rpm
yum localinstall /tmp/postgresql15-contrib-15.1-1PGDG.rhel8.x86_64.rpm
/usr/pgsql-15/bin/postgresql-15.1-setup initdb
7. Next, start the PostgreSQL service and enable it to start at system reboot with the following command:
systemctl start postgresql-15.1
systemctl enable postgresql-15.1
8. You can check the status of PostgreSQL with the following command:
systemctl start postgresql-15.1
9. By default, PostgreSQL listens on port 5432. You can check it with the following command:
netstat -tulnp |grep 5432
Once installation is complete, you can access it using pgAdmin tool and any other GUI based tool like dbeaver.
For connecting it remotely, some configurations are required. Like changes in postgresql.conf file and pg_hba.conf files which by default can be found in "/var/lib/pgsql/15/data" directory.
Edit postgresql.conf file and comment listen_address directive and add new line as below:
listen_address='IP_ADDR_PG_SERVER"
Edit pg_hba.conf and add below lines:
host all postgres CLIENT_IP_ADDR trust
For making these changes effective, restart postgresql service as below:
systemctl restart postgresql-15.1
Now you can connect to your postgresql database using pgAdmin tool from your client machine
Comments
Post a Comment