Apache kafka 无法在CentOS 7上启动Kafka Connect作为服务

Apache kafka 无法在CentOS 7上启动Kafka Connect作为服务,apache-kafka,centos7,apache-zookeeper,systemd,apache-kafka-connect,Apache Kafka,Centos7,Apache Zookeeper,Systemd,Apache Kafka Connect,我有一个卡夫卡环境(Zookeeper+卡夫卡服务器+卡夫卡连接),当我在CentOS 7上使用命令行启动每个单独的组件时,它可以完美地运行 现在,我将这些Kafka组件设置为作为服务运行。为此,我创建了.service文件并将其放置在/etc/systemd/system文件夹中。以下是文件 动物园管理员服务 #!/bin/bash # vi /etc/systemd/system/zookeeper.service [Unit] Description=This service will s

我有一个卡夫卡环境(Zookeeper+卡夫卡服务器+卡夫卡连接),当我在CentOS 7上使用命令行启动每个单独的组件时,它可以完美地运行

现在,我将这些Kafka组件设置为作为服务运行。为此,我创建了.service文件并将其放置在/etc/systemd/system文件夹中。以下是文件

动物园管理员服务

#!/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
#!/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
#!/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
kafka.service

#!/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
#!/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
#!/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
卡夫卡连接服务

#!/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
#!/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
#!/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服务开始时没有任何问题。我可以创建主题,然后对主题执行操作。问题在于卡夫卡连接服务

当我尝试使用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)
我在这一行之后的消息日志中找不到此进程的任何日志,并且在任何其他日志中都没有错误。进程卡在这一行上::

信息注册加载程序:PluginClassLoader{pluginLocation=file…er:207)

无论我增加多少超时时间,这个过程都不会启动。但是当我从命令行运行相同的命令时,服务会正常启动

我尝试从插件路径中删除所有连接器,以查看服务是否启动,但它卡在同一条线上

以下是我的参考点:


**下面的配置在Ubuntu中对我有效**

[单位]
Requires=kafka.service
之后=卡夫卡服务

[服务]
类型=简单
用户=卡夫卡
ExecStart=/bin/sh-c'/home/kafka/kafka/bin/connect-distributed.sh/home/kafka/kafka/config/connect-distributed.properties>/home/kafka/kafka\u connect.log 2>&1'
重启=出现异常

[安装]

WantedBy=multi-user.target

我在Debain 9上遇到了同样的问题。我发现这是因为服务需要一个
工作目录
,否则kafka connect永远无法完全充电

因此,您的服务应该如下所示:

#!/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
!/bin/bash
#vi/etc/systemd/system/kafkaconnect.service
[单位]
Description=此服务将启动Kafka Connect服务。
Requires=network.target remote-fs.target nss-lookup.target kafka.service kafka.service
After=network.target remote-fs.target nss-lookup.target kafka.service
[服务]
类型=分叉
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\u DIR=/var/LOG/kafka日志”

WorkingDirectory=“/opt/InteracticCRM/kafka_2.11-1.0.1”不清楚为什么不使用Confluent OSS提供的systemd文件(在安装了YUM之后)@cricket_007是的,这很管用。但是我仍然不知道为什么这个脚本不起作用!你能访问Connect服务器的
/connector插件吗?顺便说一下,你不应该在同一台机器上运行Connect、Zookeeper和Kafka