ElasticSearch源码调试环境搭建

ElasticSearch源码分析(一):源码调试环境搭建(将ElasticSearch源码导入IDEA)

​ 本源码阅读环境是基于ElasticSearch 7.8.0版本,此版本需要IDEA版本至少为2020.1版

一、 准备工作:

ElasticSearch Releases版本

  • 下载ElasticSearch 7.8.0 源码
  • 下载ElasticSearch 7.8.0发行版
  • 安装Gradle(最低版本要求详见源代码: ~/buildSrc/src/main/resources: minimumCompilerVersion、minimumGradleVersion、minimumRuntimeVersion)
  • 查看本机JDK版本(7.8.0编译JDK版本最低为14)
二、 导入IDEA (CONTRIBUTING.md)
### Importing the project into IntelliJ IDEA

Elasticsearch builds using Java 14. When importing into IntelliJ you will need
to define an appropriate SDK. The convention is that **this SDK should be named
"14"** so that the project import will detect it automatically. For more details
on defining an SDK in IntelliJ please refer to [their documentation](https://www.jetbrains.com/help/idea/sdk.html#define-sdk).
SDK definitions are global, so you can add the JDK from any project, or after
project import. Importing with a missing JDK will still work, IntelliJ will
simply report a problem and will refuse to build until resolved.

You can import the Elasticsearch project into IntelliJ IDEA via:

 - Select **File > Open**
 - In the subsequent dialog navigate to the root `build.gradle` file
 - In the subsequent dialog select **Open as Project**
三、 本地运行/调试配置
WechatIMG5.png

配置以下JVM参数:

-Des.path.conf=/Users/xuxl/Library/elasticsearch/elasticsearch-7.8.0/config
-Des.path.home=/Users/xuxl/Library/elasticsearch/elasticsearch-7.8.0
-Djava.security.policy=/Users/xuxl/Library/elasticsearch/elasticsearch-7.8.0/config/elasticsearch.policy
-Xms2g
-Xmx2g
-Dlog4j2.disable.jmx=true
-Des.path.plugins=/Users/xuxl/Library/elasticsearch/elasticsearch-7.8.0/plugins

配置 elasticsearch.policy文件(在elasticsearch-home/conf/创建文件),内容如下:

grant{

permission javax.management.MBeanTruxtPermission "register";

permission javax.management.MBeanServerPermission "createMBeanServer";

permission java.lang.RuntimePermission "createClassLoader";

};

源码文件server模块中build.gradle中修改

compileOnly project(':libs:elasticsearch-plugin-classloader')

---》

compile project(':libs:elasticsearch-plugin-classloader')

ps:
需要配置node.name!

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容