简体   繁体   English

在创建分片之前,Elasticsearch是否检查集群中可用的节点数(如果选择了默认分片大小)

[英]Does Elasticsearch check for the number of nodes available in the cluster before creating the shards(in cases when default shard size is selected)

i have a cluster with single node in it.. i had created an index A with default shard size(ie in elasticsearch.yml file the value of index.number_of_shards: 1 ). 我有在它单个节点集群..我曾与默认碎片大小创建的索引A(即,在文件elasticsearch.yml index.number_of_shards的值:1)。 When i listed all my shards, i could see single shard for index A . 当我列出所有碎片时,我可以看到索引A的单个碎片。 After this i changed the value of index.number_of_shards: 4 in elasticsearch.yml and then created another index B . 在此之后我改变index.number_of_shards的值:4 elasticsearch.yml然后创建的另一个索引B中 again when i listed all my shards in the cluster i could only see single shard created for index B instead of 4 shards. 再一次,当我列出集群中的所有分片时,我只能看到为索引B创建的单个分片,而不是4个分片。 Does Elasticsearch check for the total number of nodes present in a cluster before creating the index and assigning the shards(in my case i had not specified any no of shards while creating the index B , so i was expecting total of 4 shards to be created for my index). Elasticsearch是否在创建索引和分配分片之前检查集群中存在的节点总数(在我的情况下,在创建索引B时我没有指定任何分片数量,因此我希望总共创建4个分片作为我的索引)。 can you help me with this? 你能帮我吗?

The index configuration on elasticsearch.yml is being deprecated in favor of passing this configuration on the index settings/mapping instead. 不推荐使用elasticsearch.yml上的索引配置,而是希望通过此配置传递索引设置/映射。

So what you have to do is to remove index configurations from the elasticsearch.yml file and pass them using index settings or template. 因此,您要做的是从elasticsearch.yml文件中删除索引配置,并使用索引设置或模板传递它们。 From elastic docs: 从弹性文档:

curl -XPUT 'http://localhost:9200/twitter/' -d '{
"settings" : {
    "index" : {
        "number_of_shards" : 3, 
        "number_of_replicas" : 2 
    }
}

Using this approach you can create different configurations for each index. 使用这种方法,您可以为每个索引创建不同的配置。

Note: elasticsearch.yml is a "global" / static configuration file of elasticsearch that is read during startup and if you change it it will not affect current running instances. 注意:elasticsearch.yml是启动期间读取的Elasticsearch的“全局” /静态配置文件,如果进行更改,它将不会影响当前正在运行的实例。

Does Elasticsearch check for the total number of nodes present in a cluster before creating the index and assigning the shards 在创建索引和分配分片之前,Elasticsearch是否检查集群中存在的节点总数?

No. It will happily create many shards for the same index on the same node. 不会。它将为同一节点上的同一索引高兴地创建许多碎片。 Most likely you didn't restart ES after changing elasticsearch.yml. 您很可能在更改elasticsearch.yml后没有重新启动ES。 It's not read live, so any changes to it require a restart to take effect. 它不是实时读取的,因此对它的任何更改都需要重新启动才能生效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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