kafka启动警告解决方案,OpenJDK 64-Bit Server VM warning
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N.
·
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
报错原因,虚拟机核心数与默认配置的 并行收集器的线程数不一致。
一般来说只要改虚拟机的核心数,调整成两个就可以的。
但我这个不是虚拟机,而是阿里云的服务器,我不想升级。(才不是没钱)
既然它提示说可以修改 XX:ParallelGCThreads参数,那就修改这个好了。
问题是,在哪里改呢?
试过改java的配置,或者配置环境变量,都不行。
后来看了一下kafka的文档,查了一下环境配置,是在启动脚本里改。
# 进入kafka目录
cd kafka_2.12-2.1.0
# 编辑启动脚本
vim bin/kafka-server-start.sh
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if [ $# -lt 1 ];
then
echo "USAGE: $0 [-daemon] server.properties [--override property=value]*"
exit 1
fi
base_dir=$(dirname $0)
if [ "x$KAFKA_LOG4J_OPTS" = "x" ]; then
export KAFKA_LOG4J_OPTS="-Dlog4j.configuration=file:$base_dir/../config/log4j.properties"
fi
if [ "x$KAFKA_HEAP_OPTS" = "x" ]; then
# 修改这一行,引号里加上参数-XX:ParallelGCThreads ,有几个核心就写几,我只有一个,就是1
export KAFKA_HEAP_OPTS="-Xmx256m -Xms120m -XX:ParallelGCThreads=1"
fi
EXTRA_ARGS=${EXTRA_ARGS-'-name kafkaServer -loggc'}
COMMAND=$1
改完后再启动就不报错了。
参考文章
更多推荐
已为社区贡献1条内容
所有评论(0)