mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 01:19:02 +00:00
Use config directory to find jvm.options
This commit removes the environment variable ES_JVM_OPTIONS that allows the jvm.options file to sit separately from the rest of the config directory. Instead, we use the CONF_DIR environment variable for custom configuration location just as we do for the other configuration files. Relates #25679
This commit is contained in:
parent
39b94b72b3
commit
5a416b9922
@ -158,7 +158,7 @@ class NodeInfo {
|
||||
args.add("${property.key.substring('tests.es.'.size())}=${property.value}")
|
||||
}
|
||||
}
|
||||
env.put('ES_JVM_OPTIONS', new File(confDir, 'jvm.options'))
|
||||
env.put('CONF_DIR', confDir)
|
||||
if (Version.fromString(nodeVersion).major == 5) {
|
||||
args.addAll("-E", "path.conf=${confDir}")
|
||||
} else {
|
||||
|
@ -80,7 +80,7 @@ DAEMON_OPTS="-d -p $PID_FILE --path.conf $CONF_DIR"
|
||||
export ES_JAVA_OPTS
|
||||
export JAVA_HOME
|
||||
export ES_INCLUDE
|
||||
export ES_JVM_OPTIONS
|
||||
export CONF_DIR
|
||||
|
||||
if [ ! -x "$DAEMON" ]; then
|
||||
echo "The elasticsearch startup script does not exists or it is not executable, tried: $DAEMON"
|
||||
|
@ -64,7 +64,7 @@ pidfile="$PID_DIR/${prog}.pid"
|
||||
export ES_JAVA_OPTS
|
||||
export JAVA_HOME
|
||||
export ES_INCLUDE
|
||||
export ES_JVM_OPTIONS
|
||||
export CONF_DIR
|
||||
export ES_STARTUP_SLEEP_TIME
|
||||
|
||||
lockfile=/var/lock/subsys/$prog
|
||||
|
@ -6,7 +6,7 @@
|
||||
# behavior, those variables are:
|
||||
#
|
||||
# ES_CLASSPATH -- A Java classpath containing everything necessary to run.
|
||||
# ES_JVM_OPTIONS -- Path to file containing JVM options
|
||||
# CONF_DIR -- Path to config directory
|
||||
# ES_JAVA_OPTS -- External Java Opts on top of the defaults set
|
||||
#
|
||||
# Optionally, exact memory values can be set using the `ES_JAVA_OPTS`.
|
||||
@ -81,14 +81,10 @@ ES_HOME=`dirname "$SCRIPT"`/..
|
||||
# make ELASTICSEARCH_HOME absolute
|
||||
ES_HOME=`cd "$ES_HOME"; pwd`
|
||||
|
||||
if [ -z "$ES_JVM_OPTIONS" ]; then
|
||||
for jvm_options in "$ES_HOME"/config/jvm.options \
|
||||
/etc/elasticsearch/jvm.options; do
|
||||
if [ -r "$jvm_options" ]; then
|
||||
ES_JVM_OPTIONS=$jvm_options
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$CONF_DIR" ]; then
|
||||
ES_JVM_OPTIONS="$ES_HOME"/config/jvm.options
|
||||
else
|
||||
ES_JVM_OPTIONS="$CONF_DIR"/jvm.options
|
||||
fi
|
||||
|
||||
ES_JAVA_OPTS="$(parse_jvm_options "$ES_JVM_OPTIONS") $ES_JAVA_OPTS"
|
||||
|
Binary file not shown.
Binary file not shown.
@ -35,3 +35,11 @@ only. Related, this means that the environment variables `DATA_DIR` and
|
||||
We previously attempted to ensure that Elasticsearch could be started on 32-bit
|
||||
JVM (although a bootstrap check prevented using a 32-bit JVM in production). We
|
||||
are no longer maintaining this attempt.
|
||||
|
||||
==== `ES_JVM_OPTIONS`is no longer supported
|
||||
|
||||
The environment variable `ES_JVM_OPTIONS` that enabled a custom location for the
|
||||
`jvm.options` file has been removed in favor of using the environment variable
|
||||
`CONF_DIR`. This environment variable is already used in the packaging to
|
||||
support relocating the configuration files so this change merely aligns the
|
||||
other configuration files with the location of the `jvm.options` file.
|
||||
|
@ -67,10 +67,9 @@ When using the zip or tarball packages, the `config`, `data`, `logs` and
|
||||
default.
|
||||
|
||||
It is a good idea to place these directories in a different location so that
|
||||
there is no chance of deleting them when upgrading Elasticsearch. These
|
||||
custom paths can be <<path-settings,configured>> with the `path.conf`,
|
||||
`path.logs`, and `path.data` settings, and using `ES_JVM_OPTIONS` to specify
|
||||
the location of the `jvm.options` file.
|
||||
there is no chance of deleting them when upgrading Elasticsearch. These custom
|
||||
paths can be <<path-settings,configured>> with the `CONF_DIR` environment
|
||||
variable, and the `path.logs`, and `path.data` settings.
|
||||
|
||||
The <<deb,Debian>> and <<rpm,RPM>> packages place these directories in the
|
||||
appropriate place for each operating system.
|
||||
|
@ -111,8 +111,10 @@ setup() {
|
||||
|
||||
@test "[TAR] start Elasticsearch with custom JVM options" {
|
||||
local es_java_opts=$ES_JAVA_OPTS
|
||||
local es_jvm_options=$ES_JVM_OPTIONS
|
||||
local conf_dir=$CONF_DIR
|
||||
local temp=`mktemp -d`
|
||||
cp "$ESCONFIG"/elasticsearch.yml "$temp"
|
||||
cp "$ESCONFIG"/log4j2.properties "$temp"
|
||||
touch "$temp/jvm.options"
|
||||
chown -R elasticsearch:elasticsearch "$temp"
|
||||
echo "-Xms512m" >> "$temp/jvm.options"
|
||||
@ -121,13 +123,13 @@ setup() {
|
||||
# manager exception before we have configured logging; this will fail
|
||||
# startup since we detect usages of logging before it is configured
|
||||
echo "-Dlog4j2.disable.jmx=true" >> "$temp/jvm.options"
|
||||
export ES_JVM_OPTIONS="$temp/jvm.options"
|
||||
export CONF_DIR="$temp"
|
||||
export ES_JAVA_OPTS="-XX:-UseCompressedOops"
|
||||
start_elasticsearch_service
|
||||
curl -s -XGET localhost:9200/_nodes | fgrep '"heap_init_in_bytes":536870912'
|
||||
curl -s -XGET localhost:9200/_nodes | fgrep '"using_compressed_ordinary_object_pointers":"false"'
|
||||
stop_elasticsearch_service
|
||||
export ES_JVM_OPTIONS=$es_jvm_options
|
||||
export CONF_DIR=$CONF_DIR
|
||||
export ES_JAVA_OPTS=$es_java_opts
|
||||
}
|
||||
|
||||
|
@ -187,6 +187,30 @@ setup() {
|
||||
systemctl stop elasticsearch.service
|
||||
}
|
||||
|
||||
@test "[SYSTEMD] start Elasticsearch with custom JVM options" {
|
||||
assert_file_exist $ESENVFILE
|
||||
local temp=`mktemp -d`
|
||||
cp "$ESCONFIG"/elasticsearch.yml "$temp"
|
||||
cp "$ESCONFIG"/log4j2.properties "$temp"
|
||||
touch "$temp/jvm.options"
|
||||
chown -R elasticsearch:elasticsearch "$temp"
|
||||
echo "-Xms512m" >> "$temp/jvm.options"
|
||||
echo "-Xmx512m" >> "$temp/jvm.options"
|
||||
# we have to disable Log4j from using JMX lest it will hit a security
|
||||
# manager exception before we have configured logging; this will fail
|
||||
# startup since we detect usages of logging before it is configured
|
||||
echo "-Dlog4j2.disable.jmx=true" >> "$temp/jvm.options"
|
||||
cp $ESENVFILE "$temp/elasticsearch"
|
||||
echo "CONF_DIR=\"$temp\"" >> $ESENVFILE
|
||||
echo "ES_JAVA_OPTS=\"-XX:-UseCompressedOops\"" >> $ESENVFILE
|
||||
service elasticsearch start
|
||||
wait_for_elasticsearch_status
|
||||
curl -s -XGET localhost:9200/_nodes | fgrep '"heap_init_in_bytes":536870912'
|
||||
curl -s -XGET localhost:9200/_nodes | fgrep '"using_compressed_ordinary_object_pointers":"false"'
|
||||
service elasticsearch stop
|
||||
cp "$temp/elasticsearch" $ESENVFILE
|
||||
}
|
||||
|
||||
@test "[SYSTEMD] masking systemd-sysctl" {
|
||||
clean_before_test
|
||||
|
||||
|
@ -120,9 +120,9 @@ setup() {
|
||||
|
||||
@test "[INIT.D] start Elasticsearch with custom JVM options" {
|
||||
assert_file_exist $ESENVFILE
|
||||
local es_java_opts=$ES_JAVA_OPTS
|
||||
local es_jvm_options=$ES_JVM_OPTIONS
|
||||
local temp=`mktemp -d`
|
||||
cp "$ESCONFIG"/elasticsearch.yml "$temp"
|
||||
cp "$ESCONFIG"/log4j2.properties "$temp"
|
||||
touch "$temp/jvm.options"
|
||||
chown -R elasticsearch:elasticsearch "$temp"
|
||||
echo "-Xms512m" >> "$temp/jvm.options"
|
||||
@ -132,7 +132,7 @@ setup() {
|
||||
# startup since we detect usages of logging before it is configured
|
||||
echo "-Dlog4j2.disable.jmx=true" >> "$temp/jvm.options"
|
||||
cp $ESENVFILE "$temp/elasticsearch"
|
||||
echo "ES_JVM_OPTIONS=\"$temp/jvm.options\"" >> $ESENVFILE
|
||||
echo "CONF_DIR=\"$temp\"" >> $ESENVFILE
|
||||
echo "ES_JAVA_OPTS=\"-XX:-UseCompressedOops\"" >> $ESENVFILE
|
||||
service elasticsearch start
|
||||
wait_for_elasticsearch_status
|
||||
|
@ -147,7 +147,7 @@ fi
|
||||
move_config
|
||||
|
||||
CONF_DIR="$ESCONFIG" install_jvm_example
|
||||
CONF_DIR="$ESCONFIG" ES_JVM_OPTIONS="$ESCONFIG/jvm.options" start_elasticsearch_service
|
||||
CONF_DIR="$ESCONFIG" start_elasticsearch_service
|
||||
diff <(curl -s localhost:9200/_cat/configured_example | sed 's/ //g') <(echo "foo")
|
||||
stop_elasticsearch_service
|
||||
CONF_DIR="$ESCONFIG" remove_jvm_example
|
||||
|
@ -339,10 +339,8 @@ run_elasticsearch_service() {
|
||||
if [ ! -z "$CONF_DIR" ] ; then
|
||||
if is_dpkg ; then
|
||||
echo "CONF_DIR=$CONF_DIR" >> /etc/default/elasticsearch;
|
||||
echo "ES_JVM_OPTIONS=$ES_JVM_OPTIONS" >> /etc/default/elasticsearch;
|
||||
elif is_rpm; then
|
||||
echo "CONF_DIR=$CONF_DIR" >> /etc/sysconfig/elasticsearch;
|
||||
echo "ES_JVM_OPTIONS=$ES_JVM_OPTIONS" >> /etc/sysconfig/elasticsearch
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -370,7 +368,7 @@ run_elasticsearch_service() {
|
||||
# This line is attempting to emulate the on login behavior of /usr/share/upstart/sessions/jayatana.conf
|
||||
[ -f /usr/share/java/jayatanaag.jar ] && export JAVA_TOOL_OPTIONS="-javaagent:/usr/share/java/jayatanaag.jar"
|
||||
# And now we can start Elasticsearch normally, in the background (-d) and with a pidfile (-p).
|
||||
export ES_JVM_OPTIONS=$ES_JVM_OPTIONS
|
||||
export CONF_DIR=$CONF_DIR
|
||||
export ES_JAVA_OPTS=$ES_JAVA_OPTS
|
||||
$timeoutCommand/tmp/elasticsearch/bin/elasticsearch $background -p /tmp/elasticsearch/elasticsearch.pid $ES_PATH_CONF $commandLineArgs
|
||||
BASH
|
||||
|
Loading…
x
Reference in New Issue
Block a user