Zookeeper systemd 服务未运行

Zookeeper systemd 服务未运行

我已经在/opt/kafka目录下下载了Kafka。我创建了一个名为的用户kafkaadmin并将其添加到wheel组中,以便他可以作为root用户运行。现在,我已将 Zookeeper 配置为 systemd 服务,并创建了一个名为zookeeper.serviceunder 的文件/etc/systemd/system/zookeeper.properties。下面是配置

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

[Service]
Type=simple
User=kafkaadmin
ExecStart=/opt/kafka/bin/zookeeper-server-start.sh -daemon /opt/kafka/config/zookeeper.properties
ExecStop=/opt/kafka/bin/zookeeper-server-stop.sh
Restart=on-abnormal

[Install]
WantedBy=multi-user.target

当我运行systemctl start zookeeper然后运行时,journalctl -u zookeeper我收到一条消息,说明服务已退出

-- Logs begin at Sat 2021-05-08 12:48:37 UTC, end at Sat 2021-05-08 12:55:59 UTC. --
-- Logs begin at Sat 2021-05-08 12:48:37 UTC, end at Sat 2021-05-08 12:55:59 UTC. --
-- Logs begin at Sat 2021-05-08 12:48:37 UTC, end at Sat 2021-05-08 12:55:59 UTC. --
May 08 12:48:47 kafka-node systemd[1]: Started zookeeper.service.
May 08 12:48:51 kafka-node systemd[1]: zookeeper.service: Control process exited, code=exited status=1
May 08 12:48:51 kafka-node systemd[1]: zookeeper.service: Failed with result 'exit-code'.
May 08 12:51:49 kafka-node systemd[1]: Started zookeeper.service.
May 08 12:51:49 kafka-node zookeeper-server-start.sh[2171]: OpenJDK 64-Bit Server VM warning: Cannot open file /opt/kafka/bin/../logs/zookeeper-gc.log due to Permission denied
May 08 12:51:50 kafka-node zookeeper-server-start.sh[2171]: log4j:ERROR setFile(null,true) call failed.
May 08 12:51:50 kafka-node zookeeper-server-start.sh[2171]: java.io.FileNotFoundException: /opt/kafka/bin/../logs/server.log (Permission denied)
May 08 12:51:50 kafka-node zookeeper-server-start.sh[2171]:         at java.io.FileOutputStream.open0(Native Method)at org.apache.log>lines 1-20at org.apache.log>lines 1-20

现在,当我尝试运行时,systemctl start zookeeper出现上述错误。这kafkaadmin是 root 用户。我如何才能启动该用户的服务?我哪里错了?

相关内容