Below are the steps to install PostgreSQL version 14 and 15 using dnf
NOTE: internet access is required in the server
Configuring yum repository in RHEL8/OEL8
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
This creates a pgdg-redhat-all.repo in /etc/yum.repos.d
Run the command
rpm -qi pgdg-redhat-repo
to check package details
Disable the built-in PostgreSQL module to be able to install postgreSQL 14 and 15
dnf module disable postgresql
Clean the yum cache in order to install postgreSQL 14 and 15
dnf clean all
If you want PostgreSQL14: Run the command to install PostgreSQL 14
dnf install -y postgresql14-server
If you want PostgreSQL15:Run the command to install PostgreSQL 15
dnf install -y postgresql15-server
check the version of installed PostgreSQL
psql -V
Custom PostgreSQL data path:
If needed, PGSQL path change:
Go to custom mount point (eg: /u01) and create a folder pgsqldata with postgres permissions
cd /u01
mkdir pgsqldata
chown postgres:postgres pgsqldata
Then, edit the postgresql service
systemctl edit postgresql-14.service
- Go to the custom mount point that has the majority of the disk space
- copy and paste the following into that file:
[Service]
Environment=PGDATA=/<custom mount point>/pgsqldata
- Once edited, run the following commands:
systemctl daemon-reload
/usr/pgsql-14/bin/postgresql-14-setup initdb
systemctl start postgresql-14.service
systemctl enable postgresql-14.service
- Modify the pg_hba.conf file in /<custom mount point>/pgsqldata/ to define what authentication method should be used from all networks to the PostgreSQL server and modify the localhost authentication method (change from indent to md5 and change from localhost to accept all incoming requests):
From
# IPv4 local connections:
host all all 127.0.0.1/32 ident
to
# IPv4 local connections:
host all all 0.0.0.0/0 md5
-
Restart the PostgreSQL service by typing "service postgresql-14 restart” (or the version that is installed)
- Create a database,a user and granting all privileges in postgresql
su - postgres
psql
create database <database-name>;
create user <user-name> with password 'your_password';
grant all privileges on database <database-name> to <user-name>;
Comments
0 comments
Please sign in to leave a comment.