Skip to content

What about Oracle RAC?

averemee-si edited this page Sep 6, 2022 · 9 revisions
  • This is problem?
  • No.

Let's imagine you have an Oracle RAC database with service name ORCL with 4 instances: INST1, INST2, INST3, and INST4 and see how to run CDC in Oracle RAC environment. This is possible in three ways.

1. Manual configuration with producing data to different Kafka topics

Starting from oracdc version 1.1.0, after connecting to an Oracle Database instance, oracdc executes a query against V$INSTANCE dynamic performance views and reads value of this instance redo thread from THREAD# column

select VERSION, INSTANCE_NUMBER, INSTANCE_NAME, HOST_NAME, THREAD#,
       (select nvl(CPU_CORE_COUNT_CURRENT, CPU_COUNT_CURRENT) from V$LICENSE) CPU_CORE_COUNT_CURRENT
from   V$INSTANCE;

Then only archived redo which belongs to this thread is processed. In this case for our 4-node RAC you need to create 4 connectors with a2.jdbc.url pointing to specific instance (for more information about Oracle JDBC URL please visit Oracle® Database JDBC Java API Reference, Release 21c), and unique value for a2.topic.prefix for each connector. Below is example configuration for connector for INST1

{
    "name": "oracdc_ORCL_INST1",
    "config": {
        "connector.class" : "solutions.a2.cdc.oracle.OraCdcLogMinerConnector",
        "a2.jdbc.url" : "jdbc:oracle:thin:@//RAC-SCAN:1521/ORCL/INST1",
        "a2.jdbc.username" : "C##ORACDC",
        "a2.jdbc.password" : "c##oracdc",
        "a2.include" : "SCOTT.DEPT,SCOTT.EMP",
        "a2.topic.prefix" : "INST1"
    }
}

Pros

  1. Easy as 1-2-3

Cons

  1. equals to number of connector instances
  2. equals to number of topics per table
  3. Multiple topics for Kafka Connect Sink Connectors/Apache Kafka Consumers

2. Manual configuration with producing data to same topic but different topic partition

In oracdc version 1.2.0 a new parameter has been added a2.topic.partition which defines a partition in Apache Kafka topic for writing messages by oracdc with default value 0. Before using this method please ensure that Apache Kafka parameter num.partitions is set to appropriate value if you using topic auto creation in Kafka Connect (i.e. Kafka Connect parameter topic.creation.enable is set to true). Or pre-create required topics using kafka-topics CLI with required number of partitions. As with the previous case 1 above, you need to provide a2.jdbc.url pointing to a specific instance. Below is example configuration for connector for INST1

{
    "name": "oracdc_ORCL_INST1",
    "config": {
        "connector.class" : "solutions.a2.cdc.oracle.OraCdcLogMinerConnector",
        "a2.jdbc.url" : "jdbc:oracle:thin:@//RAC-SCAN:1521/ORCL/INST1",
        "a2.jdbc.username" : "C##ORACDC",
        "a2.jdbc.password" : "c##oracdc",
        "a2.include" : "SCOTT.DEPT,SCOTT.EMP",
        "a2.topic.partition" : "0"
    }
}

Pros

  1. One topic per table with multiple partitions

Cons

  1. equals to number of connector instances

3. Automatic configuration with producing data same topic but different topic partition

In oracdc version 1.2.0 a new parameter has been added a2.use.rac with false as default value. When value of this parameter is set to true oracdc during initialisation detect available Oracle RAC database instances using following query

select I$.INSTANCE_NAME
from   V$ACTIVE_INSTANCES A$, GV$INSTANCE I$
where  A$.INST_NUMBER = I$.INSTANCE_NUMBER

and if this query return rows oracdc starts multiple Kafka Connect tasks (one task per Oracle RAC instance) and pass to every task unique URL for connecting to specific RAC instance. Before using this method please ensure that Apache Kafka parameter num.partitions is set to appropriate value if you using topic auto creation in Kafka Connect (i.e. Kafka Connect parameter topic.creation.enable is set to true). Or pre-create required topics using kafka-topics CLI with required number of partitions. Also you must set tasks.max parameter to or a value equal to or greater than the number of Oracle RAC instances. Example configuration is below:

{
    "name": "oracdc_ORCL_INST1",
    "config": {
        "connector.class" : "solutions.a2.cdc.oracle.OraCdcLogMinerConnector",
        "a2.jdbc.url" : "jdbc:oracle:thin:@//RAC-SCAN:1521/ORCL",
        "a2.jdbc.username" : "C##ORACDC",
        "a2.jdbc.password" : "c##oracdc",
        "a2.include" : "SCOTT.DEPT,SCOTT.EMP",
        "a2.use.rac" : "true",
        "tasks.max" : "4"
    }
}

Pros

  1. One topic per table with multiple partitions
  2. One connector instance with multiple tasks