认识Elasticsearch的核心概念和配置文件

Elasticsearch核心概念

Near Realtime(近实时):Elasticsearch是一个近乎实时的搜索平台,这意味着从索引文档到可搜索文档之间只有一个轻微的延迟(通常是一秒钟)。

Cluster(集群):群集是一个或多个节点的集合,它们一起保存整个数据,并提供跨所有节点的联合索引和搜索功能。每个群集都有自己的唯一群集名称,节点通过名称加入群集。

Node(节点):节点是指属于集群的单个Elasticsearch实例,存储数据并参与集群的索引和搜索功能。可以将节点配置为按集群名称加入特定集群,默认情况下,每个节点都设置为加入一个名为elasticsearch的群集。一个节点也是由一个名字来标识的,默认情况下,这个名字是一个随机的Universally Unique IDentifier (UUID),这个名字会在节点启动时分配给节点。

Index(索引):索引是一些具有相似特征的文档集合,类似于MySql中数据库的概念。我们可以根据不同的特征来建立不同的索引,由名字标识索引。

Type(类型):类型是索引的逻辑类别分区,通常,为具有一组公共字段的文档类型,类似MySql中表的概念。注意:在Elasticsearch 6.0.0及更高的版本中,一个索引只能包含一个类型。

Document(文档):文档是可被索引的基本信息单位,以JSON形式表示,类似于MySql中行记录的概念。

Shards(分片):当索引存储大量数据时,可能会超出单个节点的硬件限制,为了解决这个问题,Elasticsearch提供了将索引细分为分片的概念。分片机制赋予了索引水平扩容的能力、并允许跨分片分发和并行化操作,从而提高性能和吞吐量。

分片作用:

1、允许水平分割/扩展内容容量

2、允许在分片(位于多个节点上)之上进行分布式的、并行的操作,进而提高性能/吞吐量

Replicas(副本):在可能出现故障的网络环境中,需要有一个故障切换机制,Elasticsearch提供了将索引的分片复制为一个或多个副本的功能,副本在某些节点失效的情况下提供高可用性。

副本作用:

1、在分片/节点失败的情况下,复制提供了高可用性。复制分片不与原/主要分片置于同一节点上是非常重要的。

2、因为搜索可以在所有的复制上并行运行,复制可以扩展你的搜索量/吞吐量


Elasticsearch的配置文件

Elasticsearch的配置文件在Elasticsearch安装目录下的config目录下

config目录是elasticsearch配置文件的存放目录主要有如下配置文件:

elasticsearch.keystore
jvm.options
role_mapping.yml
users
elasticsearch.yml
log4j2.properties
roles.yml
users_roles

其中elasticsearch.yml、log4j2.properties以及jvm.options是比较重要的配置文件,elasticsearch.yml是elasticsearch的基本配置文件,log4j2是日志输出配置文件,jvm则是jvm基本参数配置。

下面是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
#
# ---------------------------------- 集群配置 -----------------------------------
#
# Use a descriptive name for your cluster:
#配置集群名字,集群名字默认为elasticsearch,
#elasticsearch会自动发现在同一网段下的elasticsearch节点。
#读者在第一次启动elasticsearch时,在浏览器中输入http://localhost:9200,
#在返回的数据中,就有集群名字,默认即为elasticsearch。
#cluster.name: my-application
#
# ------------------------------------ 节点配置 ------------------------------------
#
# Use a descriptive name for the node:
#配置节点名称
#node.name: node-1
#
# Add custom attributes to the node:
#给节点添加自定义属性
#node.attr.rack: r1
#
# ----------------------------------- 路径配置 ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#数据存放目录,默认是elasticsearch下的data目录,可以指定多个目录,用,隔开,如:
#path.data:/path/data1,/path/data2
#path.data: /path/to/data
#
# Path to log files:
#日志存放目录,默认为elasticsearch下的logs目录
#path.logs: /path/to/logs
#
# ----------------------------------- 内存配置 -----------------------------------
#
# Lock the memory on startup:
#配置是否锁住内存。当jvm开始swapping时,elasticsearch的效率降低,为了避免这种情况,可以设置为true。
#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.
#
# ---------------------------------- 网络配置 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#设置绑定的ip地址
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#配置对外提供服务的http端口号
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- 集群节点发现参数 ----------------------------------
#
# 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]"]
#设置集群中master节点的初始列表,通过这个配置可以发现新加入的集群的节点。  
#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):
#保证集群中的节点可以知道其他n个有master资格的节点,防止出现split brain,默认为1
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#当n个节点启动后,再开始集群的恢复
#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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值