使用 kafka connect rest api 设置 mirror maker 2 不允许放置方法

Setting mirror maker 2 using kafka connect rest api put method not allowed

我正在尝试使用我当前的连接集群为 mirror maker 2 进行设置。 根据此文档,可以通过 connect rest api.

完成

https://cwiki.apache.org/confluence/display/KAFKA/KIP-382%3A+MirrorMaker+2.0#KIP-382:MirrorMaker2.0-RunningMirrorMakerinaConnectcluster

我按照示例发送了这个 PUT 请求:

PUT /connectors/us-west-source/config HTTP/1.1

{
    "name": "us-west-source",
    "connector.class": "org.apache.kafka.connect.mirror.MirrorSourceConnector",
    "source.cluster.alias": "us-west",
    "target.cluster.alias": "us-east",
    "source.cluster.bootstrap.servers": "us-west-host1:9091",
    "topics": ".*"
}

但是我得到一个方法不允许的响应错误响应。

{
  "error_code": 405,
  "message": "HTTP 405 Method Not Allowed"
}

如果我从 / 执行简单的 GET,返回版本 api,那么 api 看起来没问题

{
  "version": "2.1.0-cp1",
  "commit": "bda8715f42a1a3db",
  "kafka_cluster_id": "VBo-j1OAQZSN8tO4lMJ0Gg"
}

PUT 方法不起作用,使用 POST 有效,如 api 的文档所示: https://docs.confluent.io/current/connect/references/restapi.html#get--connectors

按照@cricket_007的建议从url中删除连接器的名称,并用新元素包装配置,如下所示:

curl --noproxy "*" -XPOST -H 'Content-Type: application/json' -H 'Accept: application/json' http://localhost:8083/connectors -d'{
    "name": "dc-west-source",
    "config": {
    "connector.class": "org.apache.kafka.connect.mirror.MirrorSourceConnector",
    "source.cluster.alias": "dc-west",
    "target.cluster.alias": "dc-east",
    "source.cluster.bootstrap.servers": "dc-west-cp-kafka-0.domain:32721,dc-west-cp-kafka-1.domain:32722,dc-west-cp-kafka-2.dc.domain:32723",
    "topics": ".*" 
    }
}
' | jq .