我创建了以下systemd服务脚本,用于使用Ansible运行Zookeeper:
[Unit]
Description=ZooKeeper
[Service]
User=root
Type=forking
User=zookeeper
Group=zookeeper
ExecStart=/tmp/zookeeper-3.4.9/bin/zkServer.sh start
ExecStop=/tmp/zookeeper-3.4.9/bin/zkServer.sh stop
TimeoutSec=300
[Install]
WantedBy=multi-user.target
但是,在尝试使用
sudo service zookeeper start
运行脚本时,出现以下错误:Nov 15 22:00:35 sharedservicesprovider systemd[1]: Starting ZooKeeper...
-- Subject: Unit zookeeper.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zookeeper.service has begun starting up.
Nov 15 22:00:35 sharedservicesprovider systemd[15287]: zookeeper.service: Failed at step USER spawning /tmp/zookeeper-3.4.9/bin/zkServer.sh: No such process
-- Subject: Process /tmp/zookeeper-3.4.9/bin/zkServer.sh could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The process /tmp/zookeeper-3.4.9/bin/zkServer.sh could not be executed and failed.
--
-- The error number returned by this process is 3.
Nov 15 22:00:35 sharedservicesprovider systemd[1]: zookeeper.service: Control process exited, code=exited status=217
Nov 15 22:00:35 sharedservicesprovider systemd[1]: Failed to start ZooKeeper.
-- Subject: Unit zookeeper.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
有什么提示我为什么不能正确启动Zookeeper,因为我对系统服务还很陌生?
最佳答案
对我来说这听起来像是基本的检查
首先,确保文件存在
ls -ltrah /tmp/zookeeper-3.4.9/bin/zkServer.sh
如果找不到你从哪里提取的zookeeper启动脚本。就我而言,它是
/opt/kafka/bin/zookeeper-server-start.sh
然后验证您指定的用户(您指定了两个用户
root
和zookeeper
。我假设最后一个值是有效/所需的值)可以访问脚本并对其具有可执行权限。这将分别使用
chown
和chmod
命令来完成。关于linux - Systemd Zookeeper服务失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40620544/