Search code examples
elasticsearchcluster-computingelastic-stackelkelasticsearch-7

Config number_of_shards and number_of_replicas in ELK


I keep studying about ELK Stack and ran into a little problem.

I have been reading all the documentation possible and it makes great emphasis on the importance of shards and replicas. But nowhere does it say how to configure the number of each one. I have read some site that says that it is better to leave it in automatic and others that say how to configure it in version 5.8 but that no longer works.

So if someone can explain to me I would be very grateful.


Solution

  • When you create an index, you can configure both values in the settings of that index:

    PUT your-index
    {
      "settings": {
        "index.number_of_shards": 3,
        "index.number_of_replicas": 1
      }
    }
    

    Also note that you can update the settings of an index after its creation, but you can only update the number of replicas and not the number of primary shards:

    PUT your-index/_settings
    {
      "settings": {
        "index.number_of_replicas": 2
      }
    }
    

    As simple as that!