Elasticsearch(简称:ES)是一个开源的分布式搜索引擎, Elasticsearch 还是一个分布式文档数据库.并提供了大量数据的存储功能快速的搜索与分析功能.
起源于 Lucene, 基于 Java 语言开发的搜索引擎类库, 创建于 1999 年, 2005 年成为 Apache 顶级开源项目.Lucene 具有高性能, 以扩展的优点,
主要功能
- 分布式搜索引擎
- 大数据近实时分析引擎
- 高性能
- 容易使用/容易扩展
- 聚合功能
- 分布式存储及集群管理
Elasticsearch个版本特性
5x版本(2016-10)
- Lucene 6x,性能提升,默认打分机制从 TF-IDF 改为 BM 25.
- 支持 Ingest 节点 / Painless Scripting / Completion suggested 支持/ 原生的 Java REST 客户端
- Type 标记成 deprecated, 支持 Keyword 的类型
- 性能优化
- 内部引擎移除了避免同一文档并发更新的竞争锁, 带来 15% - 20% 的性能提升.
- Istan aggregation, 支持分片上聚合的缓存.
- 新增了 Profile API.
6X版本(2017-10)
- Lucene 7X
- 新功能
- 跨集群复制(CCR)
- 索引生命周期管理
- SQL 的支持
- 更友好的升级及数据迁移
- 在主要版本之间的迁移更为简单,体验升级.
- 全新的基于操作的数据复制框架,可加速恢复数据.
- 性能优化
- 有效存储稀疏字段的新方法,降低了存储成本.
- 在索引时进行排序,可加快排序的查询性能.
7X版本(2019-4)
- Lucene 8.0
- 重大改进 - 正式废除单个索引下多 Type 的支持.
- 7.1开始, Security 功能免费试用.
- ECK - Elasticsearch Operator on Kubernetes
- 新功能
- 新的集群协调机制.
- 功能完整的 REST 客户端.
- Script Score Query.
- 性能优化
- 默认的 Primary Shard 数从 5 改为 1, 避免 Ober Sharding.
- 性能优化,更快的 TOP k.
部署elasticsearch
下载地址:https://www.elastic.co/cn/downloads/elasticsearch
elasticsearch7X版本自带JDK环境,之前版本需要安装JDK.
通用环境配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
下载并安装elasticsearch
1 2 3 |
|
目录说明
目录 | 主要配置文件 | 描述 |
/usr/share/elasticsearch/bin/ | elasticsearch | 脚本文件存放目录,包括 elasticesearch,安装插件.运行统计数据等. |
/etc/elasticsearch/ | elasticsearch.yml | 集群配置文件,jvm配置文件 |
/usr/share/elasticsearch/jdk/ | java | java运行环境 |
/data/elasticsearch/ | 日志和数据目录 | 数据文件及日志目录 |
/usr/share/elasticsearch/lib/ | java类库 | |
/usr/share/elasticsearch/modules/ | 包含所有ES模块 | |
/usr/share/elasticsearch/plugins/ | 包含所有已安装的插件 | |
主配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
JVM配置
配置建议:
官网配置建议: https://www.elastic.co/cn/blog/a-heap-of-trouble
- Xms 和 Xmx 设置成一样
- Xmx 不要超过机器内存的 50 %.
- 不要超过 30G.
1 2 3 |
|
启动并检查集群状态
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
elasticsearch状态说明
- green:表示每个index的shard和replica都是活跃状态的。
- yellow:表示每个index的shard是活跃状态的,replica是不可用状态的。
- red:表示索引中有些shard是不可用状态,导致数据丢失。
elasticsearch-head
elasticsearch-head 是集群管理, 数据可视化, 增删改查, 查询语句可视化工具. 从 ES5 版本后安装方式 和 ES2 以上版本有所不同. ES2 可使用安装插件方式进行安装, 但是从 ES5 之后需要使用 NodeJs来启动.
官网地址: https://github.com/mobz/elasticsearch-head
安装部署
1 2 3 4 5 |
|
修改配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
cerebro
cerebro 和 elasticsearch-head 类似.是一款基于Web的ElasticSearch管理监控工具 图形化比elasticsearch-head更加友好.
项目地址: https://github.com/lmenezes/cerebro
安装软件
1 2 3 |
|
修改配置文件
1 2 3 4 5 6 7 |
|
启动程序
1 2 3 4 |
|