ElasticSearch

一、ES查询集群里运行的节点(实例/数据库)

http://localhost:9200/_cat/nodes

get  _cat/nodes?v  -----节点信息

get  _cat/shards  -----分片信息

get  _cluster/health  -----查看集群运行状态

注:API名以下划线开头

监控ES集群API

get _cluster/stats

包含了多少个索引;索引上一共有多少分片;集群中文档总数;占用存储空间;节点数;

get _nodes/stats

包含了节点上多少个索引;文档总数;

get 索引名/_stats

number_of_shards:主分片数

number_of_replicas:副本分片数

提升集群写性能

 norm 设置成 false

数据写入过程

refresh:将文档先保存在 index buffer 中,以 refresh_interval 为时间间隔,定期清空 buffer,生成 segment,借助文件系统缓存的特性,先将segment放在文件系统缓存中,并开放查询,以提升搜索的实时性。

translog:segment没有写入磁盘,即便发生了宕机,重启后,数据也能恢复,默认配置是每次请求都会落盘。

降低写磁盘的频率,但是会降低容灾能力

index.translog.durability:默认是 request ,每个请求都落盘。设置成 async,异步写入。

index.translog.sync_interval:设置为 60s,每分钟执行一次。

index.translog.flush_threshod_size:默认512MB,可以适当调大。当translog超过该值,会触发flush。

一个索引设定的例子:

put myindex
{
    "settings":{
        "index":{
            "refresh_interval":"30s",
            "number_of_shards":"2"
        },
        "routing":{
            "allocation":{
                "total_shards_per_node":"3"
            }
        },
        "translog":{
            "sync_interval":"30s",
            "durability":"async"
        },
        "number_of_replicas":0
    },
    "mapping":{
        "dynamic":false,
        "propertise":{}
    }
}

ES官方配置建议:https://www.elastic.co/guide/en/elasticsearch/reference/7.1/system-config.html

ES中的字段类型以及常用属性:https://www.cnblogs.com/xing901022/p/5471419.html
ES写入速度:https://juejin.cn/post/6885320503867736078

原文地址:https://www.cnblogs.com/yinguojin/p/13974535.html