Saturday, December 5, 2026

How to Create a Database Link from an On-Premises Oracle Database to Oracle Autonomous Database

 


By Shashi Ranjan Singh

Introduction

Database Links (DBLinks) are widely used in Oracle Database environments to access objects residing in remote databases. They allow applications and DBAs to query remote tables, execute SQL statements, and exchange data without requiring separate connections for every operation.

In hybrid database environments, where organizations maintain both on-premises Oracle Databases and Oracle Autonomous Database (ADB) on Oracle Cloud Infrastructure (OCI), creating database links between these environments becomes an important requirement.

For example, an application running on an on-premises Oracle Database may need to access customer information stored in an Autonomous Database. Instead of developing a separate integration mechanism, we can use an Oracle Database Link to establish connectivity between the two databases.

In this article, we will explore how to create a database link from an on-premises Oracle Database to an Oracle Autonomous Database using two authentication methods:

  1. Mutual TLS (mTLS) – Requires an Autonomous Database wallet.

  2. TLS – Does not require a client wallet when the Autonomous Database is configured to allow TLS connections.

We will also discuss common configuration mistakes and troubleshooting techniques.

1. Environment Overview

For this demonstration, consider the following architecture.

Source Database (On-Premises)

ParameterValue
Hostnameora-db01.example.com
Database NamePRODDB
PDB NamePRODPDB
Oracle Version19c
Database UserAPP_OWNER

Target Database (OCI Autonomous Database)

ParameterValue
Database NameFINADB
Database Servicefinadb_high
Database UserREMOTE_APP
Connection ProtocolTCPS
OCI RegionMumbai

The objective is to create a database link named FINA_ADB_LINK from the on-premises database PRODPDB to the Autonomous Database FINADB.

The database link will allow users on the source database to access remote objects in the Autonomous Database.

Important: The source Oracle Database must be version 19c or later for the database link configuration described in this article.

2. Understanding TLS and mTLS Authentication

Before creating the database link, we need to understand the authentication options supported by Autonomous Database.

Autonomous Database supports secure connections using TLS and Mutual TLS (mTLS).

The connection method depends on the network configuration of the target Autonomous Database.

2.1 TLS (Transport Layer Security)

TLS provides encrypted communication between the source database and Autonomous Database.

With TLS authentication:

  • Communication is encrypted.

  • A client wallet is not required for the database connection.

  • The client verifies the server certificate.

  • The connection typically uses port 1521.

2.2 mTLS (Mutual Transport Layer Security)

mTLS provides an additional authentication layer by requiring both the client and server to authenticate their identities using certificates.

With mTLS:

  • Communication is encrypted.

  • The client requires an Autonomous Database wallet.

  • The wallet contains the required client certificates and connection configuration.

  • The connection typically uses port 1522.

2.3 How to Check the Authentication Configuration

Log in to the OCI Console and navigate to:

Autonomous Database → FINADB → Network

Check the Mutual TLS Authentication setting.

  • If mTLS is required, you must use the wallet-based connection.

  • If mTLS is not required, you can use the TLS connection without downloading a client wallet.

<IMPORTANT>Make sure the source database server can reach the Autonomous Database endpoint over the required port and that OCI network access controls permit the connection.</IMPORTANT>

3. Creating a DBLink Using mTLS Authentication

In this section, we will create a database link using the Autonomous Database wallet.

Step 1: Download the Autonomous Database Wallet

Log in to the OCI Console and navigate to the target Autonomous Database named FINADB.

Select:

Autonomous Database → FINADB → Database Connection → Download Wallet

Provide a wallet password and download the wallet ZIP file.

For this example, the downloaded file is:

Wallet_FINADB.zip

Step 2: Copy the Wallet to the On-Premises Database Server

Copy the downloaded wallet to the on-premises database server.

For example:

scp Wallet_FINADB.zip oracle@ora-db01.example.com:/tmp/

