0

我创建了以下 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 的任何提示?

4

3 回答 3

1
[Unit]
Description=Zookeeper
After=syslog.target
[Service]
Environment=ZOO_LOG_DIR=/zookeeper/logs
SyslogIdentifier=zookeeper
TimoutStartSec=10min
Type=forking
User=zookeeper
Group=zookeeper
ExecStart=/zookeeper/bin/zkServer.sh start
ExecStop=/zookeeper/bin/zkServer.sh stop
[Install]
WantedBy=multi-user.target

ZOO_LOG_DIR 用于权限要求

于 2018-03-23T06:55:13.600 回答
1

也许这么晚了......但用作ExecStart:

/tmp/zookeeper-3.4.9/bin/zkServer.sh start-foreground

于 2018-02-07T16:55:31.833 回答
0

这听起来像是首先要检查给我的基础知识,确保文件存在

ls -ltrah /tmp/zookeeper-3.4.9/bin/zkServer.sh

如果它没有找到您提取 zookeeper 启动脚本的位置。在我的例子中,它是/opt/kafka/bin/zookeeper-server-start.sh

然后验证您指定的用户(您指定了两个用户rootzookeeper. 我假设最后一个值是有效/所需的)可以访问脚本并对其具有可执行权限。

这将分别使用chownchmod命令来完成。

于 2017-02-08T01:15:27.257 回答