【问题标题】:Kafka connect Jdbc source connector data is stored as encoded stringKafka connect Jdbc 源连接器数据存储为编码字符串
【发布时间】:2019-12-16 00:54:48
【问题描述】:

我是 kafka 的新手,正在探索分布式模式下的 kafka connect。我有一些我在下面列出的问题。

  1. 我的 oracle 表中的数据存储为字符串中的编码值。 (例如,我的一个整数列的值为 60015 存储为“AN+w”)。

  2. 如果我在工作人员配置中使用 AVRO 转换器,kafka 连接会抛出错误“无效的十进制小数位数 127(大于精度 64)”。

下面是我的配置:

工人配置:

##
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##

# This file contains some of the configurations for the Kafka Connect distributed worker. This file is intended
# to be used with the examples, and some settings may differ from those used in a production system, especially
# the `bootstrap.servers` and those specifying replication factors.

# A list of host/port pairs to use for establishing the initial connection to the Kafka cluster.
bootstrap.servers=192.168.220.128:9092

# unique name for the cluster, used in forming the Connect cluster group. Note that this must not conflict with consumer group IDs
group.id=my-example-connect-cluster

# The converters specify the format of data in Kafka and how to translate it into Connect data. Every Connect user will
# need to configure these based on the format they want their data in when loaded from or stored into Kafka
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
# Converter-specific settings can be passed in by prefixing the Converter's setting with the converter we want to apply
# it to
key.converter.schemas.enable=true
value.converter.schemas.enable=false

# Topic to use for storing offsets. This topic should have many partitions and be replicated and compacted.
# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
# the topic before starting Kafka Connect if a specific topic configuration is needed.
# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
offset.storage.topic=connect-offsets-dm
offset.storage.replication.factor=1
#offset.storage.partitions=25

# Topic to use for storing connector and task configurations; note that this should be a single partition, highly replicated,
# and compacted topic. Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
# the topic before starting Kafka Connect if a specific topic configuration is needed.
# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
config.storage.topic=connect-configs-dm
config.storage.replication.factor=1

# Topic to use for storing statuses. This topic can have multiple partitions and should be replicated and compacted.
# Kafka Connect will attempt to create the topic automatically when needed, but you can always manually create
# the topic before starting Kafka Connect if a specific topic configuration is needed.
# Most users will want to use the built-in default replication factor of 3 or in some cases even specify a larger value.
# Since this means there must be at least as many brokers as the maximum replication factor used, we'd like to be able
# to run this example on a single-broker cluster and so here we instead set the replication factor to 1.
status.storage.topic=connect-status-dm
status.storage.replication.factor=1
#status.storage.partitions=5

# Flush much faster than normal, which is useful for testing/debugging
offset.flush.interval.ms=10000

# These are provided to inform the user about the presence of the REST host and port configs 
# Hostname & Port for the REST API to listen on. If this is set, it will bind to the interface used to listen to requests.
#rest.host.name=
rest.port=8083

# The Hostname & Port that will be given out to other workers to connect to i.e. URLs that are routable from other servers.
#rest.advertised.host.name=
#rest.advertised.port=

# Set to a list of filesystem paths separated by commas (,) to enable class loading isolation for plugins
# (connectors, converters, transformations). The list should consist of top level directories that include 
# any combination of: 
# a) directories immediately containing jars with plugins and their dependencies
# b) uber-jars with plugins and their dependencies
# c) directories immediately containing the package directory structure of classes of plugins and their dependencies
# Examples: 
# plugin.path=/usr/local/share/java,/usr/local/share/kafka/plugins,/opt/connectors,
plugin.path=/home/bjanakiraman/Desktop/confluent-5.3.0/share/java
connect_plugin_path=/home/bjanakiraman/Desktop/confluent-5.3.0/share/java/kafka-connect-jdbc

连接配置:

{
    "name": "test-oracle-jdbc-connector",
    "config": {
        "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
        "tasks.max": "1",
        "connection.url": "MY-URL",
        "connection.user": "username",
        "connection.password": "password",
        "mode": "incrementing",
        "incrementing.column.name": "ID",
        "topic.prefix": "test2-",
        "name": "test-oracle-jdbc-connector",
        "schema.pattern": "ABC",
        "table.whitelist" : "TABLENAME"
    }
}

以下是我在连接器中使用 AVRO 转换器时出现的完整日志错误:

org.apache.kafka.connect.errors.ConnectException: Tolerance exceeded in error handler
    at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:178)
    at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execute(RetryWithToleranceOperator.java:104)
    at org.apache.kafka.connect.runtime.WorkerSourceTask.convertTransformedRecord(WorkerSourceTask.java:270)
    at org.apache.kafka.connect.runtime.WorkerSourceTask.sendRecords(WorkerSourceTask.java:294)
    at org.apache.kafka.connect.runtime.WorkerSourceTask.execute(WorkerSourceTask.java:229)
    at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:177)
    at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:227)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Invalid decimal scale: 127 (greater than precision: 64)
    at org.apache.avro.LogicalTypes$Decimal.validate(LogicalTypes.java:217)
    at org.apache.avro.LogicalType.addToSchema(LogicalType.java:70)
    at org.apache.avro.LogicalTypes$Decimal.addToSchema(LogicalTypes.java:182)
    at io.confluent.connect.avro.AvroData.fromConnectSchema(AvroData.java:944)
    at io.confluent.connect.avro.AvroData.addAvroRecordField(AvroData.java:1059)
    at io.confluent.connect.avro.AvroData.fromConnectSchema(AvroData.java:900)
    at io.confluent.connect.avro.AvroData.fromConnectSchema(AvroData.java:732)
    at io.confluent.connect.avro.AvroData.fromConnectSchema(AvroData.java:726)
    at io.confluent.connect.avro.AvroData.fromConnectData(AvroData.java:365)
    at io.confluent.connect.avro.AvroConverter.fromConnectData(AvroConverter.java:80)
    at org.apache.kafka.connect.runtime.WorkerSourceTask.lambda$convertTransformedRecord$2(WorkerSourceTask.java:270)
    at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndRetry(RetryWithToleranceOperator.java:128)
    at org.apache.kafka.connect.runtime.errors.RetryWithToleranceOperator.execAndHandleError(RetryWithToleranceOperator.java:162)
    ... 11 more

请帮我解决这个问题。

【问题讨论】:

    标签: apache-kafka kafka-consumer-api apache-kafka-connect kafka-producer-api


    【解决方案1】:

    检查您是否有任何 NUMBER 类型的列,但未定义任何精度或小数位数。我通过将列数据类型更改为 INTEGER 的 NUMBER(38,0) 解决了这个问题

    【讨论】:

      猜你喜欢
      • 2020-01-15
      • 2019-06-17
      • 2019-05-17
      • 2017-10-12
      • 2020-08-05
      • 2021-12-19
      • 2018-09-01
      • 2020-07-31
      • 2018-02-06
      相关资源
      最近更新 更多