英文:
Zookeeper can't be started because of missing zookeeper-gc.log
问题
我有一个由3个节点组成的systemd
Kafka集群。我在其中一个节点中删除了/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
但我不够了解如何修改或更改它们。任何帮助将不胜感激。
英文:
I have a 3-node systemd
kafka cluster. I had removed all log files in /opt/kafka/kafka/logs/
in 1 node, thought they were just storage-consuming logs. Now after restarting the zookeeper.service
I get the following error form systemctl status zookeeper.service
which makes it unable to start:
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'.
And therefore kafka.service
can't be started since it requires zookeeper.service
.
I have tried to create the zookeeper-gc.log
manually and configured the owner, group, and permissions based on other nodes' same log file:
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
And restarted both services but got the same output.
I also find the following lines in /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
But had not enogh knowledge to modify or change them.
Any help would be appreciate.
答案1
得分: 1
从您的 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
标志表示递归。
英文:
From the error message of your systemctl restart kafka zookeeper
command's output, it seems either permissions or ownership of either the /opt/kafka/kafka/bin/../logs/zookeeper-gc.log
file or the /opt/kafka/kafka/bin/../logs/
directory is not correct.
I don't know which OS you're running, but try the following and see if it fixes the problem:
chown -R kafka:kafka /opt/kafka/kafka/bin/../logs/
Note: The -R
flag means recursive
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论