Openflow Connector for Oracle: Configure the Oracle database¶
Note
This connector is subject to the Snowflake Connector Terms.
Note
The Openflow Connector for Oracle is also subject to additional terms of service beyond the standard connector terms of service. For more information, see the Openflow Connector for Oracle Addendum.
This topic describes how to set up the Oracle database for Openflow Connector for Oracle.
Note
Your Oracle database setup depends on your organization’s security policies and database architecture. For example, if tables reside in a Container Database (CDB), a Pluggable Database (PDB), multiple PDBs, or a combination.
The steps provided in this topic are examples only. Modify them as required for your environment.
As an Oracle database administrator, perform the following procedures on your source database:
- Configure the retention period for archived redo logs
- Enable XStream and supplemental logging
- Create the XStream administrator user
- Grant XStream administrator privileges
- Configure XStream server connect user
- Create XStream Outbound Server
- Set up the XStream Outbound Server Connect User
- Set up the XStream Outbound Server Capture User
- (Optional) Data Guard or standby capture (optional)
- (Optional) Configure SSL connections (optional)
Note
The steps in this topic are written for a multi-tenant architecture with a Container Database (CDB) and one or more Pluggable Databases (PDB). If your Oracle database uses a single-tenant architecture, see Set up XStream for single-tenant databases.
Configure the retention period for archived redo logs¶
You must enable the ARCHIVELOG mode to ensure that change data is available for replication.
If you use AWS RDS for Oracle, you must also configure the retention period for archived redo logs. Determine this period based on the volume of changes in the source database and your storage capacity.
To set the retention period, for example to 24 hours, follow the procedures in the following table:
| Database version | Procedure |
|---|---|
| AWS RDS (Standard) | Run the following: For more information see Retaining archived redo logs. |
| AWS RDS Custom |
For more information see Restoring an RDS Custom for Oracle instance. |
Enable XStream and supplemental logging¶
Note
XStream is included with Oracle Database and doesn’t require any additional software.
To enable and configure XStream replication to capture and stream change data, run the following commands:
- Enable XStream replication:
Note
Snowflake recommends setting the streams pool size to 2.5 GB. This allocation covers the following:
- 1 GB for Capture
- 1 GB for Apply
- An additional 25% buffer
To enable supplemental logging to ensure that the redo logs capture the information required for logical replication, run the following commands:
-
Confirm that the database is in ARCHIVELOG mode as shown in the following example:
Snowflake recommends forcing logging on database or table space level.
-
Set the container to the root container and add supplemental logging to the database:
Alternatively, you can enable logging only on specific tables as shown in the following example:
Create the XStream administrator user¶
An XStream administrator user is required to manage XStream components, including the creation and alteration of outbound servers. You can either create a dedicated user for this purpose or use an existing user, provided that the necessary XStream administration privileges are granted (see the next section).
The following example details the setup of a dedicated XStream administrator user in the root container of a CDB.
Note
The following example assumes that the database also has a PDB containing tables to be replicated.
Connect as SYSDBA or a user with appropriate privileges and run the following commands:
Grant XStream administrator privileges¶
Connect as SYSDBA or a user with appropriate privileges and grant the required privileges to the XStream administrator user.
-
Grant the CREATE SESSION privilege to the XStream administrator:
-
Grant XStream capture privileges using one of the following commands, depending on your Oracle Database version:
Database version Command Oracle Database 21c and earlier Run the following:
Oracle Database 23c and later Oracle Database 23c introduced a dedicated
XSTREAM_CAPTUREsystem privilege. Run the following:
Configure XStream server connect user¶
The Snowflake Openflow Connector uses a dedicated connect user to establish a connection to the XStream Outbound Server and receive change data. This user requires specific privileges to facilitate replication:
-
Read from XStream Outbound Server: The user must be able to access the change data stream from the configured XStream Outbound Server.
-
Select from Data Dictionary Views: The connect user needs SELECT access to various data dictionary views. This can be achieved by granting SELECT_CATALOG_ROLE or SELECT ANY DICTIONARY. If granting SELECT ANY DICTIONARY isn’t desired due to company policy, the user specifically needs SELECT access to the following views:
- ALL_USERS
- ALL_TABLES
- ALL_TAB_COLS
- ALL_CONS_COLUMNS
- ALL_CONSTRAINTS
- ALL_INDEXES
- ALL_IND_COLUMNS
- V$DATABASE
If you’re replicating data from multiple PDBs, also grant SELECT access to:
- V$CONTAINERS
- V$PARAMETER
- CDB_TABLES
- CDB_USERS
ALL_INDEXESandALL_IND_COLUMNSare required so the connector can detect unique constraints and unique indexes as replication keys when a table has no primary key. For more information on the selection algorithm, see How the connector chooses a replication key. -
Select from Source Tables: The user must have SELECT privileges on all tables that are intended for replication.
The following is an example of how to set up such a user in the root container of the CDB. The example assumes that the database also has a PDB containing tables to be replicated.
Note
If your database is multi-tenant and the connector is connected to a CDB to replicate data from multiple PDBs, grant the connect user the additional privileges needed to switch between containers and read data dictionary information across all of them:
If you granted SELECT on individual data dictionary views instead of
SELECT_CATALOG_ROLE or SELECT ANY DICTIONARY, also grant SELECT on
V$CONTAINERS, V$PARAMETER, CDB_TABLES, and CDB_USERS.
Create XStream Outbound Server¶
The XStream Outbound Server captures changes from redo logs for consumption by the Openflow Connector. Define which schemas or tables to replicate. For more information see DBMS_XSTREAM_ADM.CREATE_OUTBOUND Documentation.
Create the outbound server on a writable database: the primary, a logical standby, or a downstream capture database. You can’t create it on an Active Data Guard physical standby. For supported standby topologies, see Data Guard and standby support and Data Guard or standby capture (optional).
Important considerations for replication scope:
- If a table is included in the XStream Outbound filtering rules command, it won’t be replicated.
- A table or schema included here must also be defined in the connector parameters for it to be replicated. You can include an entire schema in the server filtering rules and later, in the connector parameters, specify only certain tables within that schema for replication.
Note
The XStream Outbound Server can only be created from root container. However, starting with Oracle Database version 23ai, it can also be created on the PDB level.
To avoid a significant hit to your CPU and network, and to prevent your queues from being filled with irrelevant data, it’s essential to use a granular approach. The best way to do this is with the DBMS_XSTREAM_ADM.ADD_TABLE_RULES procedure, which lets you choose only the specific tables you need.
The following examples show how to set up the XStream Outbound Server based on different replication needs. In practice, when setting up your XStream Outbound Server on your production environment, you should be selective about what changes you capture. Capturing everything can have serious consequences for your database’s performance and resource usage.
For information on how to configure XStream Outbound Server, see Configuring XStream Out.
Example 1: Capture all tables from all schemas in the root container and all PDBs
Example 2: Capture all tables from a single schema in a Pluggable Database (PDB)
Set up the XStream Outbound Server Connect User¶
Set the connect user on the XStream Outbound Server. This ensures that the previously created connect user is associated with the XStream Outbound Server (XOUT1), allowing it to receive change data.
Note
The following example assumes that the connect user is c##connectuser.
Set up the XStream Outbound Server Capture User¶
Note
If you want the data to be captured by the same user that created the server (the administrator), skip this section.
If you configured a separate capture user, configure the XStream Outbound Server to run as this user. This ensures that the dedicated capture user is associated with the XStream Outbound Server (XOUT1), allowing that user to capture change data.
Set up XStream for single-tenant databases¶
The default architecture for Oracle 12c and later is a multi-tenant architecture with a Container Database (CDB) and one or more Pluggable Databases (PDB). Oracle 11g uses a single-tenant (non-CDB) architecture.
If your Oracle database uses a single-tenant architecture, note the following differences in setting up XStream:
- Do not use
ALTER SESSION SET CONTAINERcommands. In a single-tenant database, there is only one instance, so container switching doesn’t apply. - Create only one
xstream_adm_tbstablespace. Do not create a second tablespace in a PDB. - Do not use the
C##prefix on user names. For example, createxstreamadmininstead ofc##xstreamadminandconnectuserinstead ofc##connectuser. TheC##prefix is required only in multi-tenant environments. - Do not include
CONTAINER=ALLorcontainer => 'ALL'in any commands. These clauses grant privileges across multiple containers and don’t apply in a single-tenant database.
Data Guard or standby capture (optional)¶
By default, the procedures in this topic create the XStream outbound server on the primary (source) database. If you want to keep replication load off the primary, review Data Guard and standby support and choose a supported topology before you create the outbound server.
Logical standby requirements¶
On a logical standby, create the XStream outbound server and connect the
connector to that standby the same way you would for a primary. Before you
create the outbound server or start the connector, set Database Guard to
STANDBY.
Logical standbys default to Database Guard ALL, which blocks the XStream
client from reading the outbound server and raises
ORA-16224: Database Guard is enabled.
-
Check the current guard status:
-
If the result is
ALL, set Database Guard toSTANDBY:
Then complete the XStream setup procedures in this topic on the logical standby, and point the connector’s Oracle connection URL and XStream Out Server URL at that standby.
Active Data Guard requirements for snapshot load¶
You can run the connector’s snapshot load against an Active Data Guard physical standby to avoid reading application tables on the primary. Because the standby is read-only:
- Set Snapshot Fetching Strategy to
SEQUENTIAL_BY_PRIMARY_KEYin the connector parameters.CONCURRENT_BY_ROWIDrequires creating a parallel task, which isn’t allowed on a read-only standby. - Don’t create the XStream outbound server on the Active Data Guard standby. For CDC, create it on the primary, a logical standby, or a downstream capture database instead.
Point the connector’s Oracle connection URL at the Active Data Guard standby for snapshot reads. Point the XStream Out Server URL at the writable database that hosts the outbound server (for example, the primary or a downstream capture database).
Downstream capture for CDC¶
To run CDC off the primary, configure Oracle downstream capture so that a separate database receives redo from the primary, then create the XStream outbound server on that downstream database by using the procedures in this topic.
Downstream capture provides redo only. It can’t serve snapshot queries. If you also need an initial snapshot without reading the primary, combine Active Data Guard for the snapshot with downstream capture for CDC, or use a logical standby for both stages.
For Oracle’s downstream capture concepts and setup, see XStream Out Concepts in the Oracle documentation.
Configure SSL connections (optional)¶
The Openflow Connector for Oracle supports encrypted SSL connections to the Oracle database using the TCPS (TCP with SSL) protocol. When SSL is enabled, both the database connection and the XStream connection use encrypted communication.
To use SSL, you must:
Enable TCPS on the Oracle database¶
You must configure the Oracle database to accept connections using the TCPS protocol. Follow the procedure for your database environment.
On-premises / OCI¶
- Create an SSL server wallet with the server certificate.
- Configure the
listener.orato include a TCPS endpoint (default port 2484). - Configure the
sqlnet.orato reference the server wallet. - Restart the listener.
For more information, see Configuring Transport Layer Security Encryption.
AWS RDS (Standard)¶
- Add the Oracle SSL option to the option group associated with the DB instance.
- Specify the SSL port (for example, 2484).
For more information, see Oracle Secure Sockets Layer.
Create a client wallet¶
After TCPS is enabled on the database, create an Oracle auto-login wallet (cwallet.sso)
containing the server’s trusted certificate. This wallet is provided to the connector so
that it can verify the server during the SSL handshake.
-
Export the server certificate from the Oracle database server as a PEM file.
-
Use the Oracle
orapkiutility to create a client wallet and import the server certificate: -
Copy the generated
cwallet.ssofile to a location accessible by the Openflow runtime.
Note
For AWS RDS, download the root certificate from AWS instead of exporting it from the database server. For more information, see Connecting to an RDS for Oracle DB instance using SSL.
For more information, see Using the orapki Utility to Manage PKI Elements.