How to change number of shards for Elastic search in Bitbucket server?

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

From Elastic search version 7 (we are on 7.5.x), the default value for the number of primary shards per index is 1. In earlier versions, the default was 5 shards. 

Environment

Bitbucket Server and Datacenter

Elastic search 7.5.2

Solution

Bitbucket uses index templates when creating the indices and configures the number of shards to 5. The shard configuration can be changed with a system property applied through an environmental variable JVM_SUPPORT_RECOMMENDED_ARGS=-Dindex.codesearch.node.shards.num=1 (for example, to change the shards from 5 to 1)

  1. Shut down Bitbucket
  2. In the start-webapp.sh file located at $BITBUCKET_INSTALLATION_DIR/bin, there is a line that says JVM_SUPPORT_RECOMMENDED_ARGS=
  3. Uncomment out the line and add: -Dindex.codesearch.node.shards.num=1
    JVM_SUPPORT_RECOMMENDED_ARGS=-Dindex.codesearch.node.shards.num=1
  4. Restart Bitbucket
  5. Perform a full re-index of the Elasticsearch index

(warning)  Please ensure you perform a full re-index if Elasticsearch index or the indices might get corrupted. 


Last modified on Feb 15, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.