elasticSearch-head搭建es集群配置文件详解

elasticsearch.yml配置文件详细说明:

配置名字 说明
cluster.name 配置es的集群名称,默认是elasticsearch,es会自动发现在同一网段下的es,如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。
node.name 节点名,默认随机指定一个name列表中名字,该列表在es的jar包中config文件夹里name.txt文件中,其中有很多作者添加的有趣名字。
node.master 指定该节点是否有资格被选举成为master,默认是true,es是默认集群中的第一台机器为master,如果这台机挂了就会重新选举master。
node.data 指定该节点是否存储索引数据,默认为true。
index.number_of_shards 设置默认索引分片个数,默认为5片。
index.number_of_replicas 设置默认索引副本个数,默认为1个副本。
network.bind_host 设置绑定的ip地址,可以是ipv4或ipv6的,默认为0.0.0.0。
network.publish_host 设置其它节点和该节点交互的ip地址,如果不设置它会自动判断,值必须是个真实的ip地址。
network.host 这个参数是用来同时设置bind_host和publish_host上面两个参数。
transport.tcp.compress 设置是否压缩tcp传输时的数据,默认为false,不压缩。
transport.tcp.port 设置节点间交互的tcp端口,默认是9300。
http.port 设置对外服务的http端口,默认为9200。
http.enabled 是否使用http协议对外提供服务,默认为true,开启。
discovery.zen.ping.multicast.enabled 设置是否打开多播发现节点,默认是true。
discovery.zen.ping.unicast.hosts 设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点

1、es-node-master 节点

# ======================== 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 节点

**

# ======================== 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 节点

# ======================== 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

注意事项:es集群搭建的时候,如果第二个es服务器第三个es服务器是复制本机上原有第一个es服务器,需要把es下data里面的内容清空(删除nodes文件夹

猜你喜欢

转载自blog.csdn.net/weixin_43605266/article/details/114628949