问题
I can't add a MySQL connector with the command:
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" localhost:8083/connectors/ -d '{ "name": "useraccount-connector", "config": { "connector.class": "io.debezium.connector.mysql.MySqlConnector", "tasks.max": "1", "database.hostname": "mysql", "database.port": "3306", "database.user": "debezium", "database.password": "dbz", "database.server.id": "1234", "database.server.name": "mylocaldb", "database.whitelist": "useraccount", "database.history.kafka.bootstrap.servers": "kafka:9092", "database.history.kafka.topic": "schema-changes.useraccount" } }'
The connect log shows the error:
Caused by: io.debezium.text.ParsingException: no viable alternative at input 'CREATE TABLE `user_account` (\n `id` bigint(20) unsigned NOT NULL DEFAULT nextval'
Here is the table definition:
CREATE TABLE `user_account` (
`id` bigint(20) unsigned NOT NULL DEFAULT nextval(`useraccount`.`user_account_id_seq`),
`version` int(10) unsigned NOT NULL,
`created_on` datetime DEFAULT NULL,
`updated_on` datetime DEFAULT NULL,
`firstname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`lastname` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`password` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`password_salt` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`readable_password` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`email` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
`confirmed_email` bit(1) NOT NULL CHECK (`confirmed_email` in (0,1)),
`work_phone` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
The complete compose file:
version: "3.7"
services:
zookeeper:
image: debezium/zookeeper:1.2
ports:
- "2181:2181"
- "2888:2888"
- "3888:3888"
networks:
common:
volumes:
- "~/dev/docker/projects/debezium/volumes/zookeeper/data:/zookeeper/data"
- "~/dev/docker/projects/debezium/volumes/zookeeper/txns:/zookeeper/txns"
- "~/dev/docker/projects/debezium/volumes/zookeeper/conf:/zookeeper/conf"
- "~/dev/docker/projects/debezium/volumes/zookeeper/logs:/zookeeper/logs"
environment:
HOST_USER_ID: ${CURRENT_UID}
HOST_GROUP_ID: ${CURRENT_GID}
deploy:
resources:
limits:
cpus: "0.1"
memory: 256M
replicas: 1
restart_policy:
condition: any
delay: 5s
max_attempts: 3
window: 10s
kafka:
image: debezium/kafka:1.2
ports:
- "9092:9092"
networks:
common:
volumes:
- "~/dev/docker/projects/debezium/volumes/kafka/data:/kafka/data"
- "~/dev/docker/projects/debezium/volumes/kafka/logs:/kafka/logs"
environment:
ZOOKEEPER_CONNECT: zookeeper:2181
HOST_USER_ID: ${CURRENT_UID}
HOST_GROUP_ID: ${CURRENT_GID}
depends_on:
- zookeeper
deploy:
replicas: 1
restart_policy:
condition: any
delay: 5s
max_attempts: 3
window: 10s
connect:
image: debezium/connect:1.2
ports:
- "8083:8083"
- "5005:5005"
networks:
common:
volumes:
- "~/dev/docker/projects/debezium/volumes/connect/logs:/kafka/logs"
- "~/dev/docker/projects/debezium/volumes/connect/config:/kafka/config"
environment:
ZOOKEEPER_CONNECT: zookeeper:2181
BOOTSTRAP_SERVERS: kafka:9092
GROUP_ID: 1
CONFIG_STORAGE_TOPIC: my_connect_configs
OFFSET_STORAGE_TOPIC: my_connect_offsets
STATUS_STORAGE_TOPIC: my_connect_statuses
HOST_USER_ID: ${CURRENT_UID}
HOST_GROUP_ID: ${CURRENT_GID}
depends_on:
- kafka
deploy:
replicas: 1
restart_policy:
condition: any
delay: 5s
max_attempts: 3
window: 10s
networks:
common:
external: true
name: common
Before starting the stack the data volumes is emptied:
sudo rm -fr volumes/kafka/data/*
My MariaDB server version:
MariaDB [useraccount]> SELECT VERSION();
+---------------------+
| VERSION() |
+---------------------+
| 10.3.12-MariaDB-log |
+---------------------+
1 row in set (0.000 sec)
The Connect libraries version:
[kafka@39162ffb47f1 ~]$ ll connect/debezium-connector-mysql/
total 10820
-rw-r--r-- 1 kafka kafka 337904 Sep 24 05:52 antlr4-runtime-4.7.2.jar
-rw-r--r-- 1 kafka kafka 19653 Sep 24 06:34 debezium-api-1.2.5.Final.jar
-rw-r--r-- 1 kafka kafka 255757 Sep 24 06:36 debezium-connector-mysql-1.2.5.Final.jar
-rw-r--r-- 1 kafka kafka 827663 Sep 24 06:35 debezium-core-1.2.5.Final.jar
-rw-r--r-- 1 kafka kafka 2703943 Sep 24 06:35 debezium-ddl-parser-1.2.5.Final.jar
-rw-r--r-- 1 kafka kafka 173228 Sep 24 05:54 mysql-binlog-connector-java-0.20.1.jar
-rw-r--r-- 1 kafka kafka 2293144 Sep 24 05:54 mysql-connector-java-8.0.16.jar
回答1:
this funtion is not supported by Debezium MySQL parser. Could you please raise an issue in Debezium Jira so the grammar is extended?
来源:https://stackoverflow.com/questions/64372783/no-viable-alternative-at-input-create-table