• elasticsearch配置参数详解


    elasticsearch配置参数详解

    1、elasticsearch.yml配置文件内容

    # ======================== Elasticsearch Configuration =========================
    #
    # NOTE: Elasticsearch comes with reasonable defaults for most settings.
    #       Before you set out to tweak and tune the configuration, make sure you
    #       understand what are you trying to accomplish and the consequences.
    #
    # The primary way of configuring a node is via this file. This template lists
    # the most important settings you may want to configure for a production cluster.
    #
    # Please consult the documentation for further information on configuration options:
    # https://www.elastic.co/guide/en/elasticsearch/reference/index.html
    #
    # ---------------------------------- Cluster -----------------------------------
    #
    # Use a descriptive name for your cluster:
    #
    #cluster.name: my-application
    #
    # ------------------------------------ Node ------------------------------------
    #
    # Use a descriptive name for the node:
    #
    #node.name: node-1
    #
    # Add custom attributes to the node:
    #
    #node.attr.rack: r1
    #
    # ----------------------------------- Paths ------------------------------------
    #
    # Path to directory where to store the data (separate multiple locations by comma):
    #
    #path.data: /path/to/data
    #
    # Path to log files:
    #
    #path.logs: /path/to/logs
    #
    # ----------------------------------- Memory -----------------------------------
    #
    # Lock the memory on startup:
    #
    #bootstrap.memory_lock: true
    #
    # Make sure that the heap size is set to about half the memory available
    # on the system and that the owner of the process is allowed to use this
    # limit.
    #
    # Elasticsearch performs poorly when the system is swapping the memory.
    #
    # ---------------------------------- Network -----------------------------------
    #
    # By default Elasticsearch is only accessible on localhost. Set a different
    # address here to expose this node on the network:
    #
    #network.host: 192.168.0.1
    #
    # By default Elasticsearch listens for HTTP traffic on the first free port it
    # finds starting at 9200. Set a specific HTTP port here:
    #
    #http.port: 9200
    #
    # For more information, consult the network module documentation.
    #
    # --------------------------------- Discovery ----------------------------------
    #
    # Pass an initial list of hosts to perform discovery when this node is started:
    # The default list of hosts is ["127.0.0.1", "[::1]"]
    #
    #discovery.seed_hosts: ["host1", "host2"]
    #
    # Bootstrap the cluster using an initial set of master-eligible nodes:
    #
    #cluster.initial_master_nodes: ["node-1", "node-2"]
    #
    # For more information, consult the discovery and cluster formation module documentation.
    #
    # --------------------------------- Readiness ----------------------------------
    #
    # Enable an unauthenticated TCP readiness endpoint on localhost
    #
    #readiness.port: 9399
    #
    # ---------------------------------- Various -----------------------------------
    #
    # Allow wildcard deletion of indices:
    #
    #action.destructive_requires_name: false
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89

    配置项,从整个注释中,可以看到,只是列举了部分的比较重要的属性,属性并没有列全;属性按照功能,进行了分类;

    具体的所有的配置,可以参考《ES官网》

    2、主要配置

    cluster.name:配置 ES 的集群名称,建议改成与所存数据相关的名称,ES 会自动发现在同一网段下的集群名称相同的节点;

    node.name:集群中的节点名,在同一个集群中不能重复。节点的名称一旦设置,就不能再改变了;

    node.master:指定该节点是否有资格被选举成为 Master 节点,默认是 True,如果被设置为 True,则只是有资格成为Master 节点;

    具体能否成为 Master 节点,需要通过选举产生。

    node.data:指定该节点是否存储索引数据,默认为 True。数据的增、删、改、查都是在 Data 节点完成的。

    node.ingest:在文档被索引前,预处理文档;默认为true;

    配置文件中给出了三种配置高性能集群拓扑结构的模式,如下:

    1、 如果你想让节点从不选举为主节点,只用来存储数据,可作为负载器;

    node.master: false
    node.data: true
    node.ingest: false
    
    • 1
    • 2
    • 3

    2、如果想让节点成为主节点,且不存储任何数据,并保有空闲资源,可作为协调器;

    node.master: true
    node.data: false
    node.ingest: false
    
    • 1
    • 2
    • 3

    3、 如果想让节点既不称为主节点,又不成为数据节点,那么可将他作为搜索器,从节点中获取数据,生成搜索结果;

    node.master: false
    node.data: false
    node.ingest: true
    
    • 1
    • 2
    • 3

    4、仅作为协调器

    node.master: false
    node.data: false
    node.ingest: false
    
    • 1
    • 2
    • 3

    index.number_of_shards:设置都索引分片个数,默认是1片。也可以在创建索引时设置该值,具体设置为多大都值要根据数据量的大小来定。如果数据量不大,则设置成 1 时效率最高;

    index.number_of_replicas:设置默认的索引副本个数,默认为 1 个。副本数越多,集群的可用性越好,但是写索引时需要同步的数据越多。

    transport.tcp.compress :设置在节点间传输数据时是否压缩,默认为 False,不压缩;

    discovery.zen.minimum_master_nodes:设置在选举 Master 节点时需要参与的最少的候选主节点数,默认为 1。如果使用默认值,则当网络不稳定时有可能会出现脑裂。合理的数值为(master_eligible_nodes/2)+1 ,其中master_eligible_nodes 表示集群中的候选主节点;

    discovery.zen.ping.timeout:设置在集群中自动发现其他节点时 Ping 连接的超时时间,默认为 3 秒。在较差的网络环境下需要设置得大一点,防止因误判该节点的存活状态而导致分片的转移;

  • 相关阅读:
    PAT.1123 Is It a Complete AVL Tree - AVL树
    Spring声明式事务
    【MySQL必知必会】 日志Log详解
    Ubuntu上通过源码方式安装Redis
    JPA+QueryDSL
    【JDBC】数据库连接池技术
    【Python基础】史上最全||一篇博客搞懂Python面向对象编程(封装、继承、多态)
    C++交叉编译grpc
    常用docker镜像启动了解
    BFT问题思考
  • 原文地址:https://blog.csdn.net/qq_28410283/article/details/126539925