Rename CONF_DIR to ES_PATH_CONF

The environment variable CONF_DIR was previously inconsistently used in
our packaging to customize the location of Elasticsearch configuration
files. The importance of this environment variable has increased
starting in 6.0.0 as it's now used consistently to ensure Elasticsearch
and all secondary scripts (e.g., elasticsearch-keystore) all use the
same configuration. The name CONF_DIR is there for legacy reasons yet
it's too generic. This commit renames CONF_DIR to ES_PATH_CONF.

Relates #26197
This commit is contained in:
Jason Tedor 2017-08-15 06:19:06 +09:00 committed by GitHub
parent 62021147ea
commit e9687622bd
35 changed files with 86 additions and 75 deletions

View File

@ -326,7 +326,7 @@ class ClusterFormationTasks {
if (unicastTransportUri != null) { if (unicastTransportUri != null) {
esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\"" esConfig['discovery.zen.ping.unicast.hosts'] = "\"${unicastTransportUri}\""
} }
File configFile = new File(node.confDir, 'elasticsearch.yml') File configFile = new File(node.pathConf, 'elasticsearch.yml')
logger.info("Configuring ${configFile}") logger.info("Configuring ${configFile}")
configFile.setText(esConfig.collect { key, value -> "${key}: ${value}" }.join('\n'), 'UTF-8') configFile.setText(esConfig.collect { key, value -> "${key}: ${value}" }.join('\n'), 'UTF-8')
} }

View File

