Vasily802
Vasily802

Reputation: 1848

Change JVM params for Solr

How do I specify another type of garbage collector for a dockerized Solr7? My docker startup command is as follows:

docker run -d --restart always --name solrcloud \
-p 8983:8983 --net host myrepo/my-fusion-solr-image:latest \
bin/solr -c -f -a -javaagent:/opt/newrelic/newrelic.jar \
-Dnewrelic.environment=dev -Ddisable.configEdit=true \
-z dev-fusion-zk.aws.myhost.net:2181/dev-fusion -m 30g

I'm trying to follow this article: https://wiki.apache.org/solr/ShawnHeisey Where exactly should I specify -XX:+UseG1GC ?

Upvotes: 2

Views: 1861

Answers (1)

Vasily802
Vasily802

Reputation: 1848

In Dockerfile for Solr image, add following step:

# Use G1GC garbage collector
# https://wiki.apache.org/solr/ShawnHeisey
RUN sed -i -e 's/^#GC_TUNE.*/GC_TUNE=" \
-XX:+UseG1GC \
-XX:+PerfDisableSharedMem \
-XX:+ParallelRefProcEnabled \
-XX:G1HeapRegionSize=8m \
-XX:MaxGCPauseMillis=250 \
-XX:InitiatingHeapOccupancyPercent=75 \
-XX:+UseLargePages \
-XX:+AggressiveOpts \
"/' /opt/solr/solr-$SOLR_VERSION/bin/solr.in.sh

Solr 7.2.1 has this file bin/solr.in.sh that looks like it was added specifically to override some configs in bin/solr. There in bin/solr.in.sh is a commented out line starting with #GC_TUNE=. If we uncomment this line, it will override GC_TUNE variable in bin/solr.

sed command in the snippet above replaces that line with desired settings. Note that sed can act differently in different environments and may require some modifications to work for your case. Please test it before plugging it into your dockerfile. Above snippet works for centos.

Upvotes: 2

Related Questions