ES集群节点介绍

在这里插入图片描述

  • master node:整个集群的管理者,索引管理,分片管理,以及整个集群的状态的管理,master节点是从master候选节点中选出的,成为master候选节点的方式:
    node.master:true 默认(true)
  • data node:数据节点,存储主要数据,负责索引的数据的检索和聚合等操作,成为data node的方式:
    node.data:true 默认(true)
  • coordinating node:协调节点,所有节点都可以接受来自客户端的请求进行转发,因为每个节点都知道集群的所有索引分片的分布情况,但是别的节点,都还肩负着别的工作,如果请求压力过大,可能会拖垮整个集群的响应速度,所以就专门有了这个协调节点,他什么都不用做,只处理请求和请求结果,所以成为coordinating node的方式:
    node.data:false
    node.master:false
  • ingest node:预处理节点,主要是对数据进行预处理,比如对字段重命名,分解字段内容,增加字段等,类似于Logstash, 就是对数据进行预处理,ingest里面可以定义pipeline(管道),pipeline可以由很多个processor(官方预定义28个)构成,用来出来预处理数据,使用方式:先定义好预处理pipeline,然后在存储数据的时候指定pipeline,如:成为ingest node的方式:
    node.ingest:true 默认(true)
// 创建pipeline: 名字为replace_content,如果数据的name字段值是swk,就把name字段的值改为孙悟空
http://xxx.xxx.xxx.xxx:9200/_ingest/pipeline/replace_content
{
    "processors":[
        {
            "set":{
                "if":"ctx.name == 'swk'",
                "field":"name",
                "value":"孙悟空"
            }
        }
    ]
}

// 使用pipeline:就是在插入数据时指定你的pipeline名字
http://xxx.xxx.xxx.xxx:9200/person/person?pipeline=replace_content
{
    "name":"swk",
    "country": "中国",
    "age":500
}
// 结果:
{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 1,
            "relation": "eq"
        },
        "max_score": 5.896224,
        "hits": [
            {
                "_index": "person",
                "_type": "person",
                "_id": "K5qUSXgBLLjdyTtcB4ZQ",
                "_score": 5.896224,
                "_source": {
                    "country": "中国",
                    "name": "孙悟空",
                    "age": 500
                }
            }
        ]
    }
}

当然如果一个节点设置:
node.data:true
node.master:true
node.ingest:true
上面这三个设置只要设置了,就代表当前节点具备该功能。

参考博文: Elasticsearch Pipeline 详解.
ingest pipeline的使用简介.

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