@ -55,7 +55,7 @@ class NodeInfo {
File homeDir File homeDir
/** config directory */ /** config directory */
File confDir File pathConf
/** data directory (as an Object, to allow lazy evaluation) */ /** data directory (as an Object, to allow lazy evaluation) */
Object dataDir Object dataDir
@ -110,13 +110,13 @@ class NodeInfo {
pidFile = new File(baseDir, 'es.pid') pidFile = new File(baseDir, 'es.pid')
this.nodeVersion = nodeVersion this.nodeVersion = nodeVersion
homeDir = homeDir(baseDir, config.distribution, nodeVersion) homeDir = homeDir(baseDir, config.distribution, nodeVersion)
confDir = confDir(baseDir, config.distribution, nodeVersion) pathConf = pathConf(baseDir, config.distribution, nodeVersion)
if (config.dataDir != null) { if (config.dataDir != null) {
dataDir = "${config.dataDir(nodeNum)}" dataDir = "${config.dataDir(nodeNum)}"
} else { } else {
dataDir = new File(homeDir, "data") dataDir = new File(homeDir, "data")
} }
configFile = new File(confDir, 'elasticsearch.yml') configFile = new File(pathConf, 'elasticsearch.yml')
// even for rpm/deb, the logs are under home because we dont start with real services // even for rpm/deb, the logs are under home because we dont start with real services
File logsDir = new File(homeDir, 'logs') File logsDir = new File(homeDir, 'logs')
httpPortsFile = new File(logsDir, 'http.ports') httpPortsFile = new File(logsDir, 'http.ports')
@ -158,9 +158,9 @@ class NodeInfo {
args.add("${property.key.substring('tests.es.'.size())}=${property.value}") args.add("${property.key.substring('tests.es.'.size())}=${property.value}")
} }
} }
env.put('CONF_DIR', confDir) env.put('ES_PATH_CONF', pathConf)
if (Version.fromString(nodeVersion).major == 5) { if (Version.fromString(nodeVersion).major == 5) {
args.addAll("-E", "path.conf=${confDir}") args.addAll("-E", "path.conf=${pathConf}")
} }
if (!System.properties.containsKey("tests.es.path.data")) { if (!System.properties.containsKey("tests.es.path.data")) {
args.addAll("-E", "path.data=${-> dataDir.toString()}") args.addAll("-E", "path.data=${-> dataDir.toString()}")
@ -240,7 +240,7 @@ class NodeInfo {
return new File(baseDir, path) return new File(baseDir, path)
} }
static File confDir(File baseDir, String distro, String nodeVersion) { static File pathConf(File baseDir, String distro, String nodeVersion) {
switch (distro) { switch (distro) {
case 'integ-test-zip': case 'integ-test-zip':
case 'zip': case 'zip':

View File

@ -24,7 +24,6 @@ import org.gradle.api.DefaultTask
import org.gradle.api.Task import org.gradle.api.Task
import org.gradle.api.execution.TaskExecutionAdapter import org.gradle.api.execution.TaskExecutionAdapter
import org.gradle.api.internal.tasks.options.Option import org.gradle.api.internal.tasks.options.Option
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.tasks.Input import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskState import org.gradle.api.tasks.TaskState
@ -68,7 +67,7 @@ public class RestIntegTestTask extends DefaultTask {
// we pass all nodes to the rest cluster to allow the clients to round-robin between them // we pass all nodes to the rest cluster to allow the clients to round-robin between them
// this is more realistic than just talking to a single node // this is more realistic than just talking to a single node
runner.systemProperty('tests.rest.cluster', "${-> nodes.collect{it.httpUri()}.join(",")}") runner.systemProperty('tests.rest.cluster', "${-> nodes.collect{it.httpUri()}.join(",")}")
runner.systemProperty('tests.config.dir', "${-> nodes[0].confDir}") runner.systemProperty('tests.config.dir', "${-> nodes[0].pathConf}")
// TODO: our "client" qa tests currently use the rest-test plugin. instead they should have their own plugin // TODO: our "client" qa tests currently use the rest-test plugin. instead they should have their own plugin
// that sets up the test cluster and passes this transport uri instead of http uri. Until then, we pass // that sets up the test cluster and passes this transport uri instead of http uri. Until then, we pass
// both as separate sysprops // both as separate sysprops

View File

@ -521,12 +521,12 @@ Map<String, String> expansionsForDistribution(distributionType) {
'rpm': '/etc/sysconfig/elasticsearch', 'rpm': '/etc/sysconfig/elasticsearch',
/* There isn't one of these files for tar or zip but its important to /* There isn't one of these files for tar or zip but its important to
make an empty string here so the script can properly skip it. */ make an empty string here so the script can properly skip it. */
'def': 'if [ -z "$CONF_DIR" ]; then CONF_DIR="$ES_HOME"/config; done', 'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; done',
], ],
'source.path.env': [ 'source.path.env': [
'deb': 'if [ -f /etc/default/elasticsearch ]; then source /etc/default/elasticsearch; fi', 'deb': 'if [ -f /etc/default/elasticsearch ]; then source /etc/default/elasticsearch; fi',
'rpm': 'if [ -f /etc/sysconfig/elasticsearch ]; then source /etc/sysconfig/elasticsearch; fi', 'rpm': 'if [ -f /etc/sysconfig/elasticsearch ]; then source /etc/sysconfig/elasticsearch; fi',
'def': 'if [ -z "$CONF_DIR" ]; then CONF_DIR="$ES_HOME"/config; fi', 'def': 'if [ -z "$ES_PATH_CONF" ]; then ES_PATH_CONF="$ES_HOME"/config; fi',
], ],
'path.logs': [ 'path.logs': [
'deb': packagingPathLogs, 'deb': packagingPathLogs,

View File

@ -45,7 +45,7 @@ MAX_OPEN_FILES=65536
#MAX_LOCKED_MEMORY= #MAX_LOCKED_MEMORY=
# Elasticsearch configuration directory # Elasticsearch configuration directory
CONF_DIR=/etc/$NAME ES_PATH_CONF=/etc/$NAME
# Maximum number of VMA (Virtual Memory Areas) a process can own # Maximum number of VMA (Virtual Memory Areas) a process can own
MAX_MAP_COUNT=262144 MAX_MAP_COUNT=262144
@ -73,7 +73,7 @@ DAEMON_OPTS="-d -p $PID_FILE"
export ES_JAVA_OPTS export ES_JAVA_OPTS
export JAVA_HOME export JAVA_HOME
export CONF_DIR export ES_PATH_CONF
if [ ! -x "$DAEMON" ]; then if [ ! -x "$DAEMON" ]; then
echo "The elasticsearch startup script does not exists or it is not executable, tried: $DAEMON" echo "The elasticsearch startup script does not exists or it is not executable, tried: $DAEMON"

View File

@ -35,7 +35,7 @@ fi
ES_HOME="/usr/share/elasticsearch" ES_HOME="/usr/share/elasticsearch"
MAX_OPEN_FILES=65536 MAX_OPEN_FILES=65536
MAX_MAP_COUNT=262144 MAX_MAP_COUNT=262144
CONF_DIR="${path.conf}" ES_PATH_CONF="${path.conf}"
PID_DIR="/var/run/elasticsearch" PID_DIR="/var/run/elasticsearch"
@ -57,7 +57,7 @@ pidfile="$PID_DIR/${prog}.pid"
export ES_JAVA_OPTS export ES_JAVA_OPTS
export JAVA_HOME export JAVA_HOME
export CONF_DIR export ES_PATH_CONF
export ES_STARTUP_SLEEP_TIME export ES_STARTUP_SLEEP_TIME
lockfile=/var/lock/subsys/$prog lockfile=/var/lock/subsys/$prog

View File

@ -9,7 +9,7 @@
#JAVA_HOME= #JAVA_HOME=
# Elasticsearch configuration directory # Elasticsearch configuration directory
CONF_DIR=${path.conf} ES_PATH_CONF=${path.conf}
# Elasticsearch PID directory # Elasticsearch PID directory
#PID_DIR=/var/run/elasticsearch #PID_DIR=/var/run/elasticsearch

View File

@ -50,7 +50,7 @@ LOG_DIR="/var/log/elasticsearch"
PLUGINS_DIR="/usr/share/elasticsearch/plugins" PLUGINS_DIR="/usr/share/elasticsearch/plugins"
PID_DIR="/var/run/elasticsearch" PID_DIR="/var/run/elasticsearch"
DATA_DIR="/var/lib/elasticsearch" DATA_DIR="/var/lib/elasticsearch"
CONF_DIR="/etc/elasticsearch" ES_PATH_CONF="/etc/elasticsearch"
# Source the default env file # Source the default env file
if [ "$SOURCE_ENV_FILE" = "true" ]; then if [ "$SOURCE_ENV_FILE" = "true" ]; then
@ -86,8 +86,8 @@ if [ "$REMOVE_DIRS" = "true" ]; then
fi fi
# delete the conf directory if and only if empty # delete the conf directory if and only if empty
if [ -d "$CONF_DIR" ]; then if [ -d "$ES_PATH_CONF" ]; then
rmdir --ignore-fail-on-non-empty "$CONF_DIR" rmdir --ignore-fail-on-non-empty "$ES_PATH_CONF"
fi fi
fi fi

View File

@ -6,7 +6,7 @@ After=network-online.target
[Service] [Service]
Environment=ES_HOME=/usr/share/elasticsearch Environment=ES_HOME=/usr/share/elasticsearch
Environment=CONF_DIR=${path.conf} Environment=ES_PATH_CONF=${path.conf}
Environment=PID_DIR=/var/run/elasticsearch Environment=PID_DIR=/var/run/elasticsearch
EnvironmentFile=-${path.env} EnvironmentFile=-${path.env}

View File

@ -5,7 +5,7 @@
# This script relies on a few environment variables to determine startup # This script relies on a few environment variables to determine startup
# behavior, those variables are: # behavior, those variables are:
# #
# CONF_DIR -- Path to config directory # ES_PATH_CONF -- Path to config directory
# ES_JAVA_OPTS -- External Java Opts on top of the defaults set # ES_JAVA_OPTS -- External Java Opts on top of the defaults set
# #
# Optionally, exact memory values can be set using the `ES_JAVA_OPTS`. Note that # Optionally, exact memory values can be set using the `ES_JAVA_OPTS`. Note that
@ -22,7 +22,7 @@ parse_jvm_options() {
fi fi
} }
ES_JVM_OPTIONS="$CONF_DIR"/jvm.options ES_JVM_OPTIONS="$ES_PATH_CONF"/jvm.options
ES_JAVA_OPTS="`parse_jvm_options "$ES_JVM_OPTIONS"` $ES_JAVA_OPTS" ES_JAVA_OPTS="`parse_jvm_options "$ES_JVM_OPTIONS"` $ES_JAVA_OPTS"
@ -32,7 +32,7 @@ if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null;
"$JAVA" \ "$JAVA" \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \ -Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.bootstrap.Elasticsearch \ org.elasticsearch.bootstrap.Elasticsearch \
"$@" "$@"
@ -41,7 +41,7 @@ else
"$JAVA" \ "$JAVA" \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \ -Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.bootstrap.Elasticsearch \ org.elasticsearch.bootstrap.Elasticsearch \
"$@" \ "$@" \

View File

@ -67,7 +67,7 @@ fi
${source.path.env} ${source.path.env}
if [ -z "$CONF_DIR" ]; then if [ -z "$ES_PATH_CONF" ]; then
echo "CONF_DIR must be set to the configuration path" echo "ES_PATH_CONF must be set to the configuration path"
exit 1 exit 1
fi fi

View File

@ -44,6 +44,6 @@ if not "%JAVA_OPTS%" == "" (
rem check the Java version rem check the Java version
%JAVA% -cp "%ES_CLASSPATH%" "org.elasticsearch.tools.JavaVersionChecker" || exit /b 1 %JAVA% -cp "%ES_CLASSPATH%" "org.elasticsearch.tools.JavaVersionChecker" || exit /b 1
if "%CONF_DIR%" == "" ( if "%ES_PATH_CONF%" == "" (
set CONF_DIR=!ES_HOME!\config set ES_PATH_CONF=!ES_HOME!\config
) )

View File

@ -6,7 +6,7 @@ exec \
"$JAVA" \ "$JAVA" \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \ -Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.common.settings.KeyStoreCli \ org.elasticsearch.common.settings.KeyStoreCli \
"$@" "$@"

View File

@ -7,7 +7,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
%JAVA% ^ %JAVA% ^
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%CONF_DIR%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.common.settings.KeyStoreCli ^ org.elasticsearch.common.settings.KeyStoreCli ^
%* %*

View File

@ -6,7 +6,7 @@ exec \
"$JAVA" \ "$JAVA" \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \ -Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.plugins.PluginCli \ org.elasticsearch.plugins.PluginCli \
"$@" "$@"

View File

@ -7,7 +7,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
%JAVA% ^ %JAVA% ^
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%CONF_DIR%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.plugins.PluginCli ^ org.elasticsearch.plugins.PluginCli ^
%* %*

View File

@ -97,7 +97,7 @@ if exist "%JAVA_HOME%\bin\server\jvm.dll" (
) )
:foundJVM :foundJVM
set ES_JVM_OPTIONS=%CONF_DIR%\jvm.options set ES_JVM_OPTIONS=%ES_PATH_CONF%\jvm.options
if not "%ES_JAVA_OPTS%" == "" set ES_JAVA_OPTS=%ES_JAVA_OPTS: =;% if not "%ES_JAVA_OPTS%" == "" set ES_JAVA_OPTS=%ES_JAVA_OPTS: =;%
@ -174,7 +174,7 @@ if "%JVM_SS%" == "" (
goto:eof goto:eof
) )
set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%CONF_DIR%" set ES_PARAMS=-Delasticsearch;-Des.path.home="%ES_HOME%";-Des.path.conf="%ES_PATH_CONF%"
if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual if "%ES_START_TYPE%" == "" set ES_START_TYPE=manual
if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0 if "%ES_STOP_TIMEOUT%" == "" set ES_STOP_TIMEOUT=0

View File

@ -6,7 +6,7 @@ exec \
"$JAVA" \ "$JAVA" \
$ES_JAVA_OPTS \ $ES_JAVA_OPTS \
-Des.path.home="$ES_HOME" \ -Des.path.home="$ES_HOME" \
-Des.path.conf="$CONF_DIR" \ -Des.path.conf="$ES_PATH_CONF" \
-cp "$ES_CLASSPATH" \ -cp "$ES_CLASSPATH" \
org.elasticsearch.index.translog.TranslogToolCli \ org.elasticsearch.index.translog.TranslogToolCli \
"$@" "$@"

View File

@ -7,7 +7,7 @@ call "%~dp0elasticsearch-env.bat" || exit /b 1
%JAVA% ^ %JAVA% ^
%ES_JAVA_OPTS% ^ %ES_JAVA_OPTS% ^
-Des.path.home="%ES_HOME%" ^ -Des.path.home="%ES_HOME%" ^
-Des.path.conf="%CONF_DIR%" ^ -Des.path.conf="%ES_PATH_CONF%" ^
-cp "%ES_CLASSPATH%" ^ -cp "%ES_CLASSPATH%" ^
org.elasticsearch.index.translog.TranslogToolCli ^ org.elasticsearch.index.translog.TranslogToolCli ^
%* %*

View File

@ -40,7 +40,7 @@ IF ERRORLEVEL 1 (
EXIT /B %ERRORLEVEL% EXIT /B %ERRORLEVEL%
) )
set "ES_JVM_OPTIONS=%CONF_DIR%\jvm.options" set "ES_JVM_OPTIONS=%ES_PATH_CONF%\jvm.options"
@setlocal @setlocal
rem extract the options from the JVM options file %ES_JVM_OPTIONS% rem extract the options from the JVM options file %ES_JVM_OPTIONS%
@ -48,6 +48,6 @@ rem such options are the lines beginning with '-', thus "findstr /b"
for /F "usebackq delims=" %%a in (`findstr /b \- "%ES_JVM_OPTIONS%"`) do set JVM_OPTIONS=!JVM_OPTIONS! %%a for /F "usebackq delims=" %%a in (`findstr /b \- "%ES_JVM_OPTIONS%"`) do set JVM_OPTIONS=!JVM_OPTIONS! %%a
@endlocal & set ES_JAVA_OPTS=%JVM_OPTIONS% %ES_JAVA_OPTS% @endlocal & set ES_JAVA_OPTS=%JVM_OPTIONS% %ES_JAVA_OPTS%
%JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%CONF_DIR%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams! %JAVA% %ES_JAVA_OPTS% -Delasticsearch -Des.path.home="%ES_HOME%" -Des.path.conf="%ES_PATH_CONF%" -cp "%ES_CLASSPATH%" "org.elasticsearch.bootstrap.Elasticsearch" !newparams!
endlocal endlocal

View File

@ -172,7 +172,7 @@ can do this as follows:
[source,sh] [source,sh]
--------------------- ---------------------
sudo CONF_DIR=/path/to/conf/dir bin/elasticsearch-plugin install <plugin name> sudo ES_PATH_CONF=/path/to/conf/dir bin/elasticsearch-plugin install <plugin name>
--------------------- ---------------------
[float] [float]

View File

@ -16,9 +16,18 @@ Previous versions of Elasticsearch enabled setting `path.conf` as a
setting. This was rather convoluted as it meant that you could start setting. This was rather convoluted as it meant that you could start
Elasticsearch with a config file that specified via `path.conf` that Elasticsearch with a config file that specified via `path.conf` that
Elasticsearch should use another config file. Instead, to configure a custom Elasticsearch should use another config file. Instead, to configure a custom
config directory, use the <<config-files-location,`CONF_DIR` environment config directory, use the <<config-files-location,`ES_PATH_CONF` environment
variable>>. variable>>.
==== `CONF_DIR` is no longer supported
Previous versions of Elasticsearch enabled using the `CONF_DIR` environment
variable to specify a custom configuration directory for some configuration
files and some scripts (it was used inconsistently). Starting in Elasticsearch
6.0.0, the usage of this environment variable has been superceded by
`ES_PATH_CONF`, and this new environment variable is consistently used for all
configuration files and scripts.
==== Default path settings are removed ==== Default path settings are removed
Previous versions of Elasticsearch enabled setting `default.path.data` and Previous versions of Elasticsearch enabled setting `default.path.data` and
@ -56,7 +65,7 @@ are no longer maintaining this attempt.
The environment variable `ES_JVM_OPTIONS` that enabled a custom location for the 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 `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 `ES_PATH_CONF`. This environment variable is already used in the packaging to
support relocating the configuration files so this change merely aligns the support relocating the configuration files so this change merely aligns the
other configuration files with the location of the `jvm.options` file. other configuration files with the location of the `jvm.options` file.

View File

@ -25,24 +25,24 @@ on whether or not the installation is from an archive distribution (`tar.gz` or
For the archive distributions, the config directory location defaults to For the archive distributions, the config directory location defaults to
`$ES_HOME/config`. The location of the config directory can be changed via the `$ES_HOME/config`. The location of the config directory can be changed via the
`CONF_DIR` environment variable as follows: `ES_PATH_CONF` environment variable as follows:
[source,sh] [source,sh]
------------------------------- -------------------------------
CONF_DIR=/path/to/my/config ./bin/elasticsearch ES_PATH_CONF=/path/to/my/config ./bin/elasticsearch
------------------------------- -------------------------------
Alternatively, you can `export` the `CONF_DIR` environment variable via the Alternatively, you can `export` the `ES_PATH_CONF` environment variable via the
command line or via your shell profile. command line or via your shell profile.
For the package distributions, the config directory location defaults to For the package distributions, the config directory location defaults to
`/etc/elasticsearch`. The location of the config directory can also be changed `/etc/elasticsearch`. The location of the config directory can also be changed
via the `CONF_DIR` environment variable, but note that setting this in your via the `ES_PATH_CONF` environment variable, but note that setting this in your
shell is not sufficient. Instead, this variabled is sourced from shell is not sufficient. Instead, this variabled is sourced from
`/etc/default/elasticsearch` (for the Debian package) and `/etc/default/elasticsearch` (for the Debian package) and
`/etc/sysconfig/elasticsearch` (for the RPM package). You will need to edit the `/etc/sysconfig/elasticsearch` (for the RPM package). You will need to edit the
`CONF_DIR=/etc/elasticsearch` entry in one of these files accordingly to change `ES_PATH_CONF=/etc/elasticsearch` entry in one of these files accordingly to
the config directory location. change the config directory location.
[float] [float]

View File

@ -197,7 +197,7 @@ locations for a Debian-based system:
| conf | conf
| Configuration files including `elasticsearch.yml` | Configuration files including `elasticsearch.yml`
| /etc/elasticsearch | /etc/elasticsearch
| <<config-files-location,CONF_DIR>> | <<config-files-location,ES_PATH_CONF>>
| conf | conf
| Environment variables including heap size, file descriptors. | Environment variables including heap size, file descriptors.

View File

@ -185,7 +185,7 @@ locations for an RPM-based system:
| conf | conf
| Configuration files including `elasticsearch.yml` | Configuration files including `elasticsearch.yml`
| /etc/elasticsearch | /etc/elasticsearch
| <<config-files-location,CONF_DIR>> | <<config-files-location,ES_PATH_CONF>>
| conf | conf
| Environment variables including heap size, file descriptors. | Environment variables including heap size, file descriptors.

View File

@ -21,10 +21,11 @@
about `max_map_count`. This is set via `sysctl` before starting about `max_map_count`. This is set via `sysctl` before starting
elasticsearch. Defaults to `262144`. elasticsearch. Defaults to `262144`.
`CONF_DIR`:: `ES_PATH_CONF`::
Configuration file directory (which needs to include `elasticsearch.yml` Configuration file directory (which needs to include `elasticsearch.yml`,
and `log4j2.properties` files), defaults to `/etc/elasticsearch`. `jvm.options`, and `log4j2.properties` files); defaults to
`/etc/elasticsearch`.
`ES_JAVA_OPTS`:: `ES_JAVA_OPTS`::

View File

@ -164,7 +164,7 @@ directory so that you do not delete important data later on.
| conf | conf
| Configuration files including `elasticsearch.yml` | Configuration files including `elasticsearch.yml`
| $ES_HOME/config | $ES_HOME/config
| <<config-files-location,CONF_DIR>> | <<config-files-location,ES_PATH_CONF>>
| data | data
| The location of the data files of each index / shard allocated | The location of the data files of each index / shard allocated

View File

@ -169,10 +169,11 @@ The Elasticsearch service can be configured prior to installation by setting the
via the setting `path.logs` in the `elasticsearch.yml` configuration file, via the setting `path.logs` in the `elasticsearch.yml` configuration file,
or on the command line. or on the command line.
`CONF_DIR`:: `ES_PATH_CONF`::
Configuration file directory (which needs to include `elasticsearch.yml` Configuration file directory (which needs to include `elasticsearch.yml`,
and `log4j2.properties` files), defaults to `%ES_HOME%\conf`. `jvm.options`, and `log4j2.properties` files), defaults to
`%ES_HOME%\config`.
`ES_JAVA_OPTS`:: `ES_JAVA_OPTS`::
@ -234,7 +235,7 @@ directory so that you do not delete important data later on.
| conf | conf
| Configuration files including `elasticsearch.yml` | Configuration files including `elasticsearch.yml`
| %ES_HOME%\config | %ES_HOME%\config
| <<config-files-location,CONF_DIR>> | <<config-files-location,ES_PATH_CONF>>
| data | data
| The location of the data files of each index / shard allocated | The location of the data files of each index / shard allocated

View File

@ -68,7 +68,7 @@ default.
It is a good idea to place these directories in a different location so that 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 there is no chance of deleting them when upgrading Elasticsearch. These custom
paths can be <<path-settings,configured>> with the `CONF_DIR` environment paths can be <<path-settings,configured>> with the `ES_PATH_CONF` environment
variable, and the `path.logs`, and `path.data` settings. variable, and the `path.logs`, and `path.data` settings.
The <<deb,Debian>> and <<rpm,RPM>> packages place these directories in the The <<deb,Debian>> and <<rpm,RPM>> packages place these directories in the
@ -89,7 +89,8 @@ To upgrade using a zip or compressed tarball:
* Either copy the files in the `config` directory from your old installation * Either copy the files in the `config` directory from your old installation
to your new installation, or set the environment variable to your new installation, or set the environment variable
<<config-files-location,`CONF_DIR`>> to point to a custom config directory. <<config-files-location,`ES_PATH_CONF`>> to point to a custom config
directory.
* Either copy the files in the `data` directory from your old installation * Either copy the files in the `data` directory from your old installation
to your new installation, or configure the location of the data directory to your new installation, or configure the location of the data directory

View File

@ -111,7 +111,7 @@ setup() {
@test "[TAR] start Elasticsearch with custom JVM options" { @test "[TAR] start Elasticsearch with custom JVM options" {
local es_java_opts=$ES_JAVA_OPTS local es_java_opts=$ES_JAVA_OPTS
local conf_dir=$CONF_DIR local es_path_conf=$ES_PATH_CONF
local temp=`mktemp -d` local temp=`mktemp -d`
cp "$ESCONFIG"/elasticsearch.yml "$temp" cp "$ESCONFIG"/elasticsearch.yml "$temp"
cp "$ESCONFIG"/log4j2.properties "$temp" cp "$ESCONFIG"/log4j2.properties "$temp"
@ -123,13 +123,13 @@ setup() {
# manager exception before we have configured logging; this will fail # manager exception before we have configured logging; this will fail
# startup since we detect usages of logging before it is configured # startup since we detect usages of logging before it is configured
echo "-Dlog4j2.disable.jmx=true" >> "$temp/jvm.options" echo "-Dlog4j2.disable.jmx=true" >> "$temp/jvm.options"
export CONF_DIR="$temp" export ES_PATH_CONF="$temp"
export ES_JAVA_OPTS="-XX:-UseCompressedOops" export ES_JAVA_OPTS="-XX:-UseCompressedOops"
start_elasticsearch_service start_elasticsearch_service
curl -s -XGET localhost:9200/_nodes | fgrep '"heap_init_in_bytes":536870912' 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"' curl -s -XGET localhost:9200/_nodes | fgrep '"using_compressed_ordinary_object_pointers":"false"'
stop_elasticsearch_service stop_elasticsearch_service
export CONF_DIR=$CONF_DIR export ES_PATH_CONF=$es_path_conf
export ES_JAVA_OPTS=$es_java_opts export ES_JAVA_OPTS=$es_java_opts
} }

View File

@ -201,7 +201,7 @@ setup() {
# startup since we detect usages of logging before it is configured # startup since we detect usages of logging before it is configured
echo "-Dlog4j2.disable.jmx=true" >> "$temp/jvm.options" echo "-Dlog4j2.disable.jmx=true" >> "$temp/jvm.options"
cp $ESENVFILE "$temp/elasticsearch" cp $ESENVFILE "$temp/elasticsearch"
echo "CONF_DIR=\"$temp\"" >> $ESENVFILE echo "ES_PATH_CONF=\"$temp\"" >> $ESENVFILE
echo "ES_JAVA_OPTS=\"-XX:-UseCompressedOops\"" >> $ESENVFILE echo "ES_JAVA_OPTS=\"-XX:-UseCompressedOops\"" >> $ESENVFILE
service elasticsearch start service elasticsearch start
wait_for_elasticsearch_status wait_for_elasticsearch_status

View File

@ -132,7 +132,7 @@ setup() {
# startup since we detect usages of logging before it is configured # startup since we detect usages of logging before it is configured
echo "-Dlog4j2.disable.jmx=true" >> "$temp/jvm.options" echo "-Dlog4j2.disable.jmx=true" >> "$temp/jvm.options"
cp $ESENVFILE "$temp/elasticsearch" cp $ESENVFILE "$temp/elasticsearch"
echo "CONF_DIR=\"$temp\"" >> $ESENVFILE echo "ES_PATH_CONF=\"$temp\"" >> $ESENVFILE
echo "ES_JAVA_OPTS=\"-XX:-UseCompressedOops\"" >> $ESENVFILE echo "ES_JAVA_OPTS=\"-XX:-UseCompressedOops\"" >> $ESENVFILE
service elasticsearch start service elasticsearch start
wait_for_elasticsearch_status wait_for_elasticsearch_status

View File

@ -117,11 +117,11 @@ fi
move_config move_config
CONF_DIR="$ESCONFIG" install_jvm_example ES_PATH_CONF="$ESCONFIG" install_jvm_example
CONF_DIR="$ESCONFIG" start_elasticsearch_service ES_PATH_CONF="$ESCONFIG" start_elasticsearch_service
diff <(curl -s localhost:9200/_cat/configured_example | sed 's/ //g') <(echo "foo") diff <(curl -s localhost:9200/_cat/configured_example | sed 's/ //g') <(echo "foo")
stop_elasticsearch_service stop_elasticsearch_service
CONF_DIR="$ESCONFIG" remove_jvm_example ES_PATH_CONF="$ESCONFIG" remove_jvm_example
} }
@test "[$GROUP] install jvm-example plugin from a directory with a space" { @test "[$GROUP] install jvm-example plugin from a directory with a space" {

View File

@ -38,11 +38,11 @@ install_plugin() {
assert_file_exist "$path" assert_file_exist "$path"
if [ ! -z "$CONF_DIR" ] ; then if [ ! -z "$ES_PATH_CONF" ] ; then
if is_dpkg; then if is_dpkg; then
echo "CONF_DIR=$CONF_DIR" >> /etc/default/elasticsearch; echo "ES_PATH_CONF=$ES_PATH_CONF" >> /etc/default/elasticsearch;
elif is_rpm; then elif is_rpm; then
echo "CONF_DIR=$CONF_DIR" >> /etc/sysconfig/elasticsearch; echo "ES_PATH_CONF=$ES_PATH_CONF" >> /etc/sysconfig/elasticsearch;
fi fi
fi fi

View File

@ -335,12 +335,12 @@ start_elasticsearch_service() {
run_elasticsearch_service() { run_elasticsearch_service() {
local expectedStatus=$1 local expectedStatus=$1
local commandLineArgs=$2 local commandLineArgs=$2
# Set the CONF_DIR setting in case we start as a service # Set the ES_PATH_CONF setting in case we start as a service
if [ ! -z "$CONF_DIR" ] ; then if [ ! -z "$ES_PATH_CONF" ] ; then
if is_dpkg; then if is_dpkg; then
echo "CONF_DIR=$CONF_DIR" >> /etc/default/elasticsearch; echo "ES_PATH_CONF=$ES_PATH_CONF" >> /etc/default/elasticsearch;
elif is_rpm; then elif is_rpm; then
echo "CONF_DIR=$CONF_DIR" >> /etc/sysconfig/elasticsearch; echo "ES_PATH_CONF=$ES_PATH_CONF" >> /etc/sysconfig/elasticsearch;
fi fi
fi fi
@ -362,7 +362,7 @@ run_elasticsearch_service() {
# This line is attempting to emulate the on login behavior of /usr/share/upstart/sessions/jayatana.conf # 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" [ -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). # And now we can start Elasticsearch normally, in the background (-d) and with a pidfile (-p).
export CONF_DIR=$CONF_DIR export ES_PATH_CONF=$ES_PATH_CONF
export ES_JAVA_OPTS=$ES_JAVA_OPTS export ES_JAVA_OPTS=$ES_JAVA_OPTS
$timeoutCommand/tmp/elasticsearch/bin/elasticsearch $background -p /tmp/elasticsearch/elasticsearch.pid $commandLineArgs $timeoutCommand/tmp/elasticsearch/bin/elasticsearch $background -p /tmp/elasticsearch/elasticsearch.pid $commandLineArgs
BASH BASH