Steps to Install and use PostgreSQL Version 10.2 on RHEL 7.5

Often simply Postgres, is an 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 Postgresql Prerequisites On a Linux or Mac system, you must have superuser privileges to perform a PostgreSQL installation. To perform an installation on a Windows system, you must have administrator privileges.

Steps to install Postgresql in RHEL-7.5

Download and install PostgreSQL.

```
$ sudo yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-redhat10-10-2.noarch.rpm 
$ sudo  yum-config-manager --disable pgdg95
```

Check the postgresql packages

```
$ sudo yum update 
$ sudo yum list postgresql*
```

Installation command

```
$ sudo yum install postgresql10 postgresql10-server
$ sudo /usr/pgsql-10/bin/postgresql-10-setup initdb
$ sudo systemctl enable postgresql-10
```

Postgresql service stop/start/restart command

To changing default port 5432 to 9001 and connection + buffer size we need to edit the postgresql.conf file from below path PostgreSQL is running on default port 5432. you decide to change the default port, please ensure that your new port number does not conflict with any services running on that port.

Steps to change the default port

Open the file and modify the below changes

Use below command to open the port 9001 from RHEL 7.5 VM

To increase the buffer size and number of postgreSql connection same fine modify the below changes also

Start the service

To change the default password

Login to postgrsql

Restart the service:

It will ask new password to login to postgresql

Example for sourcing the sql file form command line $ psql --username=postgres --host=<server ip> --port=9001 --dbname=postgres

Open the file

** Default lines are present in pg_hab.conf file**

TYPE
DATABASE
USER
ADDRESS
METHOD

local

all

all

peer

host

all

all

127.0.0.1/32

ident

host

all

all

::1/128

ident

local

replication

all

peer

host

replication

all

127.0.0.1/32

ident

host

replication

all

::1/128

ident

** Modify with below changes in file /var/lib/pgsql/10/data/pg_hba.conf**

TYPE
DATABASE
USER
ADDRESS
METHOD

local

all

all

md5

host

all

all

127.0.0.1/32

ident

host

all

all

0.0.0.0/0

md5

host

all

all

::1/128

ident

local

replication

all

peer

host

replication

all

127.0.0.1/32

ident

host

replication

all

::1/128

ident

Reference link: https://www.tecmint.com/install-postgresql-on-centos-rhel-fedora

Last updated

Was this helpful?