# tested on
hostnamectl 
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-147.3.1.el8_1.x86_64
      Architecture: x86-64

# one could do just this:
# yum install postgresql-server postgresql-contrib
# will give one this version:
# psql --version
# psql (PostgreSQL) 10.6

# if one wants v12

dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

dnf -qy module disable postgresql

dnf -y install epel-release
dnf -y config-manager --set-enabled PowerTools
dnf -y install postgis30_12

yum -y install postgresql12-server postgresql12-contrib

/usr/pgsql-12/bin/postgresql-12-setup initdb

psql --version
psql (PostgreSQL) 12.1

# view main config file
vim /var/lib/pgsql/12/data/postgresql.conf
listen_addresses = 'localhost' # what IP address(es) to listen on; 
systemctl enable --now postgresql-12

systemctl restart postgresql-12
systemctl status postgresql-12.service

# follow logs / debugging problems:
# put this
find /var/log/ -type f \( -name "*" \) ! -path '*.gz*' -exec tail -n0 -f "$file" {} +
# in here
/scripts/mon_all_logs.sh

# and this
find /opt/tomcat/ -type f \( -name "*" \) ! -path '*.gz*' -exec tail -n0 -f "$file" {} +
# in that
/scripts/mon_all_tomcat_logs.sh

chmod + /scripts/*.sh

# increase limit of maximum per user open files
ulimit -n 8192;

# run the debugging
/scripts/mon_all_logs.sh &
/scripts/mon_all_tomcat_logs.sh &

# Error creating bean with name entityManagerFactory defined in class path resource spring bootstrap.xml Invocation of init method failed nested exception is 
# Could not open JDBC Connection for transaction nested exception is java.sql.SQLException Connections could not be acquired from the underlying database!

# and:

# psql: error: could not connect to server: FATAL:  Ident authentication failed for user 
vim /var/lib/pgsql/12/data/pg_hba.conf

# change those fields to md5

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

# restart postgres and watch the logs
systemctl restart postgresql-12.service

# test connect to testdb as user username
psql -d testdb -U username
# prompt for password
Password for user username:
# should appear


admin