ElasticSearch节点设置

作者: 饿虎嗷呜 | 来源:发表于2020-03-12 00:13 被阅读0次

    基础设置

    本节参考文档:https://www.elastic.co/guide/en/elasticsearch/reference/7.2/modules-network.html

    ES节点的基础信息包含下列几项:

    • cluster.name: test-cluster

      集群名称

    • node.name: node-1

      节点名称

    • node.host: 172.1.17.43

      节点绑定地址,可以是hostname,IPv4地址,IPv6地址(需要用“”,因为:在yaml格式中是关键词)

      如果设置成0.0.0.0,则本地所有网络接口的地址都会被绑定。

    • http.port: 9200

      http服务端口,默认9200

    • transport.port: 9300

      集群内部通信端口,默认9300

    • discovery.seed_hosts: ["172.1.17.43:9300", "172.1.17.44:9300"]

      节点加入集群中时,需要寻找集群中其他的节点,此项设置用来提供初始进行通讯的节点列表。往往会将全部节点加入到这里。

      该参数如果不进行设置,节点会自动扫描本地9300-9305端口,寻找本地其他ES实例。

      关于该配置的更多详细设置见:https://www.elastic.co/guide/en/elasticsearch/reference/7.2/modules-discovery-hosts-providers.html

    • cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]

      集群启动时,最一开始可以作为master节点的节点。可以用节点名称,IP:port等形式。

      关于此项配置见:https://www.elastic.co/guide/en/elasticsearch/reference/7.2/discovery-settings.html#initial_master_nodes

    • path.logs

      节点本身日志存储位置,如果单一主机运行多节点一定要配置。

    • path.data

      节点数据存储位置,如果单一主机运行多节点一定要配置。

    节点角色设置

    本节对应官方文档在此:https://www.elastic.co/guide/en/elasticsearch/reference/7.2/modules-node.html

    在目前版本,ES节点有下面几种设置:

    • node.master
    • node.data
    • node.ingest
    • node.ml(收费,需要预先设置xpack.ml.enabled=true,本文不考虑)

    同时,本文也不考虑跨集群搜索的情况。

    实际应用中会存在下面几种组合:

    1. Master Eligible Node

    独立的master节点,专门用于集群的管理和编排。一般设置:

    node.master: true
    node.data: false
    node.ingest: false
    node.ml: false
    xpack.ml.enabled: false
    cluster.remote.connection: false
    

    由于数据节点一般会承受更大的压力,为了让master节点稳定,该节点一般不承担数据接收和处理工作。

    1. Data Node

    专门负责数据处理与存储的节点。

    node.master: false
    node.data: true
    node.ingest: false
    node.ml: false
    xpack.ml.enabled: false
    cluster.remote.connection: false
    
    1. Ingest Node

    专门负责处理请求,只有node.ingest会设成true

    node.master: false
    node.data: false
    node.ingest: true
    node.ml: false
    xpack.ml.enabled: false
    cluster.remote.connection: false
    
    1. Coordinating Node

    专门负责对请求进行分配,所有参数设成false即可。Coordinating Node在集群中的作用相当于负载均衡器。

    node.master: false
    node.data: false
    node.ingest: false
    node.ml: false
    xpack.ml.enabled: false
    cluster.remote.connection: false
    

    冷热节点设置

    ES可以根据目的,为节点打上不同的标签,比如冷热节点,机架号等。

    相关参数:

    node.attr.xxx: tag

    比如说,我要设置一个节点为热节点,同时在机架1上可以这样配置:

    node.attr.box_type: hot
    node.attr.rack: rack1
    

    同时需要配置索引属性:

    "index.routing.allocation.require.box_type": "hot"
    "index.routing.allocation.require.rack": "rack1"
    

    启动

    一般情况下,这时在ES安装目标直接执行bin/elasticsearch -d就可以启动节点了,在启动时也可以用命令行-E xxxx=xxx的方式覆盖elasticsearch.yml中的配置。

    相关文章

      网友评论

        本文标题:ElasticSearch节点设置

        本文链接:https://www.haomeiwen.com/subject/cvcljhtx.html