es number_of_shards和number_of_replicas

number_of_replicas 是数据备份数,如果只有一台机器,设置为0

number_of_shards  是数据分片数,默认为5,有时候设置为3

可以在线改所有配置的参数,number_of_shards不可以在线改

curl -XPUT '10.0.120.39:9200/_settings' -d ' { "index" : { "number_of_replicas" : 0 } }'

如果要所有的配置都生效,修改配置文件:

index.number_of_shards: 3
index.number_of_replicas: 0

如果每次生成索引的时候没生效,就要注意是否有索引模板了,索引模板生成的时候已经制定了参数

 

上面命令在elasticsearch 6.x 用不了了,修改如下:

curl -X PUT "10.10.10.10:9200/filebeat*/_settings" -H 'Content-Type: application/json' -d'
{
    "index" : {
        "number_of_replicas" : 0
    }
}
'

 要对后面新的index有效,要创建一个默认模板(模板很重要,模板可以为所欲为):

curl -X PUT "10.10.10.10:9200/_template/template_log" -H 'Content-Type: application/json' -d'
{
    "index_patterns" : ["filebeat*"],
    "order" : 0,
    "settings" : {
        "number_of_replicas" : 0
    }
}
'

 

posted @ 2017-12-13 11:01  行知散人  阅读(45557)  评论(1编辑  收藏  举报