Oracle Database Source Connector for Confluent Cloud

Note

If you are installing the connector locally for Confluent Platform, see JDBC Connector (Source and Sink) for Confluent Platform.

The Kafka Connect Oracle Database Source connector for Confluent Cloud can obtain a snapshot of the existing data in an Oracle database and then monitor and record all subsequent row-level changes to that data. The connector supports Avro, JSON Schema, Protobuf, or JSON (schemaless) output data formats. All of the events for each table are recorded in a separate Apache Kafka® topic. The events can then be easily consumed by applications and services. Note that deleted records are not captured.

Important

If you are still on Confluent Cloud Enterprise, please contact your Confluent Account Executive for more information about using this connector.

Features

The Oracle Database Source connector provides the following features:

  • Topics created automatically: The connector automatically creates Kafka topics using the naming convention: <topic.prefix><tableName>. The tables are created with the properties: topic.creation.default.partitions=1 and topic.creation.default.replication.factor=3.

  • Insert modes:

    • timestamp mode is enabled when only a timestamp column is specified when you enter database details.

    • timestamp+incrementing mode is enabled when both a timestamp column and incrementing column are specified when you enter database details.

      Important

      A timestamp column must not be nullable.

  • Database authentication: Uses password authentication.

  • Data formats: The connector supports Avro, JSON Schema, Protobuf, or JSON (schemaless) output data. Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).

  • Select configuration properties:

    • db.timezone
    • poll.interval.ms
    • batch.max.rows
    • timestamp.delay.interval.ms
    • topic.prefix
    • schema.pattern

    See the Oracle Database Source configuration properties for additional information.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.

For more information, see the Confluent Cloud connector limitations.

Note

Most JSON data that uses precise decimal data represents it as a decimal number with a precision of 38 (e.g., NUMBER(38,0). This is too large for INT64 or FLOAT64. INTEGER is an alias for NUMBER(38) and has the same issue. For this reason, this source connector uses the Connect decimal type. Confluent has an article that goes into greater detail about this subject. See Kafka Connect Deep Dive – JDBC Source connector.

Quick Start

Use this quick start to get up and running with the Confluent Cloud Oracle Database Source connector. The quick start provides the basics of selecting the connector and configuring it to obtain a snapshot of the existing data in an Oracle database and then monitoring and recording all subsequent row-level changes.

Prerequisites
  • Authorized access to a Confluent Cloud cluster on Amazon Web Services (AWS), Microsoft Azure (Azure), or Google Cloud Platform (GCP).

  • The Confluent Cloud CLI installed and configured for the cluster. See Install and Configure the Confluent Cloud CLI.

  • The connector automatically creates Kafka topics using the naming convention: <prefix>.<table-name>. The tables are created with the properties: topic.creation.default.partitions=1 and topic.creation.default.replication.factor=3. If you want to create topics with specific settings, please create the topics before running this connector.

  • The Oracle Database System must be configured with a Pluggable Database (PDB) service name. See Configuring a Multitenant Oracle Database System for instructions for setting this up. This is used for the Database name when configuring the connection to the database.

  • Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).

  • Public access may be required for your database. See Internet Access to Resources for details. The example below shows the AWS Management Console when setting up the database.

    AWS example showing public access for Oracle Database

    Public access enabled

  • For networking considerations, see Internet access to resources. To use static egress IPs, see Static Egress IP Addresses. The example below shows the AWS Management Console when setting up security group rules for the VPC.

    AWS example showing security group rules

    Open inbound traffic

    Note

    See your specific cloud platform documentation for how to configure security rules for your VPC.

  • Kafka cluster credentials. You can use one of the following ways to get credentials:
    • Create a Confluent Cloud API key and secret. To create a key and secret, you can use the Confluent Cloud CLI or you can autogenerate the API key and secret directly in the Cloud Console when setting up the connector.
    • Create a Confluent Cloud service account for the connector. Make sure to review the ACL entries required in the service account documentation. Some connectors have specific ACL requirements.

Using the Confluent Cloud Console

Step 1: Launch your Confluent Cloud cluster.

