搜索引擎ElasticSearch源码编译安装和Debug环境搭建

8次阅读

共计 1015 个字符,预计需要花费 3 分钟才能阅读完成。

环境准备

说明:本文章使用的 ES 版本是:6.7.0

JDK

Elastisearch 6.7.0 编译需要 JDK 版本 10.0 及以上,我直接安装了 JDK12.JDK 下载地址:https://www.oracle.com/technetwork/java/javase/downloads/index.html

Gradle

brew install gradle

Elastisearch 源码

git clone https://github.com/elastic/elasticsearch.git
git tag
git checkout v6.7.0

使用 IDEA DEBUG 源码

将工程 Import 到 IDEA

进入 Elastisearch 根目录,把源码编译为 IDEA 工程:./gradlew idea

选择 Elasticsearch 目录进入:

选择 Gradle 导入后,下一步:

选择如上的选项,点击 Finish,导入源码到 IDEA 完成。

本地 Debug 代码

使用 IntelliJ 在本地调试 ES,有两种方式,一种是直接在 IntelliJ 上运行 ES 进行调试,但需要很多繁杂得配置。
配置方法:进入 IDEA,Run -> Edit Configurations

其中 VM options 如下:

其中,elasticsearch.policy 如下:

最后,运行 org.elasticsearch.bootstrap.Elasticsearch::main(java.lang.String[]) 方法就可以调试了。

远程调试

另一种是远程调试,先用 debug 模式,在本地启动 ES 服务:./gradlew run --debug-jvm

可以看到,debug 模式监听的端口是 8000

然后在 IDE 代码中设置断点,点击 debug 按钮:

同时也可以在浏览器中通过访问:[http://127.0.0.1:9200](http://127.0

ES 状态

![图片上传中 …]

[http://127.0.0.1:9200/_cat/health?v](http://127.0.0.1:92

h?v)

![图片上传中 …]

下一篇文章将说一下 ES 的启动过程。

系列文章

  1. 搜索引擎 ElasticSearch 源码编译和 Debug 环境搭建
  2. 搜索引擎 ElasticSearch 的启动过程
  3. Elasticsearch 创建索引流程
  4. Elasticsearch 搜索过程详解
  5. Elasticsearch 搜索相关性排序算法详解
  6. Elasticsearch 中的倒排索引

正文完
 0