How to change data location for Elasticsearch
Purpose
This guide will help you change the location for the logs and data for the Elasticsearch instance that is bundled with Bibtucket.
Solution
If you have installed your instance on:
Windows
With a Windows service
If you installed Windows as a service using our installer, the following actions were taken:
System Variables called:
Variable name
Variable value
LOG_DIR
%BITBUCKET_HOME%\log\search
DATA_DIR
%BITBUCKET_HOME%\shared\search\data
CONF_DIR
%BITBUCKET_HOME%\shared\search
During the service configuration, these variables were hardcoded in the Windows Service as the following JVM parameters:
Variable name
Variable value
-Des.path.logs="%LOG_DIR%"
-Des.path.data="%DATA_DIR%"
-Des.path.conf=%CONF_DIR%"
So if you're running a service on Windows you need to first update the following system variables to:
Variable name | Variable value |
---|---|
LOG_DIR | D:\the\path\you\want |
DATA_DIR | D:\the\path\you\want |
CONF_DIR | Don't change it |
From here, you can choose to apply one of the alternatives below.
Update the JVM parameters directly on the service
Variable name | Variable value |
---|---|
LOG_DIR | D:\the\path\you\want |
DATA_DIR | D:\the\path\you\want |
CONF_DIR | Don't change it |
To do that in ...
Remove the previous service and install a new one
Because you've now updated the system variables LOG_DIR and DATA_DIR, you could uninstall the old service and install a new one. Because the system variables are now set to the right values, the service will be installed correctly as the script uses the values of those variables.
In order to do that, run:
cd <Bitbucket Server installation directory>\elasticsearch\bin you could run
service.bat remove
service.bat install
Without a Windows service
Update the following system variables (if they exist). Don't worry about them otherwise.
Variable name | Variable value |
---|---|
LOG_DIR | D:\the\path\you\want |
DATA_DIR | D:\the\path\you\want |
CONF_DIR | Don't change it |
For Bitbucket version up to 4.14.x
Change the script below and set the paths where you want your Elasticsearch data/log to be stored:
<Bitbucket Server Installation>\\bin\\start-search.batset _ES_LOG_PATH=%BITBUCKET_HOME%\log\search set _ES_DATA_PATH=%BITBUCKET_HOME%\shared\search\data
Start your application manually: Starting and stopping Bitbucket Server
> cd <Bitbucket Server installation directory> > bin\stop-search.bat > bin\start-search.bat
For Bitbucket version 5.x+
Change the script below and set the paths where you want your Elasticsearch data/log to be stored:
<Bitbucket Server Installation>\\bin\\_start-search.batset _ES_LOG_PATH=%BITBUCKET_HOME%\log\search set _ES_DATA_PATH=%BITBUCKET_HOME%\shared\search\data
Start your application manually: Starting and stopping Bitbucket Server
> cd <Bitbucket Server installation directory> > bin\stop-bitbucket.bat > bin\start-bitbucket.bat
Linux
Bitbucket version up to 4.14.x
Simply change the script below and adapt the variables to the directory where you want Elasticsearch to store log/data:
<Bitbucket_Installation_Dir>/bin/start-search.shES_LOG_PATH="$BITBUCKET_HOME/log/search" ES_DATA_PATH="$BITBUCKET_HOME/shared/search/data"
Restart your Elasticsearch service
# service atlbitbucket_search status # service atlbitbucket_search stop # service atlbitbucket_search start
Bitbucket version 5.x+
Simply change the script below and adapt the variables to the directory where you want Elasticsearch to store log/data:
<Bitbucket_Installation_Dir>/bin/_start-search.shES_LOG_PATH="$BITBUCKET_HOME/log/search" ES_DATA_PATH="$BITBUCKET_HOME/shared/search/data"
Restart the Bitbucket Server service to restart Elasticsearch as well
# service atlbitbucket status # service atlbitbucket stop # service atlbitbucket start