See the Quick Start for Apache Kafka using Confluent Cloud for installation instructions.

Step 2: Add a connector.

In the left navigation menu, click Data integration, and then click Connectors. If you already have connectors in your cluster, click + Add connector.

Step 3: Select your connector.

Click the Oracle Database Source connector icon.

Oracle Database Source Connector Icon

Step 4: Set up the connection.

Complete the following and click Continue.

Note

  • Make sure you have all your prerequisites completed.
  • An asterisk ( * ) designates a required entry.
  1. Enter a connector name.

  2. Enter your Kafka Cluster credentials. The credentials are either the API key and secret or the service account API key and secret.

  3. Enter a topic prefix. The connector automatically creates Kafka topics using the naming convention: <prefix>.<table-name>. The tables are created with the properties: topic.creation.default.partitions=1 and topic.creation.default.replication.factor=3. If you want to create topics with specific settings, please create the topics before running this connector.

  4. Add the connection details for the database.

    Important

    Do not include jdbc:xxxx:// in the Connection host field. The example below shows a sample host address.

    ../_images/ccloud-postgresql-source-connect-to-data.png
  5. Add the Database details for your database. Review the following notes for more information about field selections.

    • Enter a Timestamp column name to enable timesamp mode. This mode uses a timestamp (or timestamp-like) column to detect new and modified rows. This assumes the column is updated with each write, and that values are monotonically incrementing, but not necessarily unique.
    • Enter both a Timestamp column name and an Incrementing column name to enable timestamp+incrementing mode. This mode uses two columns, a timestamp column that detects new and modified rows, and a strictly incrementing column which provides a globally unique ID for updates so each row can be assigned a unique stream offset.
    • By default, the connector only detects tables with type TABLE from the source database. Use VIEW for virtual tables created from joining one or more tables. Use ALIAS for tables with a shortened or temporary name.
    • If you define a schema pattern in your database, you need to enter the Schema pattern in this field. Search on schema.pattern in JDBC Connector Source Connector Configuration Properties for additional information.

    See the Oracle Database Source configuration properties for additional information.

  6. Add the Connection details for your connection to the database. Note the following SSL mode properties:

    • The default SSL mode is disabled. If set to verify-ca, the connector uses a truststore file to verify that the host server is trustworthy. The connector uses this file to check the certificate chain up to a trusted certificate authority (CA). If set to verify-full, the connector also verifies that the server host name matches its certificate. When verify-full is used, you must also supply the Distinguished name (DN) for the server host.
    • You use the Trust store button to upload the truststore file that contains the CA information. You must add the truststore file password.
  7. Select an Output message format (data coming from the connector): AVRO, JSON_SR (JSON Schema), PROTOBUF, or JSON (schemaless). A valid schema must be available in Schema Registry to use a schema-based message format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).

  8. Enter the number of tasks in use by the connector. Refer to Confluent Cloud connector limitations for additional information.

  9. Transforms and Predicates: See the Single Message Transforms (SMT) documentation for details.

See the Oracle Database Source configuration properties for properties and definitions.

Step 5: Launch the connector.

Verify the connection details by previewing the running configuration. Once you’ve validated that the properties are configured to your satisfaction, click Launch.

Tip

For information about previewing your connector output, see Connector Data Previews.

Launch the connector

Step 6: Check the connector status.

The status for the connector should go from Provisioning to Running. It may take a few minutes.

Check the connector status

Step 7: Check the Kafka topic.

After the connector is running, verify that messages are populating your Kafka topic.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.

See also

For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent Cloud CLI to manage your resources in Confluent Cloud.

../_images/topology.png

Using the Confluent Cloud CLI

Complete the following steps to set up and run the connector using the Confluent Cloud CLI.

Note

Make sure you have all your prerequisites completed.

Step 1: List the available connectors.

Enter the following command to list available connectors:

ccloud connector-catalog list

Step 2: Show the required connector configuration properties.

Enter the following command to show the required connector properties:

ccloud connector-catalog describe <connector-catalog-name>

For example:

ccloud connector-catalog describe OracleDatabaseSource

Example output:

Following are the required configs:
connector.class
name
kafka.api.key
kafka.api.secret
topic.prefix
connection.host
connection.port
connection.user
connection.password
db.name
table.whitelist
timestamp.column.name
output.data.format
tasks.max

Step 3: Create the connector configuration file.

Create a JSON file that contains the connector configuration properties. The following example shows the required connector properties.

{
    "name" : "confluent-oracle-source",
    "connector.class": "OracleDatabaseSource",
    "kafka.api.key": "<my-kafka-api-key>",
    "kafka.api.secret" : "<my-kafka-api-secret>",
    "topic.prefix" : "oracle_",
    "connection.host" : "<my-database-endpoint>",
    "connection.port" : "1521",
    "connection.user" : "<database-username>",
    "connection.password": "<database-password>",
    "db.name": "db078_pdb1.subnet.vcn.oraclevcn.com",
    "table.whitelist": "PASSENGERS",
    "timestamp.column.name": "created_at",
    "output.data.format": "JSON",
    "db.timezone": "UCT",
    "tasks.max" : "1"
}

Note the following property definitions:

  • "name": Sets a name for your new connector.
  • "connector.class": Identifies the connector plugin name.
  • "topic.prefix": Enter a topic prefix. The connector automatically creates Kafka topics using the naming convention: <prefix>.<table-name>. The tables are created with the properties: topic.creation.default.partitions=1 and topic.creation.default.replication.factor=3. If you want to create topics with specific settings, please create the topics before running this connector.
  • "output.data.format": Sets the output message format (data coming from the connector). Valid entries are AVRO, JSON_SR, PROTOBUF, or JSON. You must have Confluent Cloud Schema Registry configured if using a schema-based message format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).
  • "db.timezone": Identifies the database timezone. This can be any valid database timezone. The default is UTC. For more information, see this list of database timezones.

Single Message Transforms: See the Single Message Transforms (SMT) documentation for details about adding SMTs using the CLI.

See the Oracle Database Source configuration properties for properties and definitions.

Step 4: Load the properties file and create the connector.

Enter the following command to load the configuration and start the connector:

ccloud connector create --config <file-name>.json

For example:

ccloud connector create --config oracle-source.json

Example output:

Created connector confluent-oracle-source lcc-ix4dl

Step 5: Check the connector status.

Enter the following command to check the connector status:

ccloud connector list

Example output:

ID          |            Name         | Status  |  Type
+-----------+-------------------------+---------+-------+
lcc-ix4dl   | confluent-oracle-source | RUNNING | source

Step 6: Check the Kafka topic.

After the connector is running, verify that messages are populating your Kafka topic.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.

Configuring a Multitenant Oracle Database System

Multitenancy is a standard feature for Oracle database systems, beginning with Oracle Database version 12c. Multitenancy provides a Container Database (CDB) that houses the system information and Pluggable Databases (PDBs) that house your application data and tables.

The following example OCI DB Systems screen shows the environment configuration used in this procedure.

Oracle Cloud example showing the Oracle Database configuration

Use the following steps to configure an Oracle multitenant database system in the Oracle Cloud Infrastructure (OCI). Once configured, you can use the Oracle Database Source Connector for Confluent Cloud to connect to the database and obtain a snapshot of the existing data in the database and then monitor and record all subsequent row-level changes to that data.

Prerequisites

Step 1: SSH into the database VM

Open a Secure Shell (SSH) terminal session on the database VM and switch to the Oracle user. Note that you pass the private key for connecting to the VM instance.

ssh opc@<public-ip-address> -i </path/to/private-key>

For example:

ssh opc@192.136.114.86 -i ~/.ssh/oracle_id_rsa

Once you are on the VM, enter the following commands to switch to the Oracle user.

sudo su
su - oracle

Example output:

[opc@host ~]$ sudo su
[root@host opc]# su - oracle
Last login: Wed Jul 29 20:00:03 UTC 2020
[oracle@host ~]$

Step 2: Get the Pluggable Database (PDB) service name

Get the PDB service name by checking the listener status. Enter the following command on the VM as the Oracle user:

