Note:
- This tutorial requires access to Oracle Cloud. To sign up for a free account, see Get started with Oracle Cloud Infrastructure Free Tier.
- It uses example values for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, substitute these values with ones specific to your cloud environment.
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
- Connect pgAdmin 4 to OCI Database with PostgreSQL managed services.
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
-
OCI Database with PostgreSQL system provisioned in a private subnet.
-
Install pgAdmin 4.
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.
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.
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.
Task 5: Connect with pgAdmin 4 and Configure the Connection Details
-
Open pgAdmin 4 and click to add a new server. In the General section, enter a name.
-
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 usepsqladmin
. - Password:
xxxxxxxxxxx
.
- Host Name/address:
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.
By following these tasks, you will be able to securely access your PostgreSQL managed service database in OCI using pgAdmin 4.
Related Links
Acknowledgments
- Author - Jibin Babu Visweswara Panicker (Principal Cloud Architect)
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.
Connect pgAdmin 4 to OCI Database with PostgreSQL Using a Private Endpoint
F92415-01
February 2024
Copyright © 2024, Oracle and/or its affiliates.