Thanks to visit codestin.com
Credit goes to docs.oracle.com

Note:

Connect pgAdmin 4 to OCI Database with PostgreSQL Using a Private Endpoint

Introduction

Oracle Cloud Infrastructure (OCI) Database with PostgreSQL system endpoints cannot be accessed directly from the internet. For applications to connect to the database, they must have connectivity to the Virtual Cloud Network (VCN) and subnet of the database system.

pgAdmin4 is an useful tool for carrying out routine database management tasks with PostgreSQL. When connecting to OCI Database with PostgreSQL services, the utilization of OCI Bastion services becomes essential. The pgAdmin4 tool, set up on our local system, requires OCI Bastion service to connect with OCI Database with PostgreSQL. This tutorial will guide you through the steps for accessing pgAdmin 4 in conjunction with OCI Database with PostgreSQL managed services.

Objectives

Note: This tutorial will not guide you through the initial creation process of a PostgreSQL managed service database in OCI. If you have not set up the database yet, follow this documentation: Creating a Database System.

Prerequisites

Task 1: Get the Private Endpoint Details

Log in to the OCI Console, navigate to PostgreSQL, Database systems, Database system details and make a note of the private endpoint details for the managed service database created in your OCI tenancy.

image

Task 2: Establish OCI Bastion Session

Open the OCI Console, navigate to Identity & Security, Bastion, Bastion Service Name and click Create Session. Enter a session Name, select IP Address to connect to the target and enter your Target IP Address, Target Port as 5432 and your SSH public key.

image

Task 3: Establish SSH Connection

After the session is created, copy the SSH command and update the values for the private key and local port. Establish the SSH connection in the terminal and click Enter.

localserver@user1 % ssh -i /Users/user1/Keys/ssh-key-priv.key -N -L 5432:10.0.1.103:5432 -p 22 ocid1.bastionsession.oc1.iad.amaxxxxxxxxjjzlb2da@host.bastion.us-ashburn-1.oci.oraclecloud.com

Task 4: Configure Network Access

Go to the OCI Console, navigate to Networking, Virtual Cloud Networks, select your VCN and click Security Lists Details and allow the connection from Bastion IP address to the OCI Database with PostgreSQL IP address and port.

image

Task 5: Connect with pgAdmin 4 and Configure the Connection Details

  1. Open pgAdmin 4 and click to add a new server. In the General section, enter a name.

    image

  2. In the Connection section, enter the following information and click Save.

    • Host Name/address: localhost.
    • Port: 5432.
    • Maintenance Database: postgres.
    • Username: admin username. Enter the username used during the creation of the OCI Database with PostgreSQL, for this tutorial we will use psqladmin.
    • Password: xxxxxxxxxxx.

    image

Once the connection is established, you can see the OCI Database with PostgreSQL highlighted in the following image. At this point, you can begin actively managing the database.

image

By following these tasks, you will be able to securely access your PostgreSQL managed service database in OCI using pgAdmin 4.

Acknowledgments

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.