Install and configure a remote Elasticsearch instance
Install Elasticsearch on a remote machine
We don't provide specific instructions for installing Elasticsearch, but a good place to start is the Elasticsearch installation instructions. Elastic provides installation packages in several different formats on their downloads page.
Note that the authentication plugin – Buckler, described within the Secure your remote Elasticsearch instance section – only supports version 2.3 of Elasticsearch. Refer to the Supported Platforms - Additional Tools page to see the current Elasticsearch release we support.
Elasticsearch ports
Bitbucket Server's bundled Elasticsearch instance requires ports 7992 and 7993 be available to provide code search functionality. This is not configurable, so ensure these ports are available.
Configure your remote Elasticsearch instance
The 
          elasticsearch.yml
         file contains configuration details for your Elasticsearch instance.
To configure your remote Elasticsearch instance to be compatible with Bitbucket Server
- Locate the elasticsearch.ymlfile within the configuration path of your Elasticsearch instance.
- Add these parameters to your - elasticsearch.ymlfile
 - Parameter - Value - index.mapper.dynamic- false- action.auto_create_index- false- network.host- 0.0.0.0- Third party plugins, such as Elastic's Shield plugin, may require specific exceptions to be set for - action.auto_create_index. Consult your provider's documentation for more information.
Secure your remote Elasticsearch instance
After you've completed installing Bitbucket Server, you need to secure access to your remote Elasticsearch instance with a username and password. Atlassian recommends securing your remote Elasticsearch instance with a security plugin that requires anyone connecting to it provides authentication credentials. Atlassian provides a free plugin called Buckler for this purpose. Bitbucket Server also supports authentication to Elasticsearch through other plugins that provide basic authentication, like Elastic's Shield plugin.
To secure your remote Elasticsearch instance with the Buckler plugin
- Download the Buckler plugin on the remote machine: - Elasticsearch 2.3.1 - Buckler 0.2.11 for ES 2.3.1 - Elasticsearch 2.3.2 - Buckler 0.2.11 for ES 2.3.2 - Elasticsearch 2.3.3 - Buckler 0.2.11 for ES 2.3.3 - Elasticsearch 2.3.4 - Buckler 0.2.11 for ES 2.3.4 
- Install the plugin onto your remote Elasticsearch instance using the plugin helper in the Elasticsearch - /bindirectory:- cd /path/to/elasticsearch/bin ./plugin install -b <link from table above>
- Configure basic authentication (at minimum) using the Buckler authentication plugin. - Within the elasticsearch/configdirectory, create a directory calledbuckler.
- Create a file named buckler.yml. By default there is no configuration, which means all the features of the Buckler plugin are disabled.
- Enable basic authentication by adding the following properties, modifying the parameters for your company's details. 
 
- Within the 
Connect your Elasticsearch instance to Bitbucket Server
Once you've configured your Elasticsearch instance you need to connect it to Bitbucket Server.
To connect your remote Elasticsearch instance to Bitbucket Server via the bitbucket.properties file
Another way to configure connection settings is via bitbucket.properties file (resides in $BITBUCKET_HOME/shared).
If a parameter is set in the properties file, it cannot be edited later from the admin UI. Any changes that need to be made to the Elasticsearch configuration must be made within the bitbucket.properties file.
- In the $BITBUCKET_HOMEdirectory, create a new directory calledshared.
- In the $BITBUCKET_HOME/shareddirectory, create a text file namedbitbucket.properties.
- Add these Elasticsearch properties to the file. PropertyParameter name for properties file- URL - plugin.search.elasticsearch.baseurl- Username - plugin.search.elasticsearch.username- Password - plugin.search.elasticsearch.password
- Save and close the file. 
- Start Bitbucket Server.
Configure details of your Elasticsearch instance within Bitbucket Server
To configure the details of your Elasticsearch instance within the Bitbucket Server UI, go to the Administration settings page, then click Server Settings. At the bottom of the page is where you can configure the details of your Elasticsearch instance.
If a parameter is set in the 
              bitbucket.properties
             file, it cannot be edited later from the admin UI. Any changes that need to be made to the Elasticsearch configuration must be made within the bitbucket.properties file.
Migrate from using the bundled Elasticsearch instance to using a remote Elasticsearch instance
To begin using a remote instance of Elasticsearch after having previously installed a standard instance of Bitbucket Server, which uses the bundled Elasticsearch instance:
- Install the remote Elasticsearch instance.
- Configure the remote Elasticsearch instance to work with Bitbucket Server.
- Secure the remote Elasticsearch instance.
- Configure the remote Elasticsearch instance details within Bitbucket Server.
To start Bitbucket Server when using a remote Elasticsearch instance, use start-webapp.sh 
Once your remote Elasticsearch instance is installed, configured, and secured, you will start Bitbucket Server by running start-webapp.sh instead of start-bitbucket.sh. This starts Bitbucket Server without running the bundled Elasticsearch instance.

