首页 > 其他分享 >ElasticSearch配置文件解读

ElasticSearch配置文件解读

时间:2024-10-24 10:34:27浏览次数:1  
标签:node 配置文件 默认 解读 ElasticSearch 设置 path 节点 es

elasticsearch的config文件夹里面有一个主配置文件:elasticsearch.yml是es的基本配置文件。下面主要讲解下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: /home/es/elasticsearch-6.0.0/data
#
# Path to log files:
#
path.logs: /home/es/elasticsearch-6.0.0/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 new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#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):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery 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
 

详细解释

cluster.name: elasticsearch
 
  • 1

配置es的集群名称,默认是elasticsearch,es会自动发现在同一网段下的es,如果在同一网段下有多个集群,就可以用这个属性来区分不同的集群。

node.name: "Franz Kafka"
 
  • 1

节点名,默认随机指定一个name列表中名字,该列表在es的jar包中config文件夹里name.txt文件中,其中有很多作者添加的有趣名字。

node.master: true
 
  • 1

指定该节点是否有资格被选举成为node,默认是true,es是默认集群中的第一台机器为master,如果这台机挂了就会重新选举master。

node.data: true
 
  • 1

指定该节点是否存储索引数据,默认为true。

index.number_of_shards: 5
 
  • 1

设置默认索引分片个数,默认为5片。

index.number_of_replicas: 1
 
  • 1

设置默认索引副本个数,默认为1个副本。

path.conf: /path/to/conf
 
  • 1

设置配置文件的存储路径,默认是es根目录下的config文件夹。

path.data: /path/to/data
 
  • 1

设置索引数据的存储路径,默认是es根目录下的data文件夹,可以设置多个存储路径,用逗号隔开,例:

path.data: /path/to/data1,/path/to/data2
 
  • 1
path.work: /path/to/work
 
  • 1

设置临时文件的存储路径,默认是es根目录下的work文件夹。

path.logs: /path/to/logs
 
  • 1

设置日志文件的存储路径,默认是es根目录下的logs文件夹

path.plugins: /path/to/plugins
 
  • 1

设置插件的存放路径,默认是es根目录下的plugins文件夹

bootstrap.mlockall: true
 
  • 1

设置为true来锁住内存。因为当jvm开始swapping时es的效率会降低,所以要保证它不swap,可以把ES_MIN_MEM和ES_MAX_MEM两个环境变量设置成同一个值,并且保证机器有足够的内存分配给es。同时也要允许elasticsearch的进程可以锁住内存,Linux下可以通过ulimit -l unlimited命令。

network.bind_host: 192.168.0.1
设置绑定的ip地址,可以是ipv4或ipv6的,默认为0.0.0.0。

network.publish_host: 192.168.0.1
 
  • 1

设置其它节点和该节点交互的ip地址,如果不设置它会自动判断,值必须是个真实的ip地址。

network.host: 192.168.0.1
 
  • 1

这个参数是用来同时设置bind_host和publish_host上面两个参数。

transport.tcp.port: 9300
 
  • 1

设置节点间交互的tcp端口,默认是9300。

transport.tcp.compress: true
 
  • 1

设置是否压缩tcp传输时的数据,默认为false,不压缩。

http.port: 9200
 
  • 1

设置对外服务的http端口,默认为9200。

http.max_content_length: 100mb
 
  • 1

设置内容的最大容量,默认100mb

http.enabled: false
 
  • 1

是否使用http协议对外提供服务,默认为true,开启。

gateway.type: local
 
  • 1

gateway的类型,默认为local即为本地文件系统,可以设置为本地文件系统,分布式文件系统,Hadoop的HDFS,和amazon的s3服务器,其它文件系统的设置方法下次再详细说。

gateway.recover_after_nodes: 1
 
  • 1

设置集群中N个节点启动时进行数据恢复,默认为1。

gateway.recover_after_time: 5m
 
  • 1

设置初始化数据恢复进程的超时时间,默认是5分钟。

gateway.expected_nodes: 2
 
  • 1

设置这个集群中节点的数量,默认为2,一旦这N个节点启动,就会立即进行数据恢复。

cluster.routing.allocation.node_initial_primaries_recoveries: 4
 
  • 1

初始化数据恢复时,并发恢复线程的个数,默认为4。

cluster.routing.allocation.node_concurrent_recoveries: 2
 
  • 1

添加删除节点或负载均衡时并发恢复线程的个数,默认为4。

indices.recovery.max_size_per_sec: 0
 
  • 1

设置数据恢复时限制的带宽,如入100mb,默认为0,即无限制。

indices.recovery.concurrent_streams: 5
 
  • 1

设置这个参数来限制从其它分片恢复数据时最大同时打开并发流的个数,默认为5。

discovery.zen.minimum_master_nodes: 1
 
  • 1

设置这个参数来保证集群中的节点可以知道其它N个有master资格的节点。默认为1,对于大的集群来说,可以设置大一点的值(2-4)

discovery.zen.ping.timeout: 3s
 
  • 1

设置集群中自动发现其它节点时ping连接超时时间,默认为3秒,对于比较差的网络环境可以高点的值来防止自动发现时出错。

