节点离开延迟分配
index.unassigned.node_left.delayed_timeout
默认为1m
. 当一个节点出于某种原因离开集群时,无论是有意的还是其他的,主节点的反应是:
- 将副本分片提升为主分片以替换节点上的任何主分片。
- 分配副本分片以替换丢失的副本(假设有足够的节点)。
- 在剩余节点上均匀地重新平衡分片。
如果一个节点被删除永远不会返回,希望 Elasticsearch 立即分配丢失的分片,只需将超时更新为0
PUT _all/_settings
{
"settings": {
"index.unassigned.node_left.delayed_timeout": "0"
}
}
索引恢复优先级
尽可能按优先级顺序恢复未分配的分片。指数按优先级排序如下:
数据冷热节点角色
- data_content
- data_hot
- data_warm
- data_cold
- data_frozen
index.routing.allocation.include._tier: data_warm
index.routing.allocation.require._tier: data_warm
index.routing.allocation.exclude._tier: data_warm
index.routing.allocation.include._tier_preference: data_warm,data_hot
索引块
index.blocks.read_only: true
index.blocks.read_only_allow_delete: true
index.blocks.read: true
index.blocks.write: true
index.blocks.metadata: true
操作
PUT /my-index-000001/_block/<block>
慢日志
- 系统级别
// 可以动态设置,threshold默认disabled,为-1
PUT /my-index-000001/_settings
{
"index.search.slowlog.threshold.query.warn": "10s",
"index.search.slowlog.threshold.query.info": "5s",
"index.search.slowlog.threshold.query.debug": "2s",
"index.search.slowlog.threshold.query.trace": "500ms",
"index.search.slowlog.threshold.fetch.warn": "1s",
"index.search.slowlog.threshold.fetch.info": "800ms",
"index.search.slowlog.threshold.fetch.debug": "500ms",
"index.search.slowlog.threshold.fetch.trace": "200ms"
}
- 索引级别,文件名以
_index_indexing_slowlog.log
结尾PUT /my-index-000001/_settings
{
"index.indexing.slowlog.threshold.index.warn": "10s",
"index.indexing.slowlog.threshold.index.info": "5s",
"index.indexing.slowlog.threshold.index.debug": "2s",
"index.indexing.slowlog.threshold.index.trace": "500ms",
"index.indexing.slowlog.source": "1000"
}
存储
store
模块允许控制索引数据在磁盘上的存储和访问方式,建议采用默认值.
事务日志
ES提交到Lucene的索引、删除、分片拷贝、写等操作在未确认之前都会写入translog
.
index.translog.durability: request
index.translog.durability: async
index.translog.sync_interval: 5s
index.translog.flush_threshold_size: 512mb
历史保留-软删除
index.soft_deletes.enabled: true
index.soft_deletes.retention_lease.period: 12h
索引排序
默认不排序.
index.sort.field: ["username"]
index.sort.order: ["asc"]
index.sort.mode: min
index.sort.missing: _last
示例
PUT my-index-000001
{
"settings": {
"index": {
"sort.field": [ "username", "date" ],
"sort.order": [ "asc", "desc" ]
}
},
"mappings": {
"properties": {
"username": {
"type": "keyword",
"doc_values": true
},
"date": {
"type": "date"
}
}
}
}
indexing pressure
indexing_pressure.memory.limit: 10%