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

改完后再启动就不报错了。

参考文章

kafka优化–JVM参数配置优化_u013063153的博客-CSDN博客_kafka_opts

Logo

Kafka开源项目指南提供详尽教程,助开发者掌握其架构、配置和使用,实现高效数据流管理和实时处理。它高性能、可扩展,适合日志收集和实时数据处理,通过持久化保障数据安全,是企业大数据生态系统的核心。

更多推荐