lsnrctl status LISTENER

For example:

[oracle@host ~]$ lsnrctl status LISTENER

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 29-JUL-2020 21:41:52

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=host.subnet.vcn.oraclevcn.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                29-JUL-2020 17:39:05
Uptime                    0 days 4 hr. 2 min. 47 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/host/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=host.subnet.vcn.oraclevcn.com)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=host.subnet.vcn.oraclevcn.com)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/DB0729_iad1qn/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "DB0729XDB.subnet.vcn.oraclevcn.com" has 1 instance(s).
  Instance "DB0729", status READY, has 1 handler(s) for this service...
Service "DB0729_iad1qn.subnet.vcn.oraclevcn.com" has 1 instance(s).
  Instance "DB0729", status READY, has 1 handler(s) for this service...
Service "a33f59386e740c51e053c701f40af1dd.subnet.vcn.oraclevcn.com" has 1 instance(s).
  Instance "DB0729", status READY, has 1 handler(s) for this service...
Service "db0729_pdb1.subnet.vcn.oraclevcn.com" has 1 instance(s).
  Instance "DB0729", status READY, has 1 handler(s) for this service...
The command completed successfully

In the example output above, the PDB service name you need is shown below:

(HOST=host.subnet.vcn.oraclevcn.com)(PORT=1521)

Step 3: Create the PDB service name

Complete the following steps on the VM to create a new tnsnames.ora PDB service name entry. The new entry is used when setting up the database connection for the Oracle Database Source Connector for Confluent Cloud. The entry allows the connector to establish a connection to the Oracle database.

  1. Exit the Oracle user account.

    exit
    
  2. Change to the root directory.

    cd /
    
  3. Find the tnsnames.ora entries.

    find . -name tnsnames.ora
    

    For example:

    [oracle@host ~]$ exit
    logout
    [root@host opc]# cd /
    [root@host /]# find . -name tnsnames.ora
    ./u01/app/oracle/product/19.0.0/dbhome_1/network/admin/samples/tnsnames.ora
    ./u01/app/oracle/product/19.0.0/dbhome_1/network/admin/tnsnames.ora
    
  4. Change to the network/admin directory.

    cd /u01/app/oracle/product/19.0.0/dbhome_1/network/admin
    
  5. Edit the tnsnames.ora file and add the PDB service name from the listener status output. The additional PDB service name block is DB0729_PDB1 in the example.

    vi tnsnames.ora
    

    For example:

    DB0729_IAD1QN =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = host.subnet.vcn.oraclevcn.com)(PORT = 1521))
        )
        (CONNECT_DATA =
          (SERVICE_NAME = DB0729_iad1qn.subnet.vcn.oraclevcn.com)
        )
      )
    
    DB0729_PDB1 =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = host.subnet.vcn.oraclevcn.com)(PORT = 1521))
        )
        (CONNECT_DATA =
          (SERVICE_NAME = DB0729_pdb1.subnet.vcn.oraclevcn.com)
        )
      )
    

Step 4: Launch the connector

Complete the steps in Oracle Database Source Connector for Confluent Cloud. When you get to the section where you need to add the database connection details, enter the PDB service name you added in the previous step. For example:

Connection setup showing PDB service name

Configuration Properties

The following connector configuration properties can be used with the Oracle Database Source connector for Confluent Cloud.

topic.prefix

Prefix to prepend to table names to generate the name of the Apache Kafka® topic to publish data to, or in the case of a custom query, the full name of the topic to publish to.

  • Type: string
  • Importance: high
connection.host

The host URL address. For example, 192.136.114.86.

  • Type: string
  • Importance: high
connection.port

The host port to connect to. For example, 1521.

  • Type: int
  • Importance: high
connection.user

Database connection user.

  • Type: string
  • Importance: high
connection.password

Database connection user password.

  • Type: password
  • Importance: high
db.name

Database name.

  • Type: string
  • Importance: high
ssl.mode

