index.number_of_replicas可以在ESv2.x中设置为静态索引设置吗?

Can index.number_of_replicas be set as a static index setting in ES v2.x?

在 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,Marvel 索引仍会自动使用 number_of_replicas: 1 创建。它也没有与静态设置一起列出 in the docs.

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

该静态设置在 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 索引中看到副本碎片,那是因为必须有一个 .marvel-es template 指定不同的索引设置。