Skip to content

Instantly share code, notes, and snippets.

@bejean
Created April 3, 2018 21:03
Show Gist options
  • Save bejean/92ba69798fd8c27d964db9b428c34e2f to your computer and use it in GitHub Desktop.
Save bejean/92ba69798fd8c27d964db9b428c34e2f to your computer and use it in GitHub Desktop.
zookeeper-env.sh
#-------------------------------------------------------------------
# zookeeper-env.sh
#--------------------------------------------------------------------
# Configure Log
ZOO_LOG_DIR="/var/log/zookeeper"
ZOO_LOG4J_PROP="WARN, ROLLINGFILE"
# Configure JVM GC log
ZOO_GC_LOG_DIR="/var/log/zookeeper"
SERVER_JVMFLAGS="-verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistr
ibution -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=1M -Xloggc:$ZOO_GC_LOG_D
IR/zookeeper.gc -Xmx512m"
# Configure JMX (enabled by default for local monitoring by PID)
# define JMXPORT allows remote monitoring
#JMXDISABLE=true
JMXPORT=10900
# Backup log GC at startup
if [ "x$1" = "xstart" ]; then
for f in $ZOO_GC_LOG_DIR/zookeeper.gc*; do
## Check if the glob gets expanded to existing files.
## If not, f here will be exactly the pattern above
## and the exists test will evaluate to false.
if [ -e "$f" ] ; then
echo "GC log files found - backing up"
d=$PWD && cd $ZOO_GC_LOG_DIR && tar czf zookeeper.gc.$(date +%Y%m%d-%H%M%S).tgz zookeeper.gc* && cd $d
else
echo "No GC log files found"
fi
## This is all we needed to know, so we can break after the first iteration
break
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment