From c94c0aa4e8eb389b4c7a4d1460bf3e2805d834dc Mon Sep 17 00:00:00 2001 From: gaozhangmin Date: Wed, 24 Nov 2021 09:23:27 +0800 Subject: [PATCH] Fix broker gc log options (#11285) --- bin/pulsar | 4 ++++ conf/bkenv.sh | 11 ++++++++++- conf/pulsar_env.sh | 4 ++-- pulsar-client-cpp/run-unit-tests.sh | 3 ++- site2/docs/reference-cli-tools.md | 4 +++- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/bin/pulsar b/bin/pulsar index 69fcd6e48e1de..0a457e4bf2512 100755 --- a/bin/pulsar +++ b/bin/pulsar @@ -20,6 +20,7 @@ BINDIR=$(dirname "$0") export PULSAR_HOME=`cd -P $BINDIR/..;pwd` +export BK_HOME=`cd -P $BINDIR/..;pwd` DEFAULT_BROKER_CONF=$PULSAR_HOME/conf/broker.conf DEFAULT_BOOKKEEPER_CONF=$PULSAR_HOME/conf/bookkeeper.conf @@ -287,6 +288,9 @@ PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"RoutingAppender"} PULSAR_LOG_ROOT_LEVEL=${PULSAR_LOG_ROOT_LEVEL:-"info"} PULSAR_LOG_LEVEL=${PULSAR_LOG_LEVEL:-"info"} PULSAR_ROUTING_APPENDER_DEFAULT=${PULSAR_ROUTING_APPENDER_DEFAULT:-"Console"} +if [ ! -d "$PULSAR_LOG_DIR" ]; then + mkdir -p "$PULSAR_LOG_DIR" +fi #Configure log configuration system properties OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER" diff --git a/conf/bkenv.sh b/conf/bkenv.sh index 5215fdeceed09..63d12ffdfc5d7 100644 --- a/conf/bkenv.sh +++ b/conf/bkenv.sh @@ -38,8 +38,17 @@ BOOKIE_MEM=${BOOKIE_MEM:-${PULSAR_MEM:-"-Xms2g -Xmx2g -XX:MaxDirectMemorySize=2g # Garbage collection options BOOKIE_GC=${BOOKIE_GC:-${PULSAR_GC:-"-XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DoEscapeAnalysis -XX:ParallelGCThreads=32 -XX:ConcGCThreads=32 -XX:G1NewSizePercent=50 -XX:+DisableExplicitGC -XX:-ResizePLAB"}} +IS_JAVA_8=`java -version 2>&1 |grep version|grep '"1\.8'` +# java version has space, use [[ -n $PARAM ]] to judge if variable exists +if [[ -n $IS_JAVA_8 ]]; then + BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-"-Xloggc:logs/pulsar_bookie_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M"} +else +# After jdk 9, gc log param should config like this. Ignoring version less than jdk 8 + BOOKIE_GC_LOG=${BOOKIE_GC_LOG:-"-Xlog:gc*:logs/pulsar_bookie_gc_%p.log:time,uptime,level,tags:filecount=10,filesize=20M"} +fi + # Extra options to be passed to the jvm -BOOKIE_EXTRA_OPTS="${BOOKIE_EXTRA_OPTS:-"-Dio.netty.leakDetectionLevel=disabled ${PULSAR_EXTRA_OPTS:-"-Dio.netty.recycler.maxCapacity.default=1000 -Dio.netty.recycler.linkCapacity=1024"}"} ${BOOKIE_MEM} ${BOOKIE_GC}" +BOOKIE_EXTRA_OPTS="${BOOKIE_EXTRA_OPTS:-"-Dio.netty.leakDetectionLevel=disabled ${PULSAR_EXTRA_OPTS:-"-Dio.netty.recycler.maxCapacity.default=1000 -Dio.netty.recycler.linkCapacity=1024"}"} ${BOOKIE_MEM} ${BOOKIE_GC} ${BOOKIE_GC_LOG}" # Add extra paths to the bookkeeper classpath # BOOKIE_EXTRA_CLASSPATH= diff --git a/conf/pulsar_env.sh b/conf/pulsar_env.sh index 61201dd835cca..528191113f13f 100755 --- a/conf/pulsar_env.sh +++ b/conf/pulsar_env.sh @@ -54,11 +54,11 @@ if [[ -n $IS_JAVA_8 ]]; then PULSAR_GC_LOG=${PULSAR_GC_LOG:-"-Xloggc:logs/pulsar_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M"} else # After jdk 9, gc log param should config like this. Ignoring version less than jdk 8 - PULSAR_GC_LOG=${PULSAR_GC_LOG:-"-Xlog:gc:logs/pulsar_gc_%p.log:time,uptime:filecount=10,filesize=20M"} + PULSAR_GC_LOG=${PULSAR_GC_LOG:-"-Xlog:gc*:logs/pulsar_gc_%p.log:time,uptime:filecount=10,filesize=20M"} fi # Extra options to be passed to the jvm -PULSAR_EXTRA_OPTS=${PULSAR_EXTRA_OPTS:-" -Dpulsar.allocator.exit_on_oom=true -Dio.netty.recycler.maxCapacity.default=1000 -Dio.netty.recycler.linkCapacity=1024"} +PULSAR_EXTRA_OPTS="${PULSAR_EXTRA_OPTS:-" -Dpulsar.allocator.exit_on_oom=true -Dio.netty.recycler.maxCapacity.default=1000 -Dio.netty.recycler.linkCapacity=1024"} ${PULSAR_GC_LOG}" # Add extra paths to the bookkeeper classpath # PULSAR_EXTRA_CLASSPATH= diff --git a/pulsar-client-cpp/run-unit-tests.sh b/pulsar-client-cpp/run-unit-tests.sh index 8dd8c00feaea0..f31202cc44a93 100755 --- a/pulsar-client-cpp/run-unit-tests.sh +++ b/pulsar-client-cpp/run-unit-tests.sh @@ -23,7 +23,8 @@ set -e ROOT_DIR=$(git rev-parse --show-toplevel) cd $ROOT_DIR/pulsar-client-cpp -./pulsar-test-service-start.sh +JAVA_HOME=/usr ./pulsar-test-service-start.sh + pushd tests diff --git a/site2/docs/reference-cli-tools.md b/site2/docs/reference-cli-tools.md index 40db0d856c320..6aeb7e817c9c9 100644 --- a/site2/docs/reference-cli-tools.md +++ b/site2/docs/reference-cli-tools.md @@ -63,7 +63,7 @@ The table below lists the environment variables that you can use to configure th |`PULSAR_EXTRA_CLASSPATH`|Extra paths for Pulsar's classpath|| |`PULSAR_PID_DIR`|Folder where the pulsar server PID file should be stored|| |`PULSAR_STOP_TIMEOUT`|Wait time before forcefully killing the Bookie server instance if attempts to stop it are not successful|| - +|`PULSAR_GC_LOG`|Gc options to be passed to the jvm|| ### `bookie` @@ -422,6 +422,7 @@ The table below lists the environment variables that you can use to configure th |`PULSAR_CLIENT_CONF`|Configuration file for the client|conf/client.conf| |`PULSAR_EXTRA_OPTS`|Extra options to be passed to the JVM|| |`PULSAR_EXTRA_CLASSPATH`|Extra paths for Pulsar's classpath|| +|`PULSAR_GC_LOG`|Gc options to be passed to the jvm|| ### `consume` @@ -703,6 +704,7 @@ The table below lists the environment variables that you can use to configure th |ENTRY_FORMATTER_CLASS|The Java class used to format entries|| |BOOKIE_PID_DIR|Folder where the BookKeeper server PID file should be stored|| |BOOKIE_STOP_TIMEOUT|Wait time before forcefully killing the Bookie server instance if attempts to stop it are not successful|| +|BOOKIE_GC_LOG|Gc options to be passed to the jvm|| ### `auto-recovery`