Wednesday, May 10, 2023

Connect to Postgresql Database via DBeaver running on RHEL in a guest VM on Oracle virtualbox


Pre-requisites:

  • Setup includes oracle virtualbox
  • guest VM -- running on RHEL 7.x
[root@linuxpg1 selinux]#  cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.8 (Maipo)


  • Postgresql installed & running

Redirecting to /bin/systemctl status postgresql-14.service

● postgresql-14.service - PostgreSQL 14 database server

   Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vendor preset: disabled)

   Active: active (running) since Wed 2023-05-10 00:17:57 CDT; 13h ago

     Docs: https://www.postgresql.org/docs/14/static/

 Main PID: 7080 (postmaster)

   CGroup: /system.slice/postgresql-14.service

           ├─ 7080 /usr/pgsql-14/bin/postmaster -D /var/lib/pgsql/14/data/

           ├─ 7083 postgres: logger

           ├─ 7085 postgres: checkpointer

           ├─ 7086 postgres: background writer

           ├─ 7087 postgres: walwriter

           ├─ 7088 postgres: autovacuum launcher

           ├─ 7089 postgres: stats collector

           ├─ 7090 postgres: logical replication launcher

           ├─15197 postgres: postgres postgres 192.168.0.19(54850) idle

           ├─15198 postgres: postgres postgres 192.168.0.19(54851) idle

           └─15200 postgres: postgres postgres 192.168.0.19(54862) idle

May 10 00:17:57 linuxpg1 systemd[1]: Stopped PostgreSQL 14 database server.

May 10 00:17:57 linuxpg1 systemd[1]: Starting PostgreSQL 14 database server...

May 10 00:17:57 linuxpg1 postmaster[7080]: 2023-05-10 00:17:57.126 CDT [7080] LOG:  redirecting log output to loggi...roces

May 10 00:17:57 linuxpg1 postmaster[7080]: 2023-05-10 00:17:57.126 CDT [7080] HINT:  Future log output will appear ..."log"

May 10 00:17:57 linuxpg1 systemd[1]: Started PostgreSQL 14 database server.

Hint: Some lines were ellipsized, use -l to show in full.



  • Update postgresql.conf 
[root@linuxpg1 data]# pwd
/var/lib/pgsql/14/data
[root@linuxpg1 data]# ls -ltrh postgresql.conf
-rw-------. 1 postgres postgres 29K May 10 00:09 postgresql.conf
[root@linuxpg1 data]# cat postgresql.conf | grep -i listen
#listen_addresses = 'localhost'         # what IP address(es) to listen on;
listen_addresses = '*'          # what IP address(es) to listen on;
[root@linuxpg1 data]#
  • Update pg_hba.conf
[root@linuxpg1 data]# pwd
/var/lib/pgsql/14/data
[root@linuxpg1 data]# ls -ltrh pg_hba.conf
-rw-------. 1 postgres postgres 4.6K May 10 00:16 pg_hba.conf
[root@linuxpg1 data]# cat pg_hba.conf | grep password
# METHOD can be "trust", "reject", "md5", "password", "scram-sha-256",
# Note that "password" sends passwords in clear text; "md5" or
# "scram-sha-256" are preferred since they send encrypted passwords.
host    all     all     0.0.0.0/0 password
[root@linuxpg1 data]#

  • stop firewall
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld

from your laptop (host) 
use telnet to check connectivity on port 5432
telnet 192.168.0.25 5432




No comments:

Post a Comment