Oracle Database Source Connector for Confluent Cloud
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: <database.server.name>.<schemaName>.<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
Configuration properties that are not shown in the Confluent Cloud UI use the
default values. See JDBC Connector Source Connector Configuration Properties for default values and property definitions.
You can manage your full-service connector using the Confluent Cloud API. For details, see the Confluent Cloud API documentation.
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.
Public inbound traffic access (0.0.0.0/0
) may be required for the VPC where the database is located, unless the environment is configured for VPC peering. See Internet Access to Resources for details. The example below shows the AWS Management Console when setting up security group rules for the VPC.
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, go to Kafka API keys in your cluster or you can autogenerate the API key and secret directly in the UI when setting up the connector.
- Create a Confluent Cloud service account for the connector.
Using the Confluent Cloud GUI
Step 2: Add a connector.
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.
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.
Enter a connector name.
Enter your Kafka Cluster credentials. The credentials are either the API key and secret or the service account API key and secret.
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.
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.
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.
Add the Connection details for your connection to the database.
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).
Enter the number of tasks in use by the connector. Refer to Confluent Cloud connector limitations for additional information.
Step 5: Launch the connector.
Verify the connection details and click Launch.
Step 6: Check the connector status.
The status for the connector should go from Provisioning to Running. It may take a few minutes.
Step 7: Check the Kafka topic.
After the connector is running, verify that messages are populating your Kafka topic.
You can manage your full-service connector using the Confluent Cloud API. For details, see the Confluent Cloud API documentation.
For additional information about this connector, see JDBC Connector (Source and Sink) for Confluent Platform. Note
that not all Confluent Platform connector features are provided in the Confluent Cloud connector.
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.
Using the Confluent Cloud CLI
Complete the following steps to set up and run the connector using the Confluent Cloud CLI.
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.
Configuration properties that are not listed use the default values. For default
values and property definitions, see JDBC Connector Source Connector Configuration Properties.
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:
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.
You can manage your full-service connector using the Confluent Cloud API. For details, see the Confluent Cloud API documentation.
For additional information about this connector, see JDBC Connector (Source and Sink) for Confluent Platform. Note
that not all Confluent Platform connector features are provided in the Confluent Cloud connector.
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.
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.
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.
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:
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.
Exit the Oracle user account.
Change to the root directory.
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
Change to the network/admin
directory.
cd /u01/app/oracle/product/19.0.0/dbhome_1/network/admin
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.
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)
)
)