无法在centos 7上启动kafka connect作为服务

bksxznpy  于 2021-06-06  发布在  Kafka
关注(0)|答案(2)|浏览(441)

我有一个kafka环境(zookeeper+kafka服务器+kafka连接),当我在centos7上使用命令行启动每个单独的组件时,它运行得非常好。
现在我将这些kafka组件设置为作为服务运行。为此,我创建了.service文件并将其放在/etc/systemd/system文件夹中。以下是文件
Zookeeper服务


# !/bin/bash

# vi /etc/systemd/system/zookeeper.service

[Unit]
Description=This service will start Zookeeper server which will be used by Kafka Server. 
Requires=network.target remote-fs.target
After=network.target remote-fs.target

[Service]
Type=simple
ExecStart=/opt/interactcrm/kafka_2.11-1.0.1/bin/zookeeper-server-start.sh /opt/interactcrm/kafka_2.11-1.0.1/config/zookeeper.properties
ExecStop=/opt/interactcrm/kafka_2.11-1.0.1/bin/zookeeper-server-stop.sh
TimeoutStartSec=0
Restart=on-abnormal

[Install]
WantedBy=multi-user.target

Kafka服务


# !/bin/bash

# vi /etc/systemd/system/kafka.service

[Unit]
Description=This service will start Kafka server. 
Requires=zookeeper.service
After=zookeeper.service

[Service]
Type=simple
ExecStart=/opt/interactcrm/kafka_2.11-1.0.1/bin/kafka-server-start.sh /opt/interactcrm/kafka_2.11-1.0.1/config/server.properties
ExecStop=/opt/interactcrm/kafka_2.11-1.0.1/bin/kafka-server-stop.sh
TimeoutStartSec=0
Restart=on-abnormal

[Install]
WantedBy=multi-user.target

Kafka连接服务


# !/bin/bash

# vi /etc/systemd/system/kafkaconnect.service

[Unit]
Description=This service will start Kafka Connect Service. 
Requires=network.target remote-fs.target nss-lookup.target kafka.service kafka.service
After=network.target remote-fs.target nss-lookup.target kafka.service 

[Service]
Type=forking
Environment="KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10040 -Dcom.sun.management.jmxremote.local.only=true -Dcom.sun.management.jmxremote.authenticate=false"
Environment="LOG_DIR=/var/log/kafka-logs"
ExecStart=/opt/interactcrm/kafka_2.11-1.0.1/bin/connect-distributed.sh /opt/interactcrm/kafka_2.11-1.0.1/config/connect-distributed.properties
TimeoutStartSec=1000

# Restart=on-abnormal

# SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

zookeeper和kafka服务开始时没有任何问题。我可以创建主题,然后对主题执行操作。问题是Kafka连接服务。
当我尝试使用systemctl命令启动服务时,服务不会启动。它卡住了没有下面的日志:

Oct 19 18:29:20 localhost.localdomain connect-distributed.sh[1071]: [2018-10-19 18:29:20,713] INFO Added plugin 'io.debezium.connector.mysql.MySqlConnector...er:136)
Oct 19 18:29:20 localhost.localdomain connect-distributed.sh[1071]: [2018-10-19 18:29:20,713] INFO Added plugin 'io.debezium.transforms.ByLogicalTableRoute...er:136)
Oct 19 18:29:20 localhost.localdomain connect-distributed.sh[1071]: [2018-10-19 18:29:20,713] INFO Added plugin 'io.debezium.transforms.UnwrapFromEnvelope'...er:136)
Oct 19 18:29:20 localhost.localdomain connect-distributed.sh[1071]: [2018-10-19 18:29:20,761] INFO Loading plugin from: /opt/interactcrm/debezium/debezium ...er:184)
Oct 19 18:29:28 localhost.localdomain connect-distributed.sh[1071]: [2018-10-19 18:29:28,725] INFO Registered loader: PluginClassLoader{pluginLocation=file...er:207)

我在这行之后的消息日志中找不到此进程的任何日志,并且在任何其他日志中都没有错误。流程卡在这条线上:
信息注册加载器:plugincassloader{pluginlocation=file…er:207)
不管超时时间增加多少,这个过程都不会开始。但是当我从命令行运行相同的命令时,服务会正常启动。
我尝试从插件路径中删除所有连接器,以查看服务是否启动,但它卡在同一条线上。
以下是我的参考点:
Kafka连接服务

wfauudbj

wfauudbj1#

我在德宾9号也遇到了同样的问题。我想是因为服务需要 WorkingDirectory 否则Kafka永远不会完全充电。
所以你的服务应该是这样的:


# !/bin/bash

# vi /etc/systemd/system/kafkaconnect.service

[Unit]
Description=This service will start Kafka Connect Service. 
Requires=network.target remote-fs.target nss-lookup.target kafka.service kafka.service
After=network.target remote-fs.target nss-lookup.target kafka.service 

[Service]
Type=forking
Environment="KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10040 -Dcom.sun.management.jmxremote.local.only=true -Dcom.sun.management.jmxremote.authenticate=false"
Environment="LOG_DIR=/var/log/kafka-logs"
WorkingDirectory="/opt/interactcrm/kafka_2.11-1.0.1" <--- or whatever directory you to use
ExecStart=/opt/interactcrm/kafka_2.11-1.0.1/bin/connect-distributed.sh /opt/interactcrm/kafka_2.11-1.0.1/config/connect-distributed.properties
TimeoutStartSec=1000

# Restart=on-abnormal

# SuccessExitStatus=143

[Install]
WantedBy=multi-user.target
px9o7tmv

px9o7tmv2#

下面的配置在ubuntu中对我有用

[单位]
需要=Kafka服务
后=Kafka服务
[服务]
类型=简单
用户=Kafka
execstart=/bin/sh-c'/home/kafka/kafka/bin/connect-distributed.sh/home/kafka/kafka/config/connect-distributed.properties>/home/kafka/kafka/kafka\u connect.log 2>&1'
重启=异常
[安装]
wantedby=多用户.target

相关问题