1)我们有3个节点的kafka和kafka连接集群
2)我们仅在分布式模式下在kafka节点上运行kafka-connect
3)当我尝试使用以下配置创建连接器时:
{
"name": "connector-state-0",
"config": {
"connector.class": "io.debezium.connector.mysql.MySqlConnector",
"database.user": "user",
"database.server.id": "5023",
"database.hostname": "hostname",
"database.password": "password",
"database.history.kafka.bootstrap.servers": "ip:9092",
"database.history.kafka.topic": "topicname",
"database.server.name": "prod",
"database.port": "3306",
"snapshot.mode": "when_needed",
"include.schema.changes": "false",
"table.whitelist": "country.state"
}
}
关于创建连接器的请求,它在3个节点中的2个上给我以下错误:
{"error_code":409,"message":"Cannot complete request because of a conflicting operation (e.g. worker rebalance)"}
在其中一个节点上:我能够创建连接器,但任务未启动,并且我可以在日志中看到以下错误:
[2019-01-23 10:50:06,455] INFO 127.0.0.1 - - [23/Jan/2019:10:50:06 +0000] "POST /connectors/birdeye-connector-state-0/tasks?forward=true HTTP/1.1" 409 113 8 (org.apache.kafka.connect.runtime.rest.RestServer:60)
[2019-01-23 10:50:06,462] INFO 127.0.0.1 - - [23/Jan/2019:10:50:06 +0000] "POST /connectors/birdeye-connector-state-0/tasks HTTP/1.1" 409 113 21 (org.apache.kafka.connect.runtime.rest.RestServer:60)
[2019-01-23 10:50:06,466] ERROR Request to leader to reconfigure connector tasks failed (org.apache.kafka.connect.runtime.distributed.DistributedHerder:1020)
org.apache.kafka.connect.runtime.rest.errors.ConnectRestException: Cannot complete request because of a conflicting operation (e.g. worker rebalance)
at org.apache.kafka.connect.runtime.rest.RestClient.httpRequest(RestClient.java:97)
at org.apache.kafka.connect.runtime.distributed.DistributedHerder$18.run(DistributedHerder.java:1017)
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)
我无法弄清楚是什么引起了问题。
答案 0 :(得分:0)
您需要将rest.advertised.host.name
设置为其他Kafka Connect工作者可以解析并连接到的主机或IP。这是因为它用于工人之间的内部通信。
如果您的REST请求遇到了不是集群的当前领导者的工作器 ,那么该工作器将尝试将请求转发给领导者。它使用rest.advertised.host.name
完成此操作。但是如果rest.advertised.host.name
是localhost
,那么工作人员将只是将请求转发给自己,因此事情将无法进行。在您的三名工人中,一位将成为领导者,这就是为什么您发现三分之二的工人失败。
有关更多详细信息,请参见https://rmoff.net/2019/11/22/common-mistakes-made-when-configuring-multiple-kafka-connect-workers/