【问题标题】:Elasticsearch Marvel. Primary & Replicas Shards弹性搜索奇迹。主分片和副本分片
【发布时间】:2014-02-22 14:56:46
【问题描述】:

对于 ElasticSearch 新发布的 Marvel,我想问一个问题,我们是否可以调整它在创建索引时创建的副本数量,即每次创建索引时。它目前创建一个主分片和一个副本分片。这可以永久调整吗?

谢谢

副本更新

curl -XPUT localhost:9200/_template/marvel_custom -d '
{
    "order" : 1,
    "template" : ".marvel*",
    "settings" : {
        "number_of_replicas" : 0
    }
}'

【问题讨论】:

    标签: plugins elasticsearch elasticsearch-marvel


    【解决方案1】:

    默认情况下,Elasticsearch Marvel 会将数据索引到每日索引中,类似于 logstash 所做的。它首先提交一个index template,其中包含其索引的默认设置和映射,如here 所述。您可以看到默认索引模板只是通过 id 检索它:

    curl -XGET localhost:9200/_template/marvel
    

    您绝对可以通过提交具有相同名称的更新版本来更改它,但请确保不要更改默认映射或其他任何内容。

    实际上,我建议不要更改默认索引模板,而是添加一个额外的,顺序高于 0 的模板,它仅适用于您的自定义设置:

    curl -XPUT localhost:9200/_template/marvel_custom -d '
    {
        "order" : 1,
        "template" : ".marvel*",
        "settings" : {
            "number_of_shards" : 5
        }
    }
    '
    

    这样两个模板都将被应用,并且在涉及相同名称的设置时,具有最高顺序的模板将获胜。

    【讨论】:

    • 请注意,奇迹文档现在包含相同的示例,并且更具体地说明了如何更改默认索引设置。
    【解决方案2】:

    新模板不应该包含 index.number_of_replicas 0 吗?似乎如果没有指定,那么它将回退到默认值,即一个

    curl -XPUT localhost:9200/_template/marvel_custom
    {
        "order" : 1,
        "template" : ".marvel*",
        "settings" : {
            "number_of_shards" : "5",
            "index.number_of_replicas" : "0"
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-14
      相关资源
      最近更新 更多