elasticsearch配置参数详解

elasticsearch配置参数详解

1、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: 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 -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#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.
#
# --------------------------------- Readiness ----------------------------------
#
# Enable an unauthenticated TCP readiness endpoint on localhost
#
#readiness.port: 9399
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false

配置项,从整个注释中,可以看到,只是列举了部分的比较重要的属性,属性并没有列全;属性按照功能,进行了分类;

具体的所有的配置,可以参考《ES官网》

2、主要配置

cluster.name:配置 ES 的集群名称,建议改成与所存数据相关的名称,ES 会自动发现在同一网段下的集群名称相同的节点;

node.name:集群中的节点名,在同一个集群中不能重复。节点的名称一旦设置,就不能再改变了;

node.master:指定该节点是否有资格被选举成为 Master 节点,默认是 True,如果被设置为 True,则只是有资格成为Master 节点;

具体能否成为 Master 节点,需要通过选举产生。

node.data:指定该节点是否存储索引数据,默认为 True。数据的增、删、改、查都是在 Data 节点完成的。

node.ingest:在文档被索引前,预处理文档;默认为true;

配置文件中给出了三种配置高性能集群拓扑结构的模式,如下:

1、 如果你想让节点从不选举为主节点,只用来存储数据,可作为负载器;

node.master: false
node.data: true
node.ingest: false

2、如果想让节点成为主节点,且不存储任何数据,并保有空闲资源,可作为协调器;

node.master: true
node.data: false
node.ingest: false

3、 如果想让节点既不称为主节点,又不成为数据节点,那么可将他作为搜索器,从节点中获取数据,生成搜索结果;

node.master: false
node.data: false
node.ingest: true

4、仅作为协调器

node.master: false
node.data: false
node.ingest: false

index.number_of_shards:设置都索引分片个数,默认是1片。也可以在创建索引时设置该值,具体设置为多大都值要根据数据量的大小来定。如果数据量不大,则设置成 1 时效率最高;

index.number_of_replicas:设置默认的索引副本个数,默认为 1 个。副本数越多,集群的可用性越好,但是写索引时需要同步的数据越多。

transport.tcp.compress :设置在节点间传输数据时是否压缩,默认为 False,不压缩;

discovery.zen.minimum_master_nodes:设置在选举 Master 节点时需要参与的最少的候选主节点数,默认为 1。如果使用默认值,则当网络不稳定时有可能会出现脑裂。合理的数值为(master_eligible_nodes/2)+1 ,其中master_eligible_nodes 表示集群中的候选主节点;

discovery.zen.ping.timeout:设置在集群中自动发现其他节点时 Ping 连接的超时时间,默认为 3 秒。在较差的网络环境下需要设置得大一点,防止因误判该节点的存活状态而导致分片的转移;

你可能感兴趣的:(杂记,elasticsearch,搜索引擎,大数据)