Problem running Kafka Distributed as a service

We use Confluent Cloud with and external VM to run our 3rd party connectors.
Starting the connect-distributed from the command line is no problem. But when I try to set it up as service using confluent-kafka-connect.service

[Unit]
Description=Apache Kafka Connect - distributed
Documentation=http://docs.confluent.io/
After=network.target

[Service]
Type=simple
User=AdminUser
Group=confluent
ExecStart=/usr/bin/connect-distributed /etc/kafka/kafka-connect-distributed.properties
TimeoutStopSec=180
Restart=no

[Install]
WantedBy=multi-user.target

I see the following error in journalctl

WARN [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available. (org.apache.kafka.clients.NetworkClient:796)

I have no idea why this error appears.

Any help would be appreciated.

seems as your distributed connect cluser tries to connect to localhost.

my understanding is that your brokers are in confluent cloud?

1 Like

Yes, if you’re using Confluent Cloud you need to amend /etc/kafka/kafka-connect-distributed.properties to include the correct broker details per the documentation.

Robin,

Yes, we use Confluent Cloud with on-prem Workers due to the fact that we use 3rd party connectors.

That is what I have been using and it works when I start it from the command line
(e.g. ./bin/connect-distributed ./etc/my-connect-distributed.properties).
The only difference is that I commented out the consumer. section as these VM’s only run producer connectors.

So it works from the command line but not when trying to use it as a service.

Raoul

I would re-enable the consumer section.
Kafka Connect is also a consumer from the internal topics that it uses to store and fetch connector configuration, offsets, status, etc.

Robin,

I have made that change and also double checked the permissions on the properties file. But no luck. Still the same error when trying to start the confluent-Kafka-connect service.
And again, running it from the command line, no problem.

Raoul

All,

Well I think I found a work around. The problem was that if you run it from the command line the process will stop when you close the connection to the VM (Linux machine).
But when you start /bin/connect-distributed without any parameters, it comes back with:
USAGE: /usr/bin/connect-distributed [-daemon] connect-distributed.properties

So I tried to include the command -daemon and this seems to work to push the worker to the background and am able to close the terminal window without halting the process.

Might be worth to include this in the documentation as the -daemon parameter is nowhere discussed.

Thank you again for trying to help and the quick responses. Really appreciate it.

Raoul.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.