The default disabled disables SSL entirely. The option verify-ca uses SSL for encryption and authenticates the server Certificate Authority (CA). The verify-ca option requires a Java truststore file (ssl.truststorefile) containing the server CA and the truststore password (ssl.truststorepassword).

  • Type: string
  • Default: disabled
  • Importance: high
ssl.truststorefile

The file containing the server CA certificate. This is required if using verify-ca or verify-full SSL mode. You must encode the binary truststore file in base64, take the encoded string, add the data:text/plain;base64 prefix, and then specify the entire string as the property entry. For example: "ssl.truststorefile" : "data:text/plain;base64,/u3+7QAAAAIAAAACAAAAAQAGY2xpZ...==".

  • Type: password
  • Importance: low
ssl.truststorepassword

The password for the truststore file.

  • Type: password
  • Importance: low
ssl.server.cert.dn

Distinguished name (DN) of the database server. This is only required when using verify-full SSL mode.

  • Type: string
  • Importance: low
table.whitelist

List of tables from which to get data. Use a comma-separated list to specify multiple tables. For example "table.whitelist" : "User, Address, Email".

  • Type: string
  • Importance: low
timestamp.column.name

Comma-separated list of one or more timestamp columns used to detect new or modified rows using the COALESCE SQL function. Rows whose first non-null timestamp value is greater than the largest previous timestamp value are discovered with each poll. At least one column should not be nullable.

  • Type: string
  • Default: “”
  • Importance: medium
incrementing.column.name

The name of the strictly incrementing column to use when detecting new rows. Any empty value indicates the column should be autodetected by looking for an auto-incrementing column. This column may not be nullable.

  • Type: string
  • Default: “”
  • Importance: medium
table.types

By default, this connector only detects tables with type TABLE from the source Database. This config allows a comma-separated list of table types to extract. Accepts TABLE, VIEW, or ALIAS as property values.

  • Type: list
  • Default: TABLE
  • Importance: low
schema.pattern

Schema pattern to fetch table metadata from the database. "" retrieves table metadata for tables not using a schema. null (default) indicates that the schema name is not used to narrow the search and that all table metadata is fetched, regardless of the schema.

  • Type: string
  • Default: null
  • Importance: high
db.timezone

Name of the database timezone to use with the connector, when querying with time-based criteria. Defaults to UTC.

  • Type: string
  • Default: UTC
  • Valid values: Any valid JDK time zone
  • Importance: medium
numeric.mapping

Map NUMERIC values by precision and optionally scale to integral or decimal types. Use none if all NUMERIC columns are to be represented by Connect’s DECIMAL logical type. Use best_fit if NUMERIC columns should be cast to Connect’s INT8, INT16, INT32, INT64, or FLOAT64 based upon the column’s precision and scale. This option may still represent the NUMERIC value as Connect DECIMAL if it cannot be cast to a native type without losing precision. For example, a NUMERIC(20) type with precision 20 would not be able to fit in a native INT64 without overflowing and thus would be retained as DECIMAL. The none option is the default, but may lead to serialization issues with Avro since the Connect DECIMAL type is mapped to its binary representation. Typically, best_fit should be used since it maps to the most appropriate primitive type.

  • Type: string
  • Default: null
  • Valid Values: [none, precision_only, best_fit]
  • Importance: low
poll.interval.ms

Internal time in milliseconds to poll for new data in each table.

  • Type: int
  • Default: 5000
  • Importance: high
batch.max.rows

Maximum number of rows to include in a single batch, when polling for new data. This setting can be used to limit the amount of data buffered internally in the connector.

  • Type: int
  • Default: 100
  • Importance: low
timestamp.delay.interval.ms

How long to wait after a row with a given timestamp appears until that data is included in the result. You may choose to use timestamp delay to allow transactions having an earlier timestamp to complete first. The first time it runs, the connector fetches all available records (that is, starting at timestamp 0) up to the current time, minus the timestamp delay. After that, every time the connector fetches records, it fetches data from the last time it fetched up to the current time, minus the timestamp delay.

  • Type: long
  • Default: 0
  • Importance: high

Next Steps

See also

For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent Cloud CLI to manage your resources in Confluent Cloud.

../_images/topology.png