ElasticSearch配置文件常用配置

29 阅读2分钟

配置文件位置

ElasticSearch配置文件在config/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: elk-cluster-01
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# 节点名称,必须修改,默认修改为当前机器名称,若是多实例需要区分
node.name: ${HOSTNAME}-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# 设置处理器数量,默认无需设置,单机器多实例需要设置
node.processors: 2
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# 数据目录与日志目录,默认在当前程序下,生产环境需要指定
path.data: /elk/${HOSTNAME}/data
#
# Path to log files:
#
path.logs: /elk/${HOSTNAME}/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:
#
# IP 地址,默认是localhost仅限本机访问,外网不可访问,设置0.0.0.0通用做法
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
# 访问端口,默认9200,9300,建议明确指定
http.port: 9200
transport.port: 9300
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
# 默认单节点集群模式
discovery.type: single-node
# 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: ["192.168.0.24:9300"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
# 集群初始化节点
#注意,当discovery.type为single-node时候 cluster.initial_master_nodes不能同时开启
# cluster.initial_master_nodes: ["192.168.0.24:9300"]
# 部分电脑CPU不支持SSE4.2+,启动会出错,设置禁用机器学习功能
xpack.ml.enabled: false
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
# 防止批量删除索引
action.destructive_requires_name: true

集群配置

# ======================== 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: elk-cluster-01
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# 节点名称,必须修改,默认修改为当前机器名称,若是多实例需要区分
node.name: ${HOSTNAME}-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# 设置处理器数量,默认无需设置,单机器多实例需要设置
node.processors: 2
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# 数据目录与日志目录,默认在当前程序下,生产环境需要指定
path.data: /elk/${HOSTNAME}/data
#
# Path to log files:
#
path.logs: /elk/${HOSTNAME}/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:
#
# IP 地址,默认是localhost仅限本机访问,外网不可访问,设置0.0.0.0通用做法
network.host: 0.0.0.0
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
# 访问端口,默认9200,9300,建议明确指定
http.port: 9200
transport.port: 9300
# 关闭 X-Pack 安全功能,关闭后任何人都可以访问集群(生产不安全,需要开启) 
xpack.security.enabled: false
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
# 默认单节点集群模式
#discovery.type: single-node
# 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: ["192.168.0.24:9300","192.168.0.9:9300","192.168.0.17:9300"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
# 集群初始化节点
#注意,当discovery.type为single-node时候 cluster.initial_master_nodes不能同时开启
cluster.initial_master_nodes: ["192.168.0.24:9300","192.168.0.9:9300","192.168.0.17:9300"]
# 部分电脑CPU不支持SSE4.2+,启动会出错,设置禁用机器学习功能
xpack.ml.enabled: false
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
# 防止批量删除索引
action.destructive_requires_name: true