运行pubsub kafka连接器独立模式问题

时间:2017-08-24 15:39:16

标签: google-cloud-pubsub apache-kafka-connect

所以,我一直试图让PubSub Kafka连接器运行大约一个月,现在遇到各种各样的问题。我在这里回顾了很多关于Kafka Connect和Pubsub连接器的问题,这些问题帮助我走了很远但我再次陷入困境。当我运行此命令时:

.\bin\windows\connect-standalone.bat 
.\etc\kafka\WorkerConfig.properties .\etc\kafka\configSink.properties .\etc\kafka\configSource.properties

我收到了很长的错误列表here

在尝试启动其余服务器之后,就是错误"无法扫描文件[文件名] ..."开始。我不确定是否需要设置rest.host.name和rest.port,因为目前,对于standaloneConfig值,它读取

rest.host.name = null

编辑:在查看日志文件一段时间后,我发现了以下消息:

Kafka consumer created
Created connector CPSConnector
Initializing task CPSConnector-0 with config {connector.class=com.google.pubsub.kafka.sink.CloudPubSubSinkConnector, task.class=com.google.pubsub.kafka.sink.CloudPubSubSinkTask, tasks.max=1, topics=, cps.project=kohls-sis-sandbox, name=CPSConnector, cps.topic=test-pubsub}
Task CPSConnector-0 threw an uncaught and unrecoverable exception
org.apache.kafka.connect.errors.ConnectException: Sink tasks require a list of topics.
    at org.apache.kafka.connect.runtime.WorkerSinkTask.initializeAndStart(WorkerSinkTask.java:202)
    at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:139)
    at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:140)
    at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:175)
    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:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

编辑:所以,我通过在我的configSink中添加topics=test来解决上述问题。当前的错误消息如下。这是否表示您只能运行接收器连接器或源连接器?

Failed to create job for .\etc\kafka\configSource.properties
Stopping after connector error
java.util.concurrent.ExecutionException: org.apache.kafka.connect.errors.AlreadyExistsException: Connector CPSConnector already exists
    at org.apache.kafka.connect.util.ConvertingFutureCallback.result(ConvertingFutureCallback.java:80)
    at org.apache.kafka.connect.util.ConvertingFutureCallback.get(ConvertingFutureCallback.java:67)
    at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:97)
Caused by: org.apache.kafka.connect.errors.AlreadyExistsException: Connector CPSConnector already exists
    at org.apache.kafka.connect.runtime.standalone.StandaloneHerder.putConnectorConfig(StandaloneHerder.java:145)
    at org.apache.kafka.connect.cli.ConnectStandalone.main(ConnectStandalone.java:94)

在我的WorkerConfig.properites中,我有bootstrap.servers=localhost:2181。我的属性文件是here

我不确定如何解决,因为我设置了属性文件,确保cps-kakfa-connector.jar在类路径中。我还设置了plugin.path=\share\java\kafka\kafka-connect-pubsub

如果有人能指出我正确的方向来解决这个问题,那就太好了。我按照这里的指示:https://github.com/GoogleCloudPlatform/pubsub/tree/master/kafka-connector

1 个答案:

答案 0 :(得分:2)

当您将配置属性提交给Kafka Connect群集或独立工作线程时,每个Connector实例(无论是源还是接收器)都需要具有唯一名称。

在上面的示例中,只需将您的Source命名为与您的接收器不同。 例如:

$ head -n 1 configSource.properties
name=CPSSourceConnector
$ head -n 1 configSink.properties
name=CPSSinkConnector

或者,不妨:

$ head -n 1 configSource.properties
name=Tom
$ head -n 1 configSink.properties
name=Jerry