Windows10中Elasticsearch和Kibana的安装、使用

Windows10中Elasticsearch安装、使用

Elasticsearch是一个开源的分布式搜索和分析引擎,最初是由Elastic公司开发的。它基于Apache Lucene库,提供了一个分布式、多用户的全文搜索引擎,具有实时分析能力。

一. Elasticsearch介绍

1.1. Elasticsearch主要用途

全文搜索:Elasticsearch可以快速、高效地对大量文本数据进行全文搜索,支持复杂的查询和过滤操作。

实时数据分析:Elasticsearch能够处理大规模的实时数据,并提供丰富的聚合功能,用于分析和可视化数据。

日志和指标分析:Elasticsearch被广泛用于处理日志和指标数据,例如服务器日志、应用程序日志和性能指标,可以通过Elasticsearch进行搜索、过滤和分析。

企业搜索:许多企业使用Elasticsearch构建搜索功能,例如产品搜索、内容搜索和用户搜索,以提供更好的用户体验。

地理空间数据分析:Elasticsearch支持地理空间数据的索引和查询,可用于地理信息系统(GIS)和位置服务。

1.2. 使用Elasticsearch的原因

高性能和可伸缩性:Elasticsearch是一个分布式系统,可以水平扩展,能够处理大规模数据并提供低延迟的查询响应。

全文搜索功能:Elasticsearch提供强大的全文搜索功能,支持复杂的查询和分析需求,能够满足各种应用场景的需求。

实时性:Elasticsearch能够实时索引和查询数据,适用于需要实时数据分析和监控的场景。

开源和活跃的社区:作为一个开源项目,Elasticsearch拥有活跃的社区支持,提供了丰富的文档和资源,便于开发者学习和使用。

二. Elasticsearch安装

2.1.下载es(选择windows版本)

下载地址

这里注意,根据项目需求下载对应的版本,另外在下载客户端时也需要对应版本,不然容易出现未知错误

20240314092650

这里安装的是6.8.6,具体安装方式就不写了,下面给个参考,如果碰到其他问题可以进行网络搜索。

安装参考:Win10下安转Elasticsearch6.8.6

elasticsearch.yml配置文件中的配置如下:

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
# 集群名称,默认为elasticsearch
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):
# 指定es的数据存储目录
path.data: D:\RunEnv\Elasticsearch\elasticsearch6.8.6\data
#
# Path to log files:
# 指定es的日志存储目录
path.logs: D:\RunEnv\Elasticsearch\elasticsearch6.8.6\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):
# es设置ip绑定,默认是127.0.0.1,也就是默认只能通过127.0.0.1或者localhost才能访问
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
# 设置自定义端口,默认9200
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: 
#
# 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

xpack.security.enabled: false
xpack.security.transport.ssl.enabled: false
xpack.ssl.key: x-pack/instance/instance.key
xpack.ssl.certificate: x-pack/instance/instance.crt
xpack.ssl.certificate_authorities: x-pack/ca/ca.crt
xpack.ssl.verification_mode: certificate
xpack.ssl.client_authentication: required

# 开启跨域访问支持,默认为false
http.cors.enabled: true
# 跨域访问允许的域名
http.cors.allow-origin: "*"

2.2. 下载可视化工具Kibana

Kibana下载地址

直接下载最新版本,或者点击右侧连接,选择历史版本,因为我Elasticsearch安装的是6.8.6版本,所以这里选择历史版本,安装Kibana6.8.0

Kibana下载地址

kibana.yml配置文件中添加下面配置,启动即可。

# port
server.port: 9201
# host
server.host: "0.0.0.0"
# 名称
server.name: "my-kibana"
# elasticsearch的host
elasticsearch.hosts: ["http://localhost:9200"]
# kibana中文界面
i18n.locale: "zh-CN"
2.2.1 使用

启动成功后界面:

Kibana下载地址界面

按照下面步骤可看到当前储存的索引,简单可以理解为数据库中的表

Kibana索引存储

查询方式

Kibana查询使用

GET _search
{
  "query": {
    "match_all": {}
  }
}

GET /wk-login-log-2024-03/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "userId": "147806"
          }
        }
      ]
    }
  }
}
版权声明: 闲者 发表于 2024-03-14
转载请注明: Windows10中Elasticsearch和Kibana的安装、使用 | Windows10中Elasticsearch和Kibana的安装、使用 - 无界文档,Windows10中Elasticsearch和Kibana的安装、使用

评论区

暂无评论...