Connect to the source database server using the Oracle software owner.

Step 3: Create a Dedicated Wallet Directory

It is recommended to maintain a separate wallet directory for each Autonomous Database.

For this demonstration, we will use:

mkdir -p /u01/app/oracle/wallets/FINADB

Extract the wallet:

unzip /tmp/Wallet_FINADB.zip \
-d /u01/app/oracle/wallets/FINADB

Verify the extracted files:

ls -l /u01/app/oracle/wallets/FINADB

You should find files similar to:

cwallet.sso
ewallet.p12
keystore.jks
truststore.jks
sqlnet.ora
tnsnames.ora

The exact files may vary depending on the wallet package and OCI configuration.

Step 4: Configure the Wallet Directory

Navigate to the wallet directory and inspect the sqlnet.ora file.

cd /u01/app/oracle/wallets/FINADB

cat sqlnet.ora

The file may contain a wallet directory configuration similar to:

WALLET_LOCATION =
  (SOURCE =
    (METHOD = file)
    (METHOD_DATA =
      (DIRECTORY="?/network/admin")
    )
  )

SSL_SERVER_DN_MATCH=yes

Update the wallet directory to the actual location on the database server:

WALLET_LOCATION =
  (SOURCE =
    (METHOD = file)
    (METHOD_DATA =
      (DIRECTORY="/u01/app/oracle/wallets/FINADB")
    )
  )

SSL_SERVER_DN_MATCH=yes

This ensures that Oracle Net can locate the wallet files.

Note: Keep the wallet directory and file permissions restricted to the appropriate operating-system account. Do not expose wallet passwords or private keys.

Step 5: Configure TNS_ADMIN and Verify Connectivity

Set the TNS_ADMIN environment variable to point to the wallet directory.

export TNS_ADMIN=/u01/app/oracle/wallets/FINADB

Check the Autonomous Database connection aliases:

cat $TNS_ADMIN/tnsnames.ora

You should find connection aliases similar to:

finadb_high =
 (description =
   (retry_count=20)
   (retry_delay=3)
   (address =
     (protocol=tcps)
     (port=1522)
     (host=adb.ap-mumbai-1.oraclecloud.com)
   )
   (connect_data =
     (service_name=finadb_high.adb.oraclecloud.com)
   )
   (security =
     (ssl_server_dn_match=yes)
   )
 )

The hostname and service name above are illustrative. Always use the actual values provided in the downloaded wallet.

Test the connection using SQL*Plus:

sqlplus admin@finadb_high

Enter the Autonomous Database ADMIN password when prompted.

If the connection succeeds, the wallet and network configuration are working.

Step 6: Create a User in Autonomous Database

If you already have a dedicated user for database link connectivity, you can skip this step.

Otherwise, connect to Autonomous Database using the ADMIN account and create a dedicated user.

CREATE USER REMOTE_APP
IDENTIFIED BY "RemoteApp#2026";

GRANT CREATE SESSION TO REMOTE_APP;

GRANT SELECT ANY TABLE TO REMOTE_APP;

For production environments, avoid granting broad privileges such as SELECT ANY TABLE unless they are genuinely required. Prefer granting access to specific schemas and objects.

For example:

GRANT SELECT ON FINANCE.CUSTOMERS TO REMOTE_APP;

GRANT SELECT ON FINANCE.ACCOUNTS TO REMOTE_APP;

Step 7: Create the Database Link on the On-Premises Database

Now connect to the source database PRODPDB using the database user that will own the database link.

For this example, we will create a database link named:

FINA_ADB_LINK

Execute the following SQL statement:

CREATE DATABASE LINK FINA_ADB_LINK
CONNECT TO REMOTE_APP
IDENTIFIED BY "RemoteApp#2026"
USING
'(description=
   (retry_count=20)
   (retry_delay=3)
   (address=
     (protocol=tcps)
     (port=1522)
     (host=adb.ap-mumbai-1.oraclecloud.com)
   )
   (connect_data=
     (service_name=finadb_high.adb.oraclecloud.com)
   )
   (security=
     (my_wallet_directory=/u01/app/oracle/wallets/FINADB)
     (ssl_server_dn_match=true)
   )
 )';

Important: Replace the hostname, service name, and wallet directory with the actual values from your Autonomous Database wallet configuration.

The my_wallet_directory parameter specifies the location of the wallet used for the secure connection.

The ssl_server_dn_match=true setting enables server distinguished-name verification.

Step 8: Test the Database Link

After creating the database link, verify the connection.

SELECT * FROM dual@FINA_ADB_LINK;

Expected output:

D
-
X

Check the remote database identity:

SELECT
    name,
    db_unique_name,
    open_mode
FROM v$database@FINA_ADB_LINK;

If the query executes successfully, the database link is working.

You can also query a remote application table:

SELECT *
FROM FINANCE.CUSTOMERS@FINA_ADB_LINK;

The source database can now access the permitted objects in Autonomous Database.

4. Creating a DBLink Using TLS Authentication (Without Wallet)

Now let's look at the second scenario.

If the target Autonomous Database is configured with mTLS authentication set to Not required, we can create a database link without using the Autonomous Database client wallet.

This approach is simpler because we only need to configure the appropriate Oracle Net connection descriptor.

Step 1: Get the TLS Connection String from OCI

Log in to the OCI Console and navigate to:

Autonomous Database → FINADB → Database Connection

Select the TLS connection option and copy the connection string.

For TLS connectivity, the connection generally uses port 1521.

The hostname and service name must match the values provided by OCI.

Step 2: Configure the TNS Entry on the Source Database Server

Edit the tnsnames.ora file on the on-premises database server.

vi $ORACLE_HOME/network/admin/tnsnames.ora

Add the following entry:

FINADB_TLS =
 (description =
   (retry_count=20)
   (retry_delay=3)
   (address =
     (protocol=tcps)
     (port=1521)
     (host=adb.ap-mumbai-1.oraclecloud.com)
   )
   (connect_data =
     (service_name=finadb_high.adb.oraclecloud.com)
   )
   (security =
     (ssl_server_dn_match=yes)
   )
 )

Save the file.

Note: Use the TLS connection descriptor supplied by OCI. Do not assume that changing the port from 1522 to 1521 in an mTLS descriptor is sufficient for every environment.

Step 3: Verify the TLS Connection

Set the appropriate Oracle Net configuration directory if required:

export TNS_ADMIN=$ORACLE_HOME/network/admin

Test the connection:

tnsping FINADB_TLS

You can also test an actual database connection using SQL*Plus:

sqlplus admin@FINADB_TLS

If the connection is successful, proceed with database link creation.

Step 4: Create the Database Link

Connect to the source database PRODPDB and execute:

CREATE DATABASE LINK FINA_ADB_LINK
CONNECT TO REMOTE_APP
IDENTIFIED BY "RemoteApp#2026"
USING 'FINADB_TLS';

Here:

  • FINA_ADB_LINK is the database link name.

  • REMOTE_APP is the remote Autonomous Database username.

  • FINADB_TLS is the TNS alias configured on the source database server.

Step 5: Test the Database Link

Execute:

SELECT * FROM dual@FINA_ADB_LINK;

You should receive:

D
-
X

This confirms that the database link can connect to the Autonomous Database using TLS without a client wallet.

5. Common Errors and Troubleshooting

While configuring database links between on-premises Oracle Database and Autonomous Database, you may encounter a few common errors.

Let's discuss some of them.

5.1 ORA-29002: SSL Transport Detected Invalid or Obsolete Server Certificate

This error can occur when the connection descriptor uses an IP address instead of the original Autonomous Database hostname.

For example, avoid configuring:

(host=10.10.20.15)

Instead, use the original hostname supplied by OCI:

