首页 > 解决方案 > Confluent Kafka Connect - JdbcSourceTask:java.sql.SQLException:Java 堆空间

问题描述

我正在尝试将模式时间戳与 mysql 一起使用,但是当我这样做时它不会在我的 kafka 队列中创建任何主题,并且也没有错误日志。

这是我正在使用的连接器属性,

{
        "name": "jdbc_source_mysql_reqistrations_local",
        "config": {
                 "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
                 "key.converter": "io.confluent.connect.avro.AvroConverter",
                 "key.converter.schema.registry.url": "http://localhost:8081",
                 "value.converter": "io.confluent.connect.avro.AvroConverter",
                 "value.converter.schema.registry.url": "http://localhost:8081",
                 "tasks.max": "5",
                 "connection.url": "jdbc:mysql://localhost:3306/prokafka?zeroDateTimeBehavior=ROUND&user=kotesh&password=kotesh",
                 "poll.interval.ms":"100000000",
                 "query": "SELECT Language, matriid, DateUpdated from usersdata.user",
                 "mode": "timestamp",
                 "timestamp.column.name": "DateUpdated",
                 "validate.non.null": "false",
                 "batch.max.rows":"10",
                 "topic.prefix": "mysql-local-"
        }
}

发射:

./bin/confluent load jdbc_source_mysql_registration_local -d /home/prokafka/config-json/kafka-connect-jdbc-local-mysql.json



{
  "name": "jdbc_source_mysql_reqistrations_local",
  "config": {
    "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
    "key.converter": "io.confluent.connect.avro.AvroConverter",
    "key.converter.schema.registry.url": "http://localhost:8081",
    "value.converter": "io.confluent.connect.avro.AvroConverter",
    "value.converter.schema.registry.url": "http://localhost:8081",
    "tasks.max": "5",
    "connection.url": "jdbc:mysql://localhost:3306/prokafka?zeroDateTimeBehavior=ROUND&user=kotesh&password=kotesh",
    "poll.interval.ms": "100000000",
    "query": "SELECT Language, matriid, DateUpdated from usersdata.users",
    "mode": "timestamp",
    "timestamp.column.name": "DateUpdated",
    "validate.non.null": "false",
    "batch.max.rows": "10",
    "topic.prefix": "mysql-local-",
    "name": "jdbc_source_mysql_reqistrations_local"
  },
  "tasks": [
    {
      "connector": "jdbc_source_mysql_reqistrations_local",
      "task": 0
    }
  ],
  "type": null
}

标签: jdbcapache-kafkaapache-kafka-connectconfluent-platform

解决方案


SQLException: Java 堆空间

似乎您加载了太多数据以供 Connect 处理,并且必须增加堆大小

例如,将其增加到 6GB(或更多)

我没有尝试使用 Confluent CLI 来执行此操作,但根据代码,这可能有效

confluent stop connect 
export CONNECT_KAFKA_HEAP_OPTS="-Xmx6g"
confluent start connect

如果您在这台机器上的内存有限,则将 Connect 与您的 Mysql 数据库、Kafka 代理、Zookeeper、Schema Registry 等分开运行。


推荐阅读