Skip to main content

CDC Debezium Connector

Source Configuration Options

The Configuration is mostly related to Debezium task config, besides this we should provides the service URL of Pulsar cluster, and topic names that used to store offset and history.

task.classtruenullA source task class that implemented in Debezium.
database.hostnametruenullThe address of the Database server.
database.porttruenullThe port number of the Database server..
database.usertruenullThe name of the Database user that has the required privileges.
database.passwordtruenullThe password for the Database user that has the required privileges.
database.server.idtruenullThe connector’s identifier that must be unique within the Database cluster and similar to Database’s server-id configuration property.
database.server.nametruenullThe logical name of the Database server/cluster, which forms a namespace and is used in all the names of the Kafka topics to which the connector writes, the Kafka Connect schema names, and the namespaces of the corresponding Avro schema when the Avro Connector is used.
database.whitelistfalsenullA list of all databases hosted by this server that this connector will monitor. This is optional, and there are other properties for listing the databases and tables to include or exclude from monitoring.
key.convertertruenullThe converter provided by Kafka Connect to convert record key.
value.convertertruenullThe converter provided by Kafka Connect to convert record value.
database.historytruenullThe name of the database history class name.
database.history.pulsar.topictruenullThe name of the database history topic where the connector will write and recover DDL statements. This topic is for internal use only and should not be used by consumers.
database.history.pulsar.service.urltruenullPulsar cluster service url for history topic.
pulsar.service.urltruenullPulsar cluster service URL for the offset topic used in Debezium. You can use the bin/pulsar-admin --admin-url http://pulsar:8080 sources localrun --source-config-file configs/pg-pulsar-config.yaml command to point to the target Pulsar cluster. the last committed offsets that the connector successfully completed.

Configuration Example

Here is a configuration Json example:

"tenant": "public",
"namespace": "default",
"name": "debezium-kafka-source",
"className": "" ,
"topicName": "kafka-connect-topic",
"task.class": "io.debezium.connector.mysql.MySqlConnectorTask",
"database.hostname": "localhost",
"database.port": "3306",
"database.user": "debezium",
"database.password": "dbz",
"": "184054",
"": "dbserver1",
"database.whitelist": "inventory",
"database.history": "",
"database.history.pulsar.topic": "history-topic",
"database.history.pulsar.service.url": "pulsar://",
"key.converter": "org.apache.kafka.connect.json.JsonConverter",
"value.converter": "org.apache.kafka.connect.json.JsonConverter",
"pulsar.service.url": "pulsar://",
"": "offset-topic"
"archive": "connectors/pulsar-io-kafka-connect-adaptor-2.3.0-SNAPSHOT.nar"

You could also find the yaml example in this file, which has similar content below:

tenant: "public"
namespace: "default"
name: "debezium-kafka-source"
topicName: "kafka-connect-topic"
archive: "connectors/pulsar-io-kafka-connect-adaptor-2.3.0-SNAPSHOT.nar"

##autoAck: true
parallelism: 1

## sourceTask
task.class: "io.debezium.connector.mysql.MySqlConnectorTask"

## config for mysql, docker image: debezium/example-mysql:0.8
database.hostname: "localhost"
database.port: "3306"
database.user: "debezium"
database.password: "dbz" "184054" "dbserver1"
database.whitelist: "inventory"

database.history: ""
database.history.pulsar.topic: "history-topic"
database.history.pulsar.service.url: "pulsar://"
key.converter: "org.apache.kafka.connect.json.JsonConverter"
value.converter: "org.apache.kafka.connect.json.JsonConverter"
pulsar.service.url: "pulsar://"

Usage example

Here is a simple example to store MySQL change data using above example config.

  • Start a MySQL server with an example database, from which Debezium can capture changes.

docker run -it --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=debezium -e MYSQL_USER=mysqluser -e MYSQL_PASSWORD=mysqlpw debezium/example-mysql:0.8

  • Start a Pulsar service locally in standalone mode.

bin/pulsar standalone

  • Start pulsar debezium connector, with local run mode, and using above yaml config file. Please make sure that the nar file is available as configured in path connectors/pulsar-io-kafka-connect-adaptor-2.3.0-SNAPSHOT.nar.

bin/pulsar-admin source localrun --sourceConfigFile debezium-mysql-source-config.yaml

  • Subscribe the topic for table inventory.products.

bin/pulsar-client consume -s "sub-products" public/default/dbserver1.inventory.products -n 0

  • start a MySQL cli docker connector, and use it we could change to the table products in MySQL server.

$docker run -it --rm --name mysqlterm --link mysql --rm mysql:5.7 sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

This command will pop out MySQL cli, in this cli, we could do a change in table products, use commands below to change the name of 2 items in table products:

mysql> use inventory;
mysql> show tables;
mysql> SELECT * FROM products ;
mysql> UPDATE products SET name='1111111111' WHERE id=101;
mysql> UPDATE products SET name='1111111111' WHERE id=107;

  • In above subscribe topic terminal tab, we could find that 2 changes has been kept into products topic.


Debezium postgres connector will hang when create snap

#18 prio=5 os_prio=31 tid=0x00007fd83096f800 nid=0xa403 waiting on condition [0x000070000f534000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007ab025a58> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(
at java.util.concurrent.LinkedBlockingDeque.putLast(
at java.util.concurrent.LinkedBlockingDeque.put(
at io.debezium.connector.base.ChangeEventQueue.enqueue(
at io.debezium.connector.postgresql.PostgresConnectorTask$Lambda$203/385424085.accept(Unknown Source)
at io.debezium.connector.postgresql.RecordsSnapshotProducer.sendCurrentRecord(
at io.debezium.connector.postgresql.RecordsSnapshotProducer.readTable(
at io.debezium.connector.postgresql.RecordsSnapshotProducer.lambda$takeSnapshot$6(
at io.debezium.connector.postgresql.RecordsSnapshotProducer$Lambda$240/1347039967.accept(Unknown Source)
at io.debezium.jdbc.JdbcConnection.queryWithBlockingConsumer(
at io.debezium.connector.postgresql.RecordsSnapshotProducer.takeSnapshot(
at io.debezium.connector.postgresql.RecordsSnapshotProducer.lambda$start$0(
at io.debezium.connector.postgresql.RecordsSnapshotProducer$Lambda$206/ Source)
at java.util.concurrent.CompletableFuture.uniRun(
at java.util.concurrent.CompletableFuture.uniRunStage(
at java.util.concurrent.CompletableFuture.thenRun(
at io.debezium.connector.postgresql.RecordsSnapshotProducer.start(
at io.debezium.connector.postgresql.PostgresConnectorTask.start(
at io.debezium.connector.common.BaseSourceTask.start(
at org.apache.pulsar.functions.instance.JavaInstanceRunnable.setupInput(
at org.apache.pulsar.functions.instance.JavaInstanceRunnable.setupJavaInstance(

If you encounter the above problems in synchronizing data, please refer to this and add the following configuration to the configuration file: