Detailed explanation of elasticSearch-head building es cluster configuration file

Detailed description of elasticsearch.yml configuration file:

configuration name illustrate
cluster.name Configure the cluster name of es. The default is elasticsearch. es will automatically discover es under the same network segment. If there are multiple clusters under the same network segment, you can use this attribute to distinguish different clusters.
node.name The node name, by default, randomly assigns a name in the name list. The list is in the name.txt file in the config folder of the es jar package. There are many interesting names added by the author.
node.master Specifies whether the node is eligible to be elected as the master. The default is true, and es is the first machine in the default cluster to be the master. If this machine hangs up, the master will be re-elected.
node.data Specifies whether the node stores index data, the default is true.
index.number_of_shards Set the default number of index shards, the default is 5.
index.number_of_replicas Set the default number of index replicas, the default is 1 replica.
network.bind_host Set the bound ip address, which can be ipv4 or ipv6, the default is 0.0.0.0.
network.publish_host Set the ip address of other nodes interacting with this node. If it is not set, it will be automatically judged. The value must be a real ip address.
network.host This parameter is used to set the above two parameters of bind_host and publish_host at the same time.
transport.tcp.compress Set whether to compress the data during tcp transmission, the default is false, no compression.
transport.tcp.port Set the tcp port for interaction between nodes, the default is 9300.
http.port Set the http port for external services, the default is 9200.
http.enabled Whether to use the http protocol to provide external services, the default is true, enabled.
discovery.zen.ping.multicast.enabled Set whether to open multicast discovery node, the default is true.
discovery.zen.ping.unicast.hosts Set the initial list of master nodes in the cluster, which can be used to automatically discover new nodes that join the cluster

1. es-node-master node

# ======================== Elasticsearch Configuration =========================
# 集群的名字
cluster.name: my-application
# 节点名字
node.name: es-node-master
#指定该节点是否有资格被选举成为master
node.master: true
#ES的监听地址,这样别的机器也可以访问
network.host: 192.168.184.128
# 默认的就好
http.port: 9200
#必须指向主节点的节点名
cluster.initial_master_nodes: ["es-node-master"]
#culster transport port,节点相互通信端口号,默认9300
transport.tcp.port: 9300    
#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点
discovery.zen.ping.unicast.hosts: ["192.168.184.128:9300", "192.168.184.128:9400","192.168.184.128:9500"]
# 增加新的参数,这样head插件可以访问es,解决跨域访问问题(!!!必要)
http.cors.enabled: true
http.cors.allow-origin: "*"
# 集群个节点IP地址,也可以使用els、els.shuaiguoxia.com等名称,需要各节点能够解析
#
# 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
#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.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

**

2. es-node-slaver1 node

**

# ======================== Elasticsearch Configuration =========================
# 集群的名字  必须与其他机器相同
cluster.name: my-application
# 节点名字,必须与其他节点不同
node.name: es-node-slaver1
# 修改一下ES的监听地址,这样别的机器也可以访问
network.host: 192.168.184.128
# 不能和其他的节点相同
http.port: 9201
# !!!!必须指向主节点的节点名
cluster.initial_master_nodes: ["es-node-master"]
#用于互相通信的端口,必须不同,默认主分支master是9300,这里从节点1使用9400
transport.tcp.port: 9400    
#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点
discovery.zen.ping.unicast.hosts: ["192.168.184.128:9300", "192.168.184.128:9400","192.168.184.128:9500"] 
# 增加新的参数,这样head插件可以访问es,解决跨域访问问题(!!!必要)
http.cors.enabled: true
http.cors.allow-origin: "*"
#
# 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
#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.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

3. es-node-slaver2 node

# ======================== Elasticsearch Configuration =========================
# 集群的名字  必须与其他机器相同
cluster.name: my-application
# 节点名字,必须与其他节点不同
node.name: es-node-slave2
# 修改一下ES的监听地址,这样别的机器也可以访问
network.host: 192.168.184.128
# 不能和其他的节点相同
http.port: 9202
# !!!!必须指向主节点的节点名
cluster.initial_master_nodes: ["es-node-master"]
#culster transport port 用于互相通信的端口,必须不同,默认主分支master是9300,这里从节点2使用9500
transport.tcp.port: 9500    
#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点
discovery.zen.ping.unicast.hosts: ["192.168.184.128:9300", "192.168.184.128:9400","192.168.184.128:9500"] 
# 增加新的参数,这样head插件可以访问es,解决跨域访问问题(!!!必要)
http.cors.enabled: true
http.cors.allow-origin: "*"
#
# 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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
#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.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

Note: When the es cluster is built, if the second es server and the third es server are to copy the original first es server on the local machine, you need to clear the content in the data under es ( delete the nodes folder )

Guess you like

Origin blog.csdn.net/weixin_43605266/article/details/114628949