首发博客地址
首发博客地址[1]
系列文章地址[2]
教学视频[3]
为什么要学习 ES?
- 强大的全文搜索和检索功能:Elasticsearch 是一个开源的分布式搜索和分析引擎,使用倒排索引和分布式计算等技术,提供了强大的全文搜索和检索功能。学习 ES 可以掌握如何构建复杂的查询、使用各种过滤器和聚合操作来优化搜索结果。
- 实时数据分析和处理:ES 支持实时数据的索引和查询,可用于处理大规模的实时数据。学习 ES 可以了解如何使用 ES 进行实时数据的分析和处理,包括日志分析、事件处理、实时监控等。
- 分布式存储和扩展性:ES 是一个分布式系统,可以将数据分布在多个节点上,以提高存储容量和查询性能。学习 ES 可以帮助了解如何搭建和管理分布式 ES 集群,以及如何优化集群的性能和可靠性。
- 文档导入和处理:ES 支持各种数据源的导入和处理,包括数据库、文件、API 等。学习 ES 可以掌握如何将不同数据源的数据导入到 ES 中,并进行相应的处理和转换。
- 日志分析和搜索引擎优化:ES 在日志分析和搜索引擎优化方面有很大的应用价值。学习 ES 可以学会如何利用 ES 进行日志的实时分析和搜索,以及如何优化搜索引擎的性能和相关性。
- 全文搜索引擎的开发和应用:ES 是一个非常流行的全文搜索引擎,许多企业和项目都在使用 ES 构建全文搜索功能。学习 ES 可以提供开发全文搜索引擎的技能和经验,为职业发展增添竞争力。
总结起来大概就是:
- 分布式搜索引擎
- 大数据实时分析引擎
官网
官网地址[4]
ES 发展历史
Elasticsearch (ES)的发展历史可以追溯到 2004 年,当时 Shay Banon 创建了一个名为 Compass 的开源项目,作为一个基于 Lucene 的全文搜索引擎库。
随着时间的推移,Compass 逐渐发展成为一个独立的搜索引擎,但在 2009 年,Shay Banon 决定重新设计和重构该项目,以解决一些困扰他的设计和架构问题。于是,他创建了一个新的项目,命名为"elasticsearch",并于 2010 年开源发布。
以下是 ES 的主要发展里程碑:
- 2010 年:Elasticsearch 首次开源发布。它基于 Apache Lucene 构建,提供了一个分布式搜索和分析引擎,用于实时数据的索引和查询。
- 2013 年:Elasticsearch 正式成为 Elastic 公司的核心产品,并开始受到广泛关注和采用。此时,Elasticsearch 已经成为开源搜索引擎的领导者之一。
- 2014 年:Elasticsearch 发布了 1.0 版本,这是一个重要的里程碑,标志着 ES 的稳定性和成熟度。1.0 版本引入了一些重要的特性和改进,如聚合操作和索引别名等。
- 2015 年:Elasticsearch 发布了 2.0 版本,引入了许多重要的功能和改进,包括复合索引、文档级别的更新和删除、分布式索引排序等。
- 2016 年:Elasticsearch 发布了 5.0 版本,这是一个重要的版本发布,引入了许多重大的改进和变化。5.0 版本引入了新的分布式文档存储方式,并且废弃了一些旧的功能和 API。
- 2019 年:Elasticsearch 发布了 7.0 版本,这是一个重要的版本发布,引入了许多重要的功能和改进。7.0 版本引入了 Elasticsearch 的新分布式协调引擎,称为"Zen 2",以提高集群的稳定性和性能。
- 2022 年:Elasticsearch 发布了 8.0 版本,这是一个重要的版本发布,引入了许多重要的功能和改进。原生支持 NLP,速度、扩展和检索相关性提升,通过原生矢量搜索提高搜索相关性,默认开启安全功能
随着时间的推移,Elasticsearch 不断发展壮大,成为一个功能强大、可靠性高的分布式搜索和分析引擎。它被广泛应用于各种场景,包括日志分析、实时数据处理、全文搜索和商业智能等。并且,Elastic 公司也推出了其他产品,如 Kibana、Logstash 和 Beats 等,构建了一个完整的数据分析和可视化平台,被称为"Elastic Stack"或"ELK Stack"。
去官网上瞄了一眼,还支持 GPT 了..牛逼,大概看了文章说的是,通过插件可以访问 ES 内容,厉害了,有兴趣可以点击下面链接看看:
【ChatGPT】Elasticsearch 插件:将 ChatGPT 引入 Elasticsearch[5]
安装虚拟机
如果你是本地练习,可以参考这篇文章安装 Linux 系统环境: https://blog.zysicyj.top/4e7b516e[6]
环境兼容性检查
这里一定要确认好 jdk 版本,比如 8.8 支持 jdk19,8.9 不支持 jdk19,但是所有 8.x 都是支持 17 的,因为 17 是 LTS 版本。
所以建议大家安装 jdk17,兼容性比较高
兼容性检查[7]
准备安装包
官网下载:https://www.elastic.co/cn/downloads/elasticsearch[8]
关注【程序员朱永胜】回复【1021】不限速下载
安装 es
yum install elasticsearch-8.9.1-x86_64.rpm
systemctl daemon-reload systemctl enable elasticsearch.service
修改配置文件
# ======================== 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](https://www.elastic.co/guide/en/elasticsearch/reference/index.html "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: /var/lib/elasticsearch # # Path to log files: # path.logs: /var/log/elasticsearch # # ----------------------------------- 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: 0.0.0.0 # # 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. # # ---------------------------------- Various ----------------------------------- # # Allow wildcard deletion of indices: # #action.destructive_requires_name: false #----------------------- BEGIN SECURITY AUTO CONFIGURATION ----------------------- # # The following settings, TLS certificates, and keys have been automatically # generated to configure Elasticsearch security features on 31-08-2023 09:48:01 # # -------------------------------------------------------------------------------- # Enable security features xpack.security.enabled: false xpack.ml.enabled: false xpack.security.enrollment.enabled: true # Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents xpack.security.http.ssl: enabled: false keystore.path: certs/http.p12 # Enable encryption and mutual authentication between cluster nodes xpack.security.transport.ssl: enabled: false verification_mode: certificate keystore.path: certs/transport.p12 truststore.path: certs/transport.p12 # Create a new cluster with the current node only # Additional nodes can still join the cluster later cluster.initial_master_nodes: ["localhost.localdomain"] # Allow HTTP API connections from anywhere # Connections are encrypted and require user authentication http.host: 0.0.0.0 # Allow other nodes to join the cluster from anywhere # Connections are encrypted and mutually authenticated #transport.host: 0.0.0.0 #----------------------- END SECURITY AUTO CONFIGURATION -------------------------
启动并校验 es
systemctl start elasticsearch
systemctl status elasticsearch
出现这个画面基本是没问题了
[root@localhost elasticsearch]# curl -X GET "http://localhost:9200/" { "name" : "node-1", "cluster_name" : "my-application", "cluster_uuid" : "XAGRLef2SayyXzuNHPgX2Q", "version" : { "number" : "8.9.1", "build_flavor" : "default", "build_type" : "rpm", "build_hash" : "a813d015ef1826148d9d389bd1c0d781c6e349f0", "build_date" : "2023-08-10T05:02:32.517455352Z", "build_snapshot" : false, "lucene_version" : "9.7.0", "minimum_wire_compatibility_version" : "7.17.0", "minimum_index_compatibility_version" : "7.0.0" }, "tagline" : "You Know, for Search" }
参考资料
[1]
首发博客地址: https://blog.zysicyj.top/
[2]系列文章地址: https://blog.zysicyj.top/categories/技术文章/后端技术/系列文章/ES/
[3]教学视频: https://www.ixigua.com/7273889957465293368?logTag=89ff41ffd92c090eb176
[4] [5]【ChatGPT】Elasticsearch插件:将ChatGPT引入Elasticsearch: https://www.elastic.co/cn/blog/chatgpt-elasticsearch-plugin-elastic-data
[6]https://blog.zysicyj.top/4e7b516e:https://blog.zysicyj.top/4e7b516e
[7]兼容性检查: https://www.elastic.co/cn/support/matrix#matrix_jvm&#enterprise-search-and-jvm
[8]https://www.elastic.co/cn/downloads/elasticsearch:https://www.elastic.co/cn/downloads/elasticsearch
本文由 mdnice 多平台发布