由于缺少zookeeper-gc.log,无法启动Zookeeper

jk9hmnmh  于 2023-05-27  发布在  Apache
关注(0)|答案(1)|浏览(270)

我有一个3节点systemd Kafka集群。我删除了1个节点中/opt/kafka/kafka/logs/中的所有日志文件,以为它们只是消耗存储的日志。现在,在重新启动zookeeper.service后,我得到以下错误表单systemctl status zookeeper.service,这使得它无法启动:

systemd[1]: Started zookeeper.service.
zookeeper-server-start.sh[23029]: [0.001s][error][logging] Error opening log file '/opt/kafka/kafka/bin/../logs/zookeeper-gc.log': Permission denied
zookeeper-server-start.sh[23029]: [0.002s][error][logging] Initialization of output 'file=/opt/kafka/kafka/bin/../logs/zookeeper-gc.log' using options 'filecount=10,filesize=100M' failed.
zookeeper-server-start.sh[23029]: Invalid -Xlog option '-Xlog:gc*:file=/opt/kafka/kafka/bin/../logs/zookeeper-gc.log:time,tags:filecount=10,filesize=100M', see error log for details.
zookeeper-server-start.sh[23029]: Error: Could not create the Java Virtual Machine.
zookeeper-server-start.sh[23029]: Error: A fatal exception has occurred. Program will exit.
systemd[1]: zookeeper.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: zookeeper.service: Failed with result 'exit-code'.

因此kafka.service不能启动,因为它需要zookeeper.service
我尝试手动创建zookeeper-gc.log,并根据其他节点的相同日志文件配置所有者、组和权限:

touch /opt/kafka/kafka/bin/../logs/zookeeper-gc.log
chown kafka:kafka /opt/kafka/kafka/bin/../logs/zookeeper-gc.log
chmod 644 /opt/kafka/kafka/bin/../logs/zookeeper-gc.log

并重新启动两个服务,但得到相同的输出。我还在/opt/kafka/kafka/bin/kafka-run-class.sh中找到了以下行:

KAFKA_GC_LOG_OPTS="-Xlog:gc*:file=$LOG_DIR/$GC_LOG_FILE_NAME:time,tags:filecount=10,filesize=100M"
KAFKA_GC_LOG_OPTS="-Xloggc:$LOG_DIR/$GC_LOG_FILE_NAME -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSi

但没有足够的知识来修改或改变它们。任何帮助将不胜感激。

xxb16uws

xxb16uws1#

systemctl restart kafka zookeeper命令输出的错误消息来看,似乎/opt/kafka/kafka/bin/../logs/zookeeper-gc.log文件或/opt/kafka/kafka/bin/../logs/目录的权限或所有权不正确。
我不知道您运行的是哪个操作系统,但请尝试以下操作,看看是否可以解决问题:

chown -R kafka:kafka /opt/kafka/kafka/bin/../logs/

-R标志表示recursive

相关问题