How to change data location for Elasticsearch
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
This guide will help you change the location for the logs and data for the Elasticsearch instance that is bundled with Bitbucket.
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 |
---|---|
LOG_DIR | -Des.path.logs="%LOG_DIR%" |
DATA_DIR | -Des.path.data="%DATA_DIR%" |
CONF_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 Bitbucket version up to 4.14.x:
Open the command window from
Start >> Run >> type in 'cmd' >> Enter
cd
to thebin
directory<Bitbucket Server installation directory>\bin
Run from there:
tomcat8w //ES//AtlassianBitbucketElasticsearch
where
AtlassianBitbucketElasticsearch
is the service name (you should be able to correctly identify the service name by "right-clicking" on Find the service whose name begins with Atlassian Stash in the list, then right-click on the "Search" service and selecting "Properties". The resulting window have a field "Service Name" right on top that you could use to substitute theAtlassianBitbucketElasticsearch
above - this is the default name the installer uses.
A window will pop up. Click on the Java tab to see the list of current start-up options. Under "Java Options:" form, do you see any of the following JVM parameters. Update them to point to the directory you want them to be stored:
-Des.path.logs
-Des.path.data
To do that in Bitbucket version 5.x+:
Open the command window from
Start >> Run >> type in 'cmd' >> Enter
cd
to thebin
directory<Bitbucket Server installation directory>\elasticsearch\bin
Run from there:
elasticsearch-service-mgr.exe //ES//AtlassianBitbucketElasticsearch
where
AtlassianBitbucketElasticsearch
is the service name (you should be able to correctly identify the service name by "right-clicking" on Find the service whose name begins with Atlassian Stash in the list, then right-click on the "Search" service and selecting "Properties". The resulting window have a field "Service Name" right on top that you could use to substitute theAtlassianBitbucketElasticsearch
above - this is the default name the installer uses.
A window will pop up. Click on the Java tab to see the list of current start-up options. Under "Java Options:" form, do you see any of the following JVM parameters. Update them to point to the directory you want them to be stored:
-Des.path.logs
-Des.path.data
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
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.bat
set _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.bat
set _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.sh
ES_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.sh
ES_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
Was this helpful?