可以将index.number_of_replicas设置为ES v2.x中的静态索引设置吗?

时间:2016-05-30 02:11:49

标签: elasticsearch elasticsearch-2.0

在elasticsearch v1.x中,我可以静态设置index.number_of_replicas(在elasticsearch.yml文件中):

# Set the number of replicas (additional copies) of an index (1 by default):
index.number_of_replicas: 0

但是,我现在正在为v2.3整理配置文件,此设置不再有任何效果。

例如,如果我将上述代码添加到elasticsearch.yml文件并启动ES v2.3,则仍会使用number_of_replicas: 1自动创建Marvel索引。它也没有列出静态设置this question

自v1.x以来它有变化,还是我做错了什么?这只能通过动态设置完成吗?

1 个答案:

答案 0 :(得分:1)

静态设置仍然适用于2.3。您可以尝试简单地创建新索引而不指定任何设置:

PUT /test/test/1

在日志中,您会看到以下内容:

[2016-05-30 05:49:45,836][INFO ][cluster.metadata         ] [dev-node-1] [test] creating index, cause [auto(index api)], templates [], shards [2]/[0], mappings [test]

[2]/[0]表示我默认设置了两个主分片和0个副本分片。

如果您在漫威索引中看到副本分片,那么因为必须有.marvel-es template指定不同的索引设置。