(host=adb.ap-mumbai-1.oraclecloud.com)

The hostname is important for SSL certificate verification and server identity matching.

Also verify that the client wallet and trusted certificates are valid.

5.2 ORA-02085: Database Link Connects to Another Database

You may encounter the following error:

ORA-02085: database link FINA_ADB_LINK connects to FINADB

This can happen when the GLOBAL_NAMES parameter is enabled and the database link name does not match the remote database's global database name.

Check the parameter on the source database:

SHOW PARAMETER global_names;

If it is enabled, Oracle enforces global database link naming rules.

You can check the remote database global name using:

SELECT * FROM global_name@FINA_ADB_LINK;

If your operational requirements permit non-matching database link names, the DBA can evaluate setting GLOBAL_NAMES to FALSE.

ALTER SYSTEM SET GLOBAL_NAMES=FALSE SCOPE=BOTH;

Important: This is a database-wide configuration change. Evaluate the impact on existing database links and application dependencies before changing it in production.

5.3 ORA-12154: TNS Could Not Resolve the Connect Identifier

This error commonly occurs when Oracle Net cannot resolve the TNS alias.

Check the following:

  • Verify that the tnsnames.ora file contains the correct alias.

  • Confirm that TNS_ADMIN points to the expected directory.

  • Check for syntax errors in the connection descriptor.

  • Verify that the database process can access the required Oracle Net configuration files.

Useful command:

tnsping FINADB_TLS

5.4 ORA-12541: TNS No Listener

This error indicates that the connection cannot reach the expected listener endpoint.

Check:

  • Network connectivity from the source server.

  • Firewall rules for the required TCPS port.

  • OCI network security lists or NSGs.

  • Autonomous Database endpoint accessibility.

  • DNS resolution of the OCI hostname.

For example:

nslookup adb.ap-mumbai-1.oraclecloud.com

5.5 ORA-01017: Invalid Username or Password

This error indicates that the authentication credentials supplied for the remote database are incorrect or cannot be authenticated.

Verify:

  • Remote username.

  • Remote password.

  • Whether the user is locked or expired.

  • Whether the database link was created with the correct credentials.

If necessary, recreate the database link with the correct credentials.

6. Important DBA Considerations

Before implementing this configuration in production, keep the following points in mind:

  1. Database Version: Ensure the source Oracle Database is running a supported version (19c or later for this approach).

  2. Network Connectivity: Verify that the on-premises server can reach the Autonomous Database endpoint over the required port.

  3. Wallet Management: For mTLS, keep the wallet in a secure location and establish a process for wallet rotation and updates.

  4. RAC Environment: If the source database is running on RAC, ensure that the wallet is accessible from every node where database processes may establish outbound connections. A shared ACFS location is one possible approach.

  5. TNS_ADMIN Configuration: Ensure that Oracle Net configuration is available to the database server processes, not just the interactive shell session.

  6. Privileges: Grant only the minimum required privileges to the remote database user.

  7. Connection Testing: Always test the database link with a simple query before using it in application code or production jobs.

  8. Password Security: Avoid embedding production passwords directly in scripts, SQL deployment logs, or shared documentation. Use appropriate secret-management procedures.

7. Conclusion

Creating a database link from an on-premises Oracle Database to Oracle Autonomous Database is straightforward once the required network and authentication configurations are understood.

The main difference between TLS and mTLS connectivity is the requirement for a client wallet.

With mTLS, we need to download and configure the Autonomous Database wallet on the source database server and provide its location in the database link connection descriptor.

With TLS, provided that the Autonomous Database allows TLS connections, we can configure a TNS alias and create the database link using the standard USING clause.

Both approaches provide secure connectivity between on-premises Oracle Database and Autonomous Database, enabling organizations to integrate their existing database environments with Oracle Cloud Infrastructure.

Happy Learning!

— Shashi Ranjan Singh

No comments:

Post a Comment