ElasticSearch源碼調(diào)試環(huán)境搭建

ElasticSearch源碼分析(一):源碼調(diào)試環(huán)境搭建(將ElasticSearch源碼導(dǎo)入IDEA)

? 本源碼閱讀環(huán)境是基于ElasticSearch 7.8.0版本,此版本需要IDEA版本至少為2020.1版

一、 準(zhǔn)備工作:

ElasticSearch Releases版本

  • 下載ElasticSearch 7.8.0 源碼
  • 下載ElasticSearch 7.8.0發(fā)行版
  • 安裝Gradle(最低版本要求詳見(jiàn)源代碼: ~/buildSrc/src/main/resources: minimumCompilerVersion、minimumGradleVersion、minimumRuntimeVersion)
  • 查看本機(jī)JDK版本(7.8.0編譯JDK版本最低為14)
二、 導(dǎo)入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**
三、 本地運(yùn)行/調(diào)試配置
WechatIMG5.png

配置以下JVM參數(shù):

-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/創(chuàng)建文件),內(nèi)容如下:

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!

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容