discovery.zen.ping.multicast.enabled: false
 
  • 1

设置是否打开多播发现节点,默认是true。

discovery.zen.ping.unicast.hosts: ["host1", "host2:port", "host3[portX-portY]"]
 
  • 1

设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点。

下面是一些查询时的慢日志参数设置

index.search.slowlog.level: TRACE
index.search.slowlog.threshold.query.warn: 10s
index.search.slowlog.threshold.query.info: 5s
index.search.slowlog.threshold.query.debug: 2s
index.search.slowlog.threshold.query.trace: 500ms

index.search.slowlog.threshold.fetch.warn: 1s
index.search.slowlog.threshold.fetch.info: 800ms
index.search.slowlog.threshold.fetch.debug:500ms
index.search.slowlog.threshold.fetch.trace: 200ms
 

标签:node,配置文件,默认,解读,ElasticSearch,设置,path,节点,es
From: https://www.cnblogs.com/tiancai/p/18499086

相关文章

  • 【深度解读】涉密网向非涉密网跨网传输数据,需要注意什么?
    网间数据传输的背景为什么会存在涉密网向非涉密网跨网传输数据呢?哪些行业会面临这样的传输场景呢?首先,会存在这样的场景,是因为有核心机密数据需要保护,通常会在政府机构、金融机构、军工企业、科研单位和大型企业中会做这样的网络隔离。这种做法主要是为了保护敏感信息和数据安全......
  • Elasticsearch 在linux部署 及 Docker 集群部署详解案例示范
    1.在CentOS上安装和配置Elasticsearch在CentOS系统下,安装Elasticsearch主要分为以下步骤:1.1准备工作在开始安装之前,确保你的系统满足以下基本条件:CentOS版本要求:推荐使用CentOS7及以上版本。Java环境:Elasticsearch依赖于Java运行时环境(JRE)。需要确......
  • Linklist代码实现以及代码解读
    package集合框架.LinkList;importorg.w3c.dom.Node;importjava.util.Arrays;importjava.util.LinkedList;importjava.util.List;publicclassLinkListTest<E>{publicstaticclassNode<E>{/***@paramelement存储元素*@paramne......
  • Elasticsearch中的倒排索引是什么?它如何工作?
    Elasticsearch是一个基于Lucene的分布式搜索和分析引擎,它能够快速地存储、搜索和分析大量数据。倒排索引(InvertedIndex)是Elasticsearch和其他全文搜索引擎用来实现高效搜索的核心数据结构。倒排索引的概念在传统的数据库或文件系统中,我们通常使用正向索引来查找信息......
  • 通过命令行修改nacos配置文件
    通过命令行修改nacos配置文件1、介绍nacos-cli是一个命令行工具,用来代替nacos的图形界面操作。下载地址:GitHub-szpinc/nacos-cli:用终端命令行的方式操作nacos2、安装进入页面之后,下载对应的文件,上传到服务器上,授予执行权限,放到Linux执行文件bin目录,/usr/local/bin和/u......
  • 【Elasticsearch】分布式搜索引擎技术学习[上]
    目录一.认识与了解搜索引擎1.介绍2.安装二.初步了解Elasticsearch1.倒排索引2.IK分词器3.基础概念三.Elasticsearch基础操作1.索引库操作1.1.常见映射属性1.2.索引库的·CRUD操作2.文档操作1.1.文档的CRUD操作1.2.批量处理四.ES的Java客户端1.客户端的......
  • Qwen2技术报告解读
    论文:https://arxiv.org/pdf/2407.10671摘要本报告介绍了最新的大型语言模型和多模态模型Qwen2系列。该系列包括参数范围从0.5亿到720亿的基础型和指令微调型语言模型,涵盖密集模型和混合专家模型。Qwen2在多个基准测试中表现优异,超越了之前的开源模型,并在语言理解、生成、多语......
  • 解读快充给为设备充电的过程
    在这个快节奏的时代不可否认快充技术的出现给我们生活带来了很多的便利,那么如何让我我们的产品实现快速充电呢?这里就要使用到了快充协议,快充协议又分充电电端协议(充电器),和受电端协议(设备),它的工作原理是:例如充电端芯片集成华为SCP协议和PD2.0/3.0协议,设备端安装了XSP08Q芯片它......
  • MySQL和Elasticsearch使用场景
    来源:https://www.zhihu.com/question/637732937ES的底层实现:倒排索引正排索引(ForwardIndex)的实现方式为,通过文档ID去查找整个文档内容,适用于全部文档遍历或根据某个文档ID查找内容的场景。而倒排索引(InvertedIndex)的实现方式,则是通过文档中的关键词去查找文档ID列表,这也就是其非......
  • 第6天:Intent和页面导航-补充材料——`MainActivity.kt`解读
    下面是对“第6天:Intent和页面导航”该文学习的更深层次的补充材料,对MainActivity.kt文件的理解。下面对`MainActivity.kt’文件中每一行进行详细解释:packagecom.example.intentdemo定义包名:这行代码指定了当前Kotlin文件所属的包。在Android项目中,包名通常是由反向......