简体   繁体   中英

Elasticsearch 7.5.2 cluster is creating only one shard for an index by default

I have a newly setup Elasticsearch 7.5.2 cluster. When I create an index, only one shard is created default for it.

My cluster strategy is as below:

Total Nodes: 5
--------------
Node 1 & Node 2 - Master Only
Node 3          - Master & Data Node
Node 4 & Node 5 - Data Only

Could not find any cluster setting that is restricting the shards for index creation. 在此处输入图片说明 Is the issue with cluster strategy or am I missing any settings here?.

Please help me to find the the issue.

Earlier Elasticsearch had default number of primary shards to 5, which is changed from Elasticsearch 7.X, which you are using, hence you are seeing just 1 primary shard.

Elasticsearch link for this change and more info on this SO answer.

Apart from API which is applicable on a particular index, which @Kamal already mentioned, you can specify this setting in your elasticsearch.yml , which would be effective on every index created until you override using the API call.

Config to add in your elasticsearch.yml

index.number_of_shards: {your desired number of shards}

Note: This is for primary shards that can't be changed dynamically, so be cautious of setting this, Unlike the number of replicas which can be changed dynamically.

That is correct. Post version 7, Elasticsearch by default creates index with shard size 1 as mentioned here

You can always specify the index shard using the below settings, while creating the index.

PUT <your_index_name>
{
    "settings" : {
        "index" : {
            "number_of_shards" : 5
        }
    }
}

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM