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 } } '