设置elasticsearch的默认分区数和副本数

日志是从logstash传输给ES的,但是logstash配置中只能配置host和index,所以只能在es中进行配置

但是在es配置文件中配置,也就是新增如下参数的话会报错:node settings must not contain any index level settings

index.number_of_shards: 1
index.number_of_replicas: 0

所以采用索引模板的方式进行设置

POST /_templates/index_patterns
{
  "order": 0,
  "index_patterns": [
    "filebeat_*"
  ],
  "settings": {
    "index": {
      "number_of_shards": "1",
      "number_of_replicas": "0"
    }
  },
  "mappings": {},
  "aliases": {}
}

凡是索引名是filebeat_*的,分片数是1 ,副本数是0

原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/11988530.html