简体   繁体   English

无法在 Centos 7/Centos 8 上启动 Kafka/Zookeeper 服务

[英]Can't start Kafka/Zookeeper Service on Centos 7/Centos 8

Paths are correct, I don't know why I can't start kafka service, all lines, log files, etc and do not say what the Issue is... :/路径是正确的,我不知道为什么我无法启动 kafka 服务、所有行、日志文件等,也没有说明问题是什么......:/

I'm trying to install kafka on my Centos 7/8 and there is no Issue description I can figure out.我正在尝试在我的 Centos 7/8 上安装 kafka,但没有我能弄清楚的问题描述。

zookeeper.service file: zookeeper.service文件:

[Unit] 
Requires=network.target remote-fs.target 
After=network.target remote-fs.target 

[Service] 
Type=simpleUser=kafka 

ExecStart=/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties 
ExecStop=/home/kafka/kafka/bin/zookeeper-server-stop.shRestart=on-abnormal 

[Install]
WantedBy=multi-user.target 

kafka.service file: kafka.service文件:

[Unit] 
Requires=zookeeper.service 
After=zookeeper.service 

[Service] 
Type=simple 
User=kafka 
ExecStart=/bin/sh -c '/home/kafka/kafka/bin/kafka-server-start.sh /home/kafka/kafka/config/server.properties > /home/kafka/kafka/kafka.log 2>&1'
ExecStop=/home/kafka/kafka/bin/kafka-server-stop.shRestart=on-abnormal 

[Install]
WantedBy=multi-user.target 

在此处输入图片说明

在此处输入图片说明

UPDATE: I was trying to solve kafka Issue when I sould check zookeeper service first.更新:当我首先检查zookeeper服务时,我试图解决kafka问题。 Please check the workaround below.请检查下面的解决方法。

Ok I found the solution and I'm posting it because I saw a lot of questions regarding this Issue hoping I can also help them.好的,我找到了解决方案并发布了它,因为我看到了很多关于此问题的问题,希望我也可以帮助他们。

So, please check out the new command line ExecStart :因此,请查看新的命令行ExecStart

zookeeper.service file: zookeeper.service文件:

[Unit] 
Requires=network.target remote-fs.target 
After=network.target remote-fs.target 

[Service] 
Type=simpleUser=kafka 

ExecStart=/bin/sh -c '/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties'
ExecStop=/home/kafka/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal 

[Install]
WantedBy=multi-user.target 

On Centos (7/8/ X Version) it needs to specify the batch like this (using /bin/sh -c '' ):Centos (7/8/ X 版本)上,它需要像这样指定批处理(使用/bin/sh -c '' ):

ExecStart=/bin/sh -c '/home/kafka/kafka/bin/zookeeper-server-start.sh /home/kafka/kafka/config/zookeeper.properties'

动物园管理员按预期工作

After this, you can run the kafka service!之后就可以运行kafka服务了! :) :)

From Kafka docs Quickstart来自Kafka 文档快速入门

Kafka uses ZooKeeper so you need to first start a ZooKeeper server if you don't already have one. Kafka 使用 ZooKeeper,因此如果您还没有 ZooKeeper 服务器,则需要先启动一个 ZooKeeper 服务器。 You can use the convenience script packaged with kafka to get a quick-and-dirty single-node ZooKeeper instance.您可以使用 kafka 打包的便捷脚本来获得一个快速而肮脏的单节点 ZooKeeper 实例。

Start zookeeper server with default settings使用默认设置启动 zookeeper 服务器

$ bin/zookeeper-server-start.sh config/zookeeper.properties

Start Kakfa server with default settings使用默认设置启动 Kakfa 服务器

$ bin/kafka-server-start.sh config/server.properties

If you had already done this step and still getting this error, Kafka server is unable to reach zookeeper service.如果你已经做了这一步还是出现这个错误,说明Kafka服务器无法访问zookeeper服务。 Please check zookeeper server is running and listening on port mentioned (clientPort, default port: 2181) in zookeeper.properties file using anyone of the following commands - netstat , lsof , and telnet请使用以下任一命令检查zookeeper 服务器是否正在运行并侦听zookeeper.properties 文件中提到的端口(clientPort,默认端口:2181) - netstatlsoftelnet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM