Create Database Links from Autonomous AI Database to an Autonomous AI Database on a Private Endpoint
You can create database links from an Autonomous AI Database to a target Autonomous AI Database that is on a private endpoint.
Depending on configuration of the target Autonomous AI Database, you have these options:
See How to Create a Database Link from Your Autonomous AI Database to a Database Cloud Service Instance for more information.
Prerequisites for Database Links from Autonomous AI Database to a Target Autonomous AI Database on a Private Endpoint
Lists the prerequisites to create database links to a target Autonomous AI Database that is on a private endpoint.
To create a database link to a target Autonomous AI Database on a private endpoint:
-
The target database must be accessible from the source database's Oracle Cloud Infrastructure VCN. For example, you can connect to the target database when:
-
The target database is on a private endpoint.
-
Both the source database and the target database are in the same Oracle Cloud Infrastructure VCN.
-
The source database and the target database are in different Oracle Cloud Infrastructure VCNs that are paired.
-
The target database is connected to the source database's Oracle Cloud Infrastructure VCN using FastConnect or VPN.
-
-
For a target on a private endpoint,
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINKsupports specifying a single hostname with thehostnameparameter. On a private endpoint, using an IP address, SCAN IP, or a SCAN hostname is not supported (when the target is on a public endpoint,CREATE_DATABASE_LINKsupports using an IP address, a SCAN IP, or a SCAN hostname). -
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINKdoes not support a value oflocalhostfor thehostnameparameter. -
The following ingress and egress rules must be defined for the private endpoint:
-
Define an egress rule in the source database's subnet security list or network security group such that the traffic over TCP is allowed to the target database's IP address and port number.
-
Define an ingress rule in the target database's subnet security list or network security group such that the traffic over TCP is allowed from the source database IP address to the destination port.
See Configure Network Access with Private Endpoints for information on configuring private endpoints with ingress and egress rules.
-
Note: When your Autonomous AI Database instance is configured with a private endpoint, set the ROUTE_OUTBOUND_CONNECTIONS database property to specify that all outgoing database links are subject to the Autonomous AI Database instance private endpoint VCN’s egress rules. See Enhanced Security for Outbound Connections with Private Endpoints for more information.
Create Database Links to a Target Autonomous AI Database on a Private Endpoint without a Wallet (TLS)
You can create database links from an Autonomous AI Database to a target Autonomous AI Database that is on a private endpoint and connect without a wallet (TLS).
Perform the prerequisite steps, as required. See Prerequisites for Database Links from Autonomous AI Database to a Target Autonomous AI Database on a Private Endpoint for details.
To create a database link to a target Autonomous AI Database on a private endpoint without a wallet:
-
If you have not already done so, enable TLS connections on your Autonomous AI Database instance.
See Update your Autonomous AI Database Instance to Allow both TLS and mTLS Authentication for details.
-
Create credentials to access the target Autonomous AI Database instance. The
usernameandpasswordyou specify withDBMS_CLOUD.CREATE_CREDENTIALare the credentials for the target database used within the database link, (where the target database is accessed through the VCN).For example:
BEGIN DBMS_CLOUD.CREATE_CREDENTIAL( credential_name => 'PRIVATE_ENDPOINT_CRED', username => 'NICK', password => 'password' ); END; /The characters in the
usernameparameter must be all uppercase letters.Note: You can use a vault secret credential for the target database credential in a database link. See Use Vault Secret Credentials for more information.
This operation stores the credentials in the database in an encrypted format. You can use any name for the credential name.
-
Create the database link to the target database using
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK.For example:
BEGIN DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK( db_link_name => 'PRIVATE_ENDPOINT_LINK', hostname => 'exampleHostname', port => '1521', service_name => '*example_high.adb.oraclecloud.com*', credential_name => 'PRIVATE_ENDPOINT_CRED', directory_name => NULL, private_target => TRUE); END; /For a target on a private endpoint,
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINKsupports specifying a single hostname with thehostnameparameter. On a private endpoint, using an IP address, SCAN IP, or a SCAN hostname is not supported (when the target is on a public endpoint,CREATE_DATABASE_LINKsupports using an IP address, a SCAN IP, or a SCAN hostname).Users other than ADMIN require privileges to run
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK.As shown in the example, to create a database link with
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINKto a target database on a private endpoint without a wallet, all of the following are required:-
The
directory_nameparameter must beNULL. -
The
ssl_server_cert_dnparameter can either be omitted or if included, specify aNULLvalue. -
The
private_targetparameter must beTRUE.
Note: If you set the
ROUTE_OUTBOUND_CONNECTIONSdatabase property, setting theprivate_targetparameter toTRUEis not required in this API. See Enhanced Security for Outbound Connections with Private Endpoints for more information. -
-
Use the database link you created to access data in the target database.
For example:
SELECT * FROM employees@PRIVATE_ENDPOINT_LINK;Note:
For the credentials you create in Step 1, the Oracle AI Database credentials, if the password of the target user changes you can update the credential that contains the target user’s credentials as follows:
BEGIN DBMS_CLOUD.UPDATE_CREDENTIAL ( credential_name => 'DB_LINK_CRED', attribute => 'PASSWORD', value => 'password'); END; /Where password is the new password.
After this operation, the existing database links that use this credential continue to work without having to drop and recreate the database links.
See CREATE_DATABASE_LINK Procedure for additional information.
Create Database Links to a Target Autonomous AI Database on a Private Endpoint with a Wallet (mTLS)
You can create database links from an Autonomous AI Database to a target Autonomous AI Database that is on a private endpoint (mTLS).
Perform the prerequisite steps, as required. See Prerequisites for Database Links from Autonomous AI Database to a Target Autonomous AI Database on a Private Endpoint for details.
To create a database link to a target Autonomous AI Database on a private endpoint, with a wallet:
-
Copy your target database wallet,
cwallet.sso, containing the certificates for the target database to Object Store.Note: The wallet file, along with the Database user ID and password provide access to data in the target Oracle database. Store wallet files in a secure location. Share wallet files only with authorized users.
-
Create credentials to access your Object Store where you store the
cwallet.sso. See CREATE_CREDENTIAL Procedure for information about the username and password parameters for different object storage services. -
Create a directory on Autonomous AI Database for the wallet file
cwallet.sso.For example:
CREATE DIRECTORY WALLET_DIR AS '*directory_path_of_your_choice*';See Create Directory in Autonomous AI Database for information on creating directories.
-
Use
DBMS_CLOUD.GET_OBJECTto upload the target database wallet to the directory you created in the previous step, WALLET_DIR.For example:
BEGIN DBMS_CLOUD.GET_OBJECT( credential_name => 'DEF_CRED_NAME', object_uri => 'https://objectstorage.us-phoenix-1.oraclecloud.com/n/namespace-string/b/bucketname/o/cwallet.sso', directory_name => 'WALLET_DIR'); END; /In this example,
namespace-stringis the Oracle Cloud Infrastructure object storage namespace andbucketnameis the bucket name. See Understanding Object Storage Namespaces for more information.Note: The
credential_nameyou use in this step is the credentials for the Object Store. In the next step you create the credentials to access the target database. -
On Autonomous AI Database create credentials to access the target database. The
usernameandpasswordyou specify withDBMS_CLOUD.CREATE_CREDENTIALare the credentials for the target database used within the database link, (where the target database is accessed through the VCN).Note: Supplying the
credential_nameparameter is required.For example:
BEGIN DBMS_CLOUD.CREATE_CREDENTIAL( credential_name => 'DB_LINK_CRED', username => 'NICK', password => 'password'); END; /The characters in the
usernameparameter must be all uppercase letters.Note: You can use a vault secret credential for the target database credential in a database link. See Use Vault Secret Credentials for more information.
This operation stores the credentials in the database in an encrypted format. You can use any name for the credential name.
-
Create the database link to the target database using
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK.For example:
BEGIN DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK( db_link_name => 'PEDBLINK1', hostname => 'example1.adb.ap-osaka-1.oraclecloud.com', port => '1522', service_name => '*example_high.adb.oraclecloud.com*', credential_name => 'DB_LINK_CRED', directory_name => 'WALLET_DIR', private_target => TRUE); END; /Note: If you set the
ROUTE_OUTBOUND_CONNECTIONSdatabase property, setting theprivate_targetparameter toTRUEis not required in this API. See Enhanced Security for Outbound Connections with Private Endpoints for more information.For a target on a private endpoint,
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINKsupports specifying a single hostname with thehostnameparameter. On a private endpoint, using an IP address, SCAN IP, or a SCAN hostname is not supported (when the target is on a public endpoint,CREATE_DATABASE_LINKsupports using an IP address, a SCAN IP, or a SCAN hostname).DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINKdoes not support a value oflocalhostfor thehostnameparameter.Users other than ADMIN require privileges to run
DBMS_CLOUD_ADMIN.CREATE_DATABASE_LINK. -
Use the database link you created to access data in the target database.
For example:
SELECT * FROM employees@PEDBLINK1;Note:
For the credentials you create in Step 5, the Oracle AI Database credentials, if the password of the target user changes you can update the credential that contains the target user’s credentials as follows:
BEGIN DBMS_CLOUD.UPDATE_CREDENTIAL ( credential_name => 'DB_LINK_CRED', attribute => 'PASSWORD', value => 'password'); END; /Where password is the new password.
After this operation, the existing database links that use this credential continue to work without having to drop and recreate the database links.
See CREATE_DATABASE_LINK Procedure for additional information.