Access Pega 7 PostgreSQL DB with pgAdmin

This post shows how to access Pega 7 PostgreSQL DB with pgAdminassuming Pega 7 is installed to use PostgreSQL– and to view all Pega 7 DB tables. This example applies to the following Pega 7 installation method:

  1. Pega 7 is installed as a Personal Virtual Server (PVS) utilizing the VMWare Player or Oracle VM VirtualBox as described in the Downloading the Exercise System section of the System Architect Essentials I (7.1) and Senior System Architect (7.1) courses provided by Pega Academy.
  2. Here, Windows 7 is used as the host operating system. The steps should be similar for other OS.

Related Posts

Summary

  1. Installation of the PostgreSQL pgAdmin Console
  2. Configuration of PostgreSQL DB Server to Accept Remote Connections
  3. Configuration of Connection Settings in postgresql.conf File
  4. Setup of PostgreSQL DB User for pgAdmin Connections
  5. Setup Connection in pgAdmin to Access Pega 7 PostgreSQL DB

1  Installation of the PostgreSQL pgAdmin Console

Download the pgAdmin tool for Windows from https://www.pgadmin.org/download/windows.php or for the Mac from https://www.pgadmin.org/download/macosx.php. In this example, pgAdmin version 1.14.3 for Windows was used. Follow the pgAdmin installation instructions to install the application.

2  Configuration of PostgreSQL DB Server to Accept Remote Connections

  • The exercise systems on Pega Academy use the PostgreSQL DB server as part of the PRPC personal virtual server installation.
  • Open the VMWare Player and click on the virtual machine and then click on the link Edit virtual machine settings.

VMWare Player Edit Virtual Machine Settings

  • Clicking on Network Adapter opens a view showing the current network connection settings.
  • In this example, the Network Adapter under Virtual Machine Settings of the VMWare Player is configured to use NAT (network address translation), so that the host’s IP address is shared (in this case the Windows OS on which the VMWare Player is running).
  • This will result in the virtual machine using an IP address in the 192.168 private network that is shared with the host operating system.

VMWare Player Edit Virtual Machine Settings - Network Adapter NAT Used to share the hosts IP Address

  • Next, use the VMWare Player to start the virtual machine by clicking on the link Play virtual machine and access it through the command line using the default user architect and the default password password.
  • For newer versions of the Pega Exercise System, use the default user root and the password install.

VMWare Player Ubuntu Command Line Login to Virtual Machine

  • The PostgreSQL server instance needs to be configured so that it allows connections from the 192.168 private network since pgAdmin has been installed on the host operating system.
  • Navigate to the folder /etc/postgresql/9.1/main on the virtual machine and locate pg_hba.conf.
  • On newer Pega 7 versions, the file is located at /var/lib/pgsql/9.4/data.
  • If you can’t locate the configuration file use the below command to search for it:
find / -name pg_hba.conf
  • Open the file in the vi editor using the command:
sudo vi pg_hba.conf

VMWare Player Ubuntu Command Line - Edit pg_hba.conf

  • In the section # IPv4 local connections, add: host all all 192.168.0.0/16 md5 to allow incoming connections from pgAdmin running on the Windows host operating system.

VMWare Player Ubuntu Command Line - Edit pg_hba.conf with VI

3  Configuration of Connection Settings in postgresql.conf File

  • Navigate to the folder /etc/postgresql/9.1/main and locate the file postgresql.conf and open it in vi using the command:
sudo vi postgresql.conf
  • Locate the section # CONNECTIONS AND AUTHENTICATION and uncomment the parameter listen_addresses and set its value to '*'.

VMWare Player Ubuntu Command Line - Edit postgresql.conf

  • In order for the changes to take effect, the virtual machine can either be restarted or the command:
/etc/init.d/postgresql restart
  • …can be used to only restart PostgreSQL so that it applies the updated configuration files.

VMWare Player Ubuntu Command Line - Restart PostgreSql DB Server

  • The PostgreSQL DB server running on the virtual machine will now accept remote connections from any IP address.

4  Setup of PostgreSQL DB User for pgAdmin Connections

  • It is recommended to create a dedicated PostgreSQL database user that will be used in the pgAdmin console. Execute the following command to create a new super user with access to all databases:
sudo -u postgres createuser --superuser <username>
  • Then open the PostgreSQL command line with by executing the command:
sudo -u postgres psql
  • Set the password of the new super user with the psql command:
\password <username>

VMWare Player Ubuntu Command Line - Create New PostgreSql DB User

  • The PostgreSQL server port should be 5432. It can be checked by executing the command:
sudo -u postgres psql -c "SHOW port;"

VMWare Player Ubuntu Command Line - Get PostgreSql DB Server Port 5432

  • Obtain the IP address of the virtual server by executing the command:
ifconfig -a

VMWare Player Ubuntu Command Line - Get Virtual Machine IP Address ifconfig command

  • In this case, the IP address of the virtual machine is 192.168.1.128.
  • Open the pgAdmin application on the Windows host system.

5  Setup Connection in pgAdmin to Access Pega 7 PostgreSQL DB

  • In pgAdmin, click on File in the top level menu and select Add Server.
  • In the New Server Registration dialog, enter the name for the connection, the host name, the port and the username and the password of the super user account created earlier.
  • Then click on Ok to open the connection.

pgAdmin Console - Add New Server - Properties

  • Double clicking on the new server connection opens a tree menu showing the Pega PRPC database named pega.
  • pgAdmin can be used to understand how PRPC operates and how it maintains data and rules by looking at the tables in the associated schemas.

Access Pega 7 PostgreSQL DB with pgAdmin - viewing pegarules schema

Caution: Modifying or deleting data or PRPC system tables can compromise a Pega 7 instance and render it useless.

2 thoughts on “Access Pega 7 PostgreSQL DB with pgAdmin

  1. Hi Bruno,

    From step 2 Configuration of PostgreSQL DB Server to Accept Remote Connections.

    when I had performed below

    Open the file in the vi editor using the command:
    sudo vi pg_hba.confOpen the file in the vi editor using the command:
    sudo vi pg_hba.conf

    I am not able to find any data here to make modifications, as well as after adding the details not sure on how to come out of the cmd prompt of vm.

    Can you please provide detailed info on how to connect to postgress sql database of SSA exercise system of 7.2 for windows 7 and for the latest pgadmin4.

Leave a Reply