elasticsearch.yml是yaml格式的elasticsearch配置文件,列出来了针对生产环境下的一些重要配置。其默认路径为:$ES_HOME/config/。
我们知道elasticsearch已经为我们提供了很多合理的默认值。但是全面的了解一下配置文件中的配置项,对于理解elasticsearch是很有帮助的。
首先我们要对yaml格式的文件有一个基本概念:
- 属性顶格写,不能有空格
- 索引一定不能使用tab制表符
- 属性和值之间的":"后边要有空格
- 例如: network.host: 192.168.0.1
# ======================== Elasticsearch Configuration =========================
# ======================== Elasticsearch 配 置 =========================
#
# 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.
# 注意:Elasticsearch为大多数配置项提供了合理的默认值。
# 在开始调整配置前,请确保你了解要完成的任务和后果。
#
# 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:
# 为你的集群设置描述性的名称:
#
# 默认值:elasticsearch
#
# 拥有相同cluster.name的节点可以加入同一集群。注意不要在不同环境中设置相同的cluster.name,以防节点加错集群
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# 为你的节点设置描述性的名称:
#
# 默认值:随机生成的uuid的前7个字符
#
# 注意:同一集群的节点名称不能重复。
#
# 注意:官方文档中提到,node.name是持久的,并且在节点重新启动时不会更改,因此默认节点名称也不会更改。
# 然而当你在修改了已经启动过的节点的node.name时,es会因找不到原节点名下的shards而报警告,但是在新的节点名下还是可以找到shards和indices。
#
# node.name 可以被设置为当前服务器的HOSTNAME:
#
#node.name: ${HOSTNAME}
#
#node.name: node-1
#
# Add custom attributes to the node:
# 向节点添加自定义属性:
#
# 为节点配置其在物理机中所在的机架(用于shard allocation awareness)
#
#node.attr.rack: r1
#
#
#
# -----关于node再说几句:-----
#
# 默认情况下,集群中的每个节点都可以处理HTTP和Transport。
# Transport层只用于节点和Java TransportClient之间的通信;
# HTTP层仅由外部REST客户端使用。
#
# 所有节点都知道集群中的所有其他节点,并将客户端请求转发到适当的节点。
#
# 除此之外,每个节点都有一个或多个目的:
#
# *Master-eligible node:
# 一个节点的node.master设置为true(默认),这使得它有资格被选为主节点,控制集群。
#
#node.master: true
#
# *Data node:
# node.data设置为true(默认)的节点。
# 数据节点是否保存数据并执行数据相关操作,如: CRUD,搜索和聚合。
#
#node.data: true
#
# *Ingest node:
# node.ingest设置为true(默认)的节点。
# 获取节点能够将 [ingest pipeline]应用于文档,以便在索引之前变换和丰富文档。
# 使用沉重的请求负载,使用专门的请求节点并将主节点和数据节点标记为node.ingest:false是有意义的。
#
#node.ingest: true
#
# ----------------------------------- 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
#
# 以上两个配置非常重要。elasticsearch建议将文件与程序分离,这样之后的维护、迁移、升级都会非常方便。程序崩溃也不会影响数据。
# 默认配置为ES主目录下创建。
#
#
# ----------------------------------- 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.
# 当系统内存交换时,elasticsearch表现不佳。
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
# 将绑定的地址设置为特定IP(IPv4或IPv6):
#
# 默认为_local_(127.0.0.1)。
# 当此项不为_local_时,es认为从开发模式转移到生产模式。
#
# 可用特殊值:
# _[networkInterface]_,例如,网络接口的地址_en0_。
# _local_,例如,系统上的任何回送地址127.0.0.1
# _site_,例如,系统上的任何站点本地地址192.168.0.1。
# _global_,例如,系统上的任何全局作用域地址8.8.8.8。
#
# 这些特殊值默认在IPv4和IPv6都可工作,但是你可以用":ipv4"、":ipv6"这两个限定说明符来指定。
# 例如, _en0:ipv4_只会绑定到接口的IPv4地址en0。
#
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
# 自定义配置HTTP端口:
# 接受单个值或范围。如果指定了范围,则节点将绑定到范围中的第一个可用端口。
# 默认为9200-9300
#
#http.port: 9200
#
# 自定义tcp端口:
# 接受单个值或范围。如果指定了范围,则节点将绑定到范围中的第一个可用端口。
# 默认为9300-9400
#
#transport.tcp.port: 9300
#
# For more information, consult the network module documentation.
# 有关更多信息,请查阅网络模块文档。
# --------------------------------- Discovery ----------------------------------
#
# 这部分主要设置集群节点间的链接,所以叫做Discovery
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
# 在新节点启动时,遍历一个内置的host列表来进行发现:
# 默认的host列表是["127.0.0.1", "[::1]"]
#
# 127.0.0.1,表示ipv4的回环地址;[::1],表示ipv6的回环地址。
#
# 注意,这里使用的端口是tcp端口。
# 注意,当不设置port时,将使用默认的transport.profiles.default.port值,如果此值也为设置则使用transport.tcp.port
# 主机名将被尝试解析成能解析的多个IP
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
# 通过设置大部分节点来避免脑裂(master候选节点的总数 / 2 + 1):
# 例如,你有三个master候选节点,最小的主节点数应被设置为(3/2)+1或者是2
#
#discovery.zen.minimum_master_nodes: 3
#
#
# For more information, consult the zen discovery module documentation.
# 更多有关信息,请参阅zen发现模块文档。
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
# 整个集群重启后,在N个节点启动前,阻碍数据恢复处理:
# 默认是1
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
# 有关更多信息,请参阅网关模块文档。
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
# 在删除索引时是否需要明确索引名:
# 换句话说,是否可以通过正则或者_all删除或者关闭索引,默认true表示必须需要显式指定索引名称
# 生产环境建议设置为true,删除索引的时候必须显式指定,否则可能会误删索引库中的索引。
#
#action.destructive_requires_name: true