全文搜索引擎ElasticSearch源码编译和Debug环境搭建

栏目: 后端 · 发布时间: 6年前

内容简介:说明:本文章使用的ES版本是:6.7.0Elastisearch 6.7.0编译需要JDK版本10.0及以上,我直接安装了JDK12.JDK下载地址:

环境准备

说明:本文章使用的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源码编译和Debug环境搭建

选择Elasticsearch目录进入:

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

选择Gradle导入后,下一步:

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

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

本地Debug代码

使用IntelliJ在本地调试ES,有两种方式,一种是直接在IntelliJ上运行ES进行调试,但需要很多繁杂得配置。

配置方法:进入IDEA, Run -> Edit Configurations

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

其中VM options如下:

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

其中,elasticsearch.policy如下:

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

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

远程调试

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

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

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

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

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

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

同时也可以在浏览器中通过访问: http://127.0.0.1:9200 查看ES状态

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

http://127.0.0.1:9200/_cat/health?v

全文搜索引擎ElasticSearch源码编译和Debug环境搭建

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

文章首发: 搜索引擎ElasticSearch源码编译和Debug环境搭建


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Java Servlet & JSP Cookbook

Java Servlet & JSP Cookbook

Bruce W. Perry / O'Reilly Media / 2003-12-1 / USD 49.99

With literally hundreds of examples and thousands of lines of code, the Java Servlet and JSP Cookbook yields tips and techniques that any Java web developer who uses JavaServer Pages or servlets will ......一起来看看 《Java Servlet & JSP Cookbook》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具