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 ' {"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 @ 2020-12-17 10:00  技术颜良  阅读(2393)  评论(0编辑  收藏  举报