输入'CREATE TABLE没有可行的替代方案

Posted

技术标签:

【中文标题】输入\'CREATE TABLE没有可行的替代方案【英文标题】:no viable alternative at input 'CREATE TABLE输入'CREATE TABLE没有可行的替代方案 【发布时间】:2021-01-30 00:13:21 【问题描述】:

我无法使用以下命令添加 mysql 连接器:

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"   '

连接日志显示错误:

Caused by: io.debezium.text.ParsingException: no viable alternative at input 'CREATE TABLE `user_account` (\n  `id` bigint(20) unsigned NOT NULL DEFAULT nextval'

这是表定义:

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

完整的撰写文件:

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

在启动堆栈之前,数据卷被清空:

sudo rm -fr volumes/kafka/data/*

我的 MariaDB 服务器版本:

MariaDB [useraccount]> SELECT VERSION(); 
+---------------------+
| VERSION()           |
+---------------------+
| 10.3.12-MariaDB-log |
+---------------------+
1 row in set (0.000 sec)

Connect 库版本:

[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】:

Debezium MySQL 解析器不支持此功能。您能否在 Debezium Jira 中提出问题,以便扩展语法?

【讨论】:

请问哪个功能不支持?你会分享它的名字吗? 我认为 JDBC 正在完成与 SQL 对话的工作。一周前,它在同一个数据库和表实例上与 Streamsets 一样工作,在该表上运行带有 CDC 的管道。我很惊讶 CREATE TABLE 语句是一个问题。 nextval - Debezium 需要自己解析以获取有关数据库架构的信息 我找不到问题列表的 url。非常遗憾。你会有吗?谢谢。 这是记录的问题issues.redhat.com/browse/DBZ-2671

以上是关于输入'CREATE TABLE没有可行的替代方案的主要内容,如果未能解决你的问题,请参考以下文章

SiddhiQL 中的语法错误,输入时没有可行的替代方案

ParseExpection:输入时没有可行的替代方案

在 cassandra 中输入“>”没有可行的替代方案

房间数据库 - 查询错误作为输入时没有可行的替代方案

Spark SQL 嵌套 JSON 错误“输入时没有可行的替代方案”

如何修复 Javadoc 注释有解析错误,详细信息:在解析 JAVADOC_TAG [NonEmptyAtClauseDescription] 时输入“*”没有可行的替代方案