1、环境准备

  • 操作系统Win10x64
  • JDK版本:Java version "14.0.2"——elasticsearch7.8.0最低要JDK14
  • Gradle版本:Gradle 6.5
  • ElasticSearch源码版本:7.8.0
  • ElasticSearch客户端版本:7.8.0
  • Idea版本:2019.3.3
  • Groovy版本:3.0.5——用于编译 ElasticSearch 源码包中的一些模块交互逻辑

2、资源下载地址

3、安装配置

  • jdk配置
    • JAVA_HOME=C:\PROGRA~1\Java\jdk-14.0.2
    • "PATH" 变量 ——> "新建" ——> "%JAVA_HOME%\bin"
  • gradle配置
    • GRADLE_HOME=E:\installations\es_tools\gradle-6.5
    • "PATH" 变量 ——> "新建" ——> "%GRADLE_HOME%\bin"
  • Groovy配置
    • GROOVY_HOME=E:\installations\es_tools\groovy-3.0.5
    • 启动脚本为    startGroovy.bat

PROGRA~1:防止空格引起其他引用了JAVA_HOME的配置不生效问题

4、提速工作

  • gradle提速

编译ElasticSearch需要下载很多依赖包,而其中有很多包的站源是国外的,下载时比较慢。 因此可以给Gradle换成国内镜像源(本文使用阿里云镜像),提升依赖包下载速度。 在 GRADLE_HOME 目录中的 init.d 路径下,创建文件 init.gradle(如果把init.gradle放在C:\Users\dkjhl\.gradle目录下,也就是USER_HOME目录下,表示全局以以下网址下载jar包等) ,并贴上如下内容

allprojects{
    repositories {
        def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public/'
        def ALIYUN_GRADLE_PLUGIN_URL = 'https://maven.aliyun.com/repository/gradle-plugin/'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://plugins.gradle.org/m2/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL."
                    remove repo
                }
            }
        }
        maven { url ALIYUN_REPOSITORY_URL }
        maven { url ALIYUN_GRADLE_PLUGIN_URL }
    }
}

  • ElasticSearch 源码包换 Gradle 分发地址

打开下载下来的 ElasticSearch 源码包,进入目录 /elasticsearch/gradle/wrapper。然后,重新将 GRADLE_HOME 打包成 gradle-6.5.zip,拷贝到该目录下

接着,打开文件 gradle-wrapper.properties,替换如下(由此可知es版本与gradle版本的依赖关系):

 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionUrl=gradle-6.5.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=c9910513d0eed63cd8f5c7fec4cb4a05731144770104a0871234a4edc3ba3cef

变化在于:distributionUrl;变化前的distributionUrl为默认官网下载地址,意思是在编译源码初期,程序会去搜寻制定好的gradle-6.5.zip压缩文件,然后解压下载,因为下载慢的原因,这里直接使用本地压缩文件即可

5、编译elasticsearch源码

  • idea打开elasticsearch-7.8.0源码,打开方式任选一种
### 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**
  • 打开后,gradle配置

​​​

  •   编译——成功

6、启动elasticsearch源码

  • 本地启动

1)创建application启动配置

        1、设置启动类
        2、填写JVM配置,详细如下

-Des.path.home=E:\installations\es_tools\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0
-Des.path.conf=E:\installations\es_tools\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\config
-Dlog4j2.disable.jmx=true
-Xmx4g
-Xms4g 

        其中
        -Des.path.home -- 指定上文中你所下载的 ElasticSearch 客户端安装路径;
        -Des.path.conf -- 指定客户端安装路径中的配置路径;

        3、设置classpath路径,选项勾选
        4、配置jre环境

2)默认安装的 Jdk-14 环境中没有足够权限构建类加载器的,这会导致ElasticSearch源码启动时报安全权限错误;打开配置的 JAVA_HOME/conf/security/java.policy 文件,
在文件中的 grant 结构末尾加上以下权限指令:

permission java.lang.RuntimePermission "createClassLoader";

3)设置 node.name, 不然会启动失败,报空指针错误

-Des.path.conf 路径中的配置文件elasticsearch.yml,进行如下设置,以指定节点名

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: es-source-demo
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: es-source-node

启动源码

详细启动控制台信息如下

"C:\Program Files\Java\jdk-14.0.2\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:54042,suspend=y,server=n -Des.path.home=E:\installations\es_tools\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0 -Des.path.conf=E:\installations\es_tools\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\config -Dlog4j2.disable.jmx=true -Xmx4g -Xms4g -javaagent:C:\Users\cool\.IntelliJIdea2019.3\system\groovyHotSwap\gragent.jar -javaagent:C:\Users\cool\.IntelliJIdea2019.3\system\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "E:\installations\es_tools\elasticsearch-7.8.0\server\out\production\classes;E:\installations\es_tools\elasticsearch-7.8.0\server\out\production\resources;E:\installations\es_tools\elasticsearch-7.8.0\libs\x-content\out\production\classes;E:\installations\es_tools\elasticsearch-7.8.0\libs\cli\out\production\classes;E:\installations\es_tools\elasticsearch-7.8.0\libs\core\out\production\classes;E:\installations\es_tools\elasticsearch-7.8.0\libs\secure-sm\out\production\classes;E:\installations\es_tools\elasticsearch-7.8.0\libs\geo\out\production\classes;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-core\8.5.1\24212de43c19269f5211f3e79eb2f414c4a0254b\lucene-core-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-analyzers-common\8.5.1\704685ddf536e1af4da025b6e6f4e50b9846ef18\lucene-analyzers-common-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-backward-codecs\8.5.1\ab12c24a7c33ef5dfe8b57f17f67fec4a3fee1c\lucene-backward-codecs-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-grouping\8.5.1\4404f3ff6341b7518843d09141df743bf91a8284\lucene-grouping-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-highlighter\8.5.1\142f5f249aa0803f8283a3d08615e37a56f40e8a\lucene-highlighter-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-join\8.5.1\b0a48846662fc504bd7796b5506dad94981fca08\lucene-join-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-memory\8.5.1\ba9e24b90323aacc98a4ac661ac34bfbf0ed66d8\lucene-memory-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-misc\8.5.1\a0418e9bc16fc876448accb828a6ca38ed63d4a8\lucene-misc-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-queries\8.5.1\269c67a4ee9b806cfdacddc211744243cbcbd127\lucene-queries-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-queryparser\8.5.1\ee5ba0e07a178a32987b0a92da149f2104e26dd9\lucene-queryparser-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-sandbox\8.5.1\f1461680109e499d8c58dcaf5d314aeeef41d99a\lucene-sandbox-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-spatial-extras\8.5.1\eece1ef3f919634c79b9ae9d99264ac9efa4276c\lucene-spatial-extras-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-spatial3d\8.5.1\a8fb2771ac562d60a3c945a4cef0e3742c390329\lucene-spatial3d-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.lucene\lucene-suggest\8.5.1\b5613f4995836fd9edae5925ed38559460721492\lucene-suggest-8.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\com.carrotsearch\hppc\0.8.1\ffc7ba8f289428b9508ab484b8001dea944ae603\hppc-0.8.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\joda-time\joda-time\2.10.4\8c10bb8815109067ce3c91a8e547b5a52e8a1c1a\joda-time-2.10.4.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\com.tdunning\t-digest\3.2\2ab94758b0276a8a26102adf8d528cf6d0567b9a\t-digest-3.2.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.hdrhistogram\HdrHistogram\2.1.9\e4631ce165eb400edecfa32e03d3f1be53dee754\HdrHistogram-2.1.9.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.locationtech.spatial4j\spatial4j\0.7\faa8ba85d503da4ab872d17ba8c00da0098ab2f2\spatial4j-0.7.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.locationtech.jts\jts-core\1.15.0\705981b7e25d05a76a3654e597dab6ba423eb79e\jts-core-1.15.0.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.11.1\268f0fe4df3eefe052b57c87ec48517d64fb2a10\log4j-api-2.11.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-core\2.11.1\592a48674c926b01a9a747c7831bcd82a9e6d6e4\log4j-core-2.11.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.elasticsearch\jna\4.5.1\da10908ae23dc59b19dc258e63aea1c44621dc3a\jna-4.5.1.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.26\a78a8747147d2c5807683e76ec2b633e95c14fe9\snakeyaml-1.26.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.10.4\8796585e716440d6dd5128b30359932a9eb74d0d\jackson-core-2.10.4.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\net.sf.jopt-simple\jopt-simple\5.0.2\98cafc6081d5632b61be2c9e60650b64ddbc637c\jopt-simple-5.0.2.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.dataformat\jackson-dataformat-smile\2.10.4\c872c2e224cfdcc5481037d477f5890f05c001b4\jackson-dataformat-smile-2.10.4.jar;E:\installations\es_tools\elasticsearch-7.8.0\libs\plugin-classloader\out\production\classes;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.dataformat\jackson-dataformat-yaml\2.10.4\8a7f3c6b640bd89214807af6d8160b4b3b16af93\jackson-dataformat-yaml-2.10.4.jar;E:\installations\es_tools\elasticsearch-7.8.0\gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.dataformat\jackson-dataformat-cbor\2.10.4\c854bb2d46138198cb5d4aae86ef6c04b8bc1e70\jackson-dataformat-cbor-2.10.4.jar;E:\installations\idea\IntelliJ IDEA 2019.3.3\lib\idea_rt.jar" org.elasticsearch.bootstrap.Elasticsearch
Connected to the target VM, address: '127.0.0.1:54042', transport: 'socket'
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
[2022-02-21T14:23:48,967][INFO ][o.e.n.Node               ] [es-source-node] version[7.8.0], pid[16508], build[unknown/unknown/unknown/unknown], OS[Windows 10/10.0/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/14.0.2/14.0.2+12-46]
[2022-02-21T14:23:49,017][INFO ][o.e.n.Node               ] [es-source-node] JVM home [C:\Program Files\Java\jdk-14.0.2]
[2022-02-21T14:23:49,018][INFO ][o.e.n.Node               ] [es-source-node] JVM arguments [-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:54042,suspend=y,server=n, -Des.path.home=E:\installations\es_tools\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0, -Des.path.conf=E:\installations\es_tools\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\config, -Dlog4j2.disable.jmx=true, -Xmx4g, -Xms4g, -javaagent:C:\Users\cool\.IntelliJIdea2019.3\system\groovyHotSwap\gragent.jar, -javaagent:C:\Users\cool\.IntelliJIdea2019.3\system\captureAgent\debugger-agent.jar, -Dfile.encoding=UTF-8]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [aggs-matrix-stats]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [analysis-common]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [constant-keyword]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [flattened]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [frozen-indices]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [ingest-common]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [ingest-geoip]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [ingest-user-agent]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [kibana]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [lang-expression]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [lang-mustache]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [lang-painless]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [mapper-extras]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [parent-join]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [percolator]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [rank-eval]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [reindex]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [repository-url]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [search-business-rules]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [searchable-snapshots]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [spatial]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [tasks]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [transform]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [transport-netty4]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [vectors]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-analytics]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-async-search]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-autoscaling]
[2022-02-21T14:24:48,575][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-ccr]
[2022-02-21T14:24:48,588][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-core]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-deprecation]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-enrich]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-eql]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-graph]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-identity-provider]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-ilm]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-logstash]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-ml]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-monitoring]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-ql]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-rollup]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-security]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-sql]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-voting-only-node]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] loaded module [x-pack-watcher]
[2022-02-21T14:24:48,589][INFO ][o.e.p.PluginsService     ] [es-source-node] no plugins loaded
[2022-02-21T14:24:48,849][INFO ][o.e.e.NodeEnvironment    ] [es-source-node] using [1] data paths, mounts [[新加卷 (E:)]], net usable_space [106.1gb], net total_space [175.7gb], types [NTFS]
[2022-02-21T14:24:48,849][INFO ][o.e.e.NodeEnvironment    ] [es-source-node] heap size [4gb], compressed ordinary object pointers [true]
[2022-02-21T14:24:49,101][INFO ][o.e.n.Node               ] [es-source-node] node name [es-source-node], node ID [LpzJJAW9TGiG_G4EOqzLjg], cluster name [es-source-demo]
[2022-02-21T14:24:49,591][INFO ][i.n.u.i.PlatformDependent] [es-source-node] Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
[2022-02-21T14:24:54,598][INFO ][o.e.x.s.a.s.FileRolesStore] [es-source-node] parsed [0] roles from file [E:\installations\es_tools\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\config\roles.yml]
[2022-02-21T14:24:55,719][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [es-source-node] [controller/7464] [Main.cc@110] controller (64 bit): Version 7.8.0 (Build 58ff6912e20047) Copyright (c) 2020 Elasticsearch BV
[2022-02-21T14:24:57,104][INFO ][i.n.u.i.PlatformDependent] [es-source-node] Your platform does not provide complete low-level API for accessing direct buffers reliably. Unless explicitly requested, heap buffer will always be preferred to avoid potential system instability.
[2022-02-21T14:24:57,294][INFO ][o.e.d.DiscoveryModule    ] [es-source-node] using discovery type [zen] and seed hosts providers [settings]
[2022-02-21T14:24:59,011][INFO ][o.e.n.Node               ] [es-source-node] initialized
[2022-02-21T14:24:59,011][INFO ][o.e.n.Node               ] [es-source-node] starting ...
[2022-02-21T14:24:59,255][INFO ][o.e.t.TransportService   ] [es-source-node] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300}
[2022-02-21T14:24:59,656][WARN ][o.e.b.BootstrapChecks    ] [es-source-node] the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
[2022-02-21T14:24:59,672][INFO ][o.e.c.c.Coordinator      ] [es-source-node] cluster UUID [31HwP3TXTpWrql7POjjDbw]
[2022-02-21T14:24:59,700][INFO ][o.e.c.c.ClusterBootstrapService] [es-source-node] no discovery configuration found, will perform best-effort cluster bootstrapping after [3s] unless existing master is discovered
[2022-02-21T14:24:59,854][INFO ][o.e.c.s.MasterService    ] [es-source-node] elected-as-master ([1] nodes joined)[{es-source-node}{LpzJJAW9TGiG_G4EOqzLjg}{pcfC4BC5RIqsOW_qTodPpQ}{127.0.0.1}{127.0.0.1:9300}{dilmrt}{ml.machine_memory=16934494208, xpack.installed=true, transform.node=true, ml.max_open_jobs=20} elect leader, _BECOME_MASTER_TASK_, _FINISH_ELECTION_], term: 9, version: 60, delta: master node changed {previous [], current [{es-source-node}{LpzJJAW9TGiG_G4EOqzLjg}{pcfC4BC5RIqsOW_qTodPpQ}{127.0.0.1}{127.0.0.1:9300}{dilmrt}{ml.machine_memory=16934494208, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}]}
[2022-02-21T14:25:00,023][INFO ][o.e.c.s.ClusterApplierService] [es-source-node] master node changed {previous [], current [{es-source-node}{LpzJJAW9TGiG_G4EOqzLjg}{pcfC4BC5RIqsOW_qTodPpQ}{127.0.0.1}{127.0.0.1:9300}{dilmrt}{ml.machine_memory=16934494208, xpack.installed=true, transform.node=true, ml.max_open_jobs=20}]}, term: 9, version: 60, reason: Publication{term=9, version=60}
[2022-02-21T14:25:00,162][INFO ][o.e.h.AbstractHttpServerTransport] [es-source-node] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
[2022-02-21T14:25:00,162][INFO ][o.e.n.Node               ] [es-source-node] started
[2022-02-21T14:25:00,443][INFO ][o.e.l.LicenseService     ] [es-source-node] license [5e700f6b-15cb-455b-9c7d-860198954f09] mode [basic] - valid
[2022-02-21T14:25:00,443][INFO ][o.e.x.s.s.SecurityStatusChangeListener] [es-source-node] Active license is now [BASIC]; Security is disabled
[2022-02-21T14:25:00,459][INFO ][o.e.g.GatewayService     ] [es-source-node] recovered [1] indices into cluster_state
[2022-02-21T14:25:01,361][INFO ][o.e.c.r.a.AllocationService] [es-source-node] Cluster health status changed from [RED] to [YELLOW] (reason: [shards started [[cool_example][0]]]).

到这里,已经成功地以源码形式运行elasticsearch了 

本机浏览器访问 : http://localhost:9200/

或者:   http://localhost:9200/_cat/health?v

7、接下来以debug形式启动源码

postman形式执行索引的增删改,断点跟踪调用链分析底层源码以及原理;详见对应专栏

8、报错总结:

1)、第一次编译报错

> Task :benchmarks:idea FAILED

FAILURE: Build failed with an exception.

* Where:
Script 'E:\installations\es_tools\elasticsearch-7.8.0\gradle\ide.gradle' line: 20

* What went wrong:
Execution failed for task ':benchmarks:idea'.
> Use of the 'idea' task has been deprecated. For details on importing into IntelliJ see CONTRIBUTING.md.

解决办法:找到对应文件,注释掉该行

 再次编译成功

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