索引一旦创建无法修改分片数,但是可以使用reindex重建索引。
可以修改单个索引副本数量
PUT /testindex/_settings
{
"number_of_replicas" : 2
}
新建模板修改默认分片数
查看所有模板
GET _template
创建新索引模板,设置三个分片0个副本
PUT _template/logstash
{
"template": "*", 匹配所有索引
"order": 0, 优先级
"settings": {
"index": {
"number_of_replicas": "0",
"number_of_shards": "3",
"refresh_interval": "5s"
}
},
"mappings": {
"_default_": {
"dynamic_templates": [
{
"message_field": {
"path_match": "message",
"mapping": {
"norms": false,
"type": "text"
},
"match_mapping_type": "string"
}
},
{
"string_fields": {
"mapping": {
"norms": false,
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"match_mapping_type": "string",
"match": "*"
}
}
],
"_all": {
"norms": false,
"enabled": true
},
"properties": {
"@timestamp": {
"include_in_all": false,
"type": "date"
},
"geoip": {
"dynamic": true,
"properties": {
"ip": {
"type": "ip"
},
"latitude": {
"type": "half_float"
},
"location": {
"type": "geo_point"
},
"longitude": {
"type": "half_float"
}
}
},
"@version": {
"include_in_all": false,
"type": "keyword"
}
}
}
},
"aliases": {}
}
查看新创建模板信息
GET /_template/logstash
网友评论