无法使用REST API创建kafka连接器

时间:2019-09-26 06:20:30

标签: apache-kafka apache-kafka-connect

我正在尝试以分布式模式运行Kafka工人。与独立模式不同,在以分布式模式启动工作线程时,我们无法传递连接器属性文件。在分布式模式下,工作程序是单独启动的,我们使用REST API在这些工作程序上部署和管理连接器

参考链接-https://docs.confluent.io/current/connect/managing/configuring.html#connect-managing-distributed-mode

我尝试通过在curl命令中传递以下值来构建连接器并执行

curl -X POST -H "Content-Type: application/json" --data '{"name":"sailpointdb","connector.class":"io.confluent.connect.jdbc.JdbcSourceConnector","tasks.max":"1","connection.password " : " abc","connection.url " : "jdbc:mysql://localhost:3306/db","connection.user " : "abc" ,"query" : " SELECT * FROM (SELECT NAME, FROM_UNIXTIME(completed/1000) AS 
TASKFAILEDON FROM abc WHERE COMPLETION_STATUS = 'Error') as A","mode" : " timestamp","timestamp.column.name" : "TASKFAILEDON","topic.prefix" : "dbevents","validate.non.null" : "false" }}' http://localhost:8089/connectors/

我遇到以下错误-卷曲:(3)使用错误/非法格式的URL或缺少URL

请让我知道以上curl声明出了什么问题,我在这里错过了什么吗?

1 个答案:

答案 0 :(得分:1)

  1. 您的JSON中有一个多余的右花括号,这无济于事
  2. 如果您要POST/connectors,则需要nameconfig根级元素。但是,我建议使用PUT /config,因为如果需要您可以重新运行它以更新配置

尝试一下:

curl -X PUT -H  "Content-Type:application/json" \
      http://localhost:8089/connectors/source-jdbc-sailpointdb-00/config \
      -d '{
        "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
        "tasks.max": "1",
        "connection.password ": " abc",
        "connection.url ": "jdbc:mysql://localhost:3306/db",
        "connection.user ": "abc",
        "query": " SELECT * FROM (SELECT NAME, FROM_UNIXTIME(completed/1000) AS TASKFAILEDON FROM abc WHERE COMPLETION_STATUS = 'Error') as A",
        "mode": " timestamp",
        "timestamp.column.name": "TASKFAILEDON",
        "topic.prefix": "dbevents",
        "validate.non.null": "false"
    }'