ES source road: source local compilation start

Keywords: ElasticSearch Gradle Maven Java

ES source road (1): source local compilation and startup

First of all, let's talk about ES:

ElasticSearch is based on Lucene Search server for. It provides a distributed multi-user full-text search engine based on RESTful web interface. Elasticsearch is developed in Java language and released as open source under Apache license. It is a popular enterprise search engine. Elasticsearch for cloud computing In, it can achieve real-time search, stability, reliability, fast, easy to install and use. Official clients are available in Java,. NET (C), PHP, Python, Apache Groovy, Ruby, and many other languages. According to the ranking of DB engines, elastic search is the most popular enterprise search engine, followed by Apache Solr, which is also based on Lucene.

Now we will start to introduce the local compilation and startup of ES source code to prepare for the following source code analysis:

I. download ES, and choose elastic search version 6.1.2 this time

The compilation of ES requires gradle, and the 6.1.2 version of ES requires gradle 3.3 or above, not too high as 5.6.

gradle doesn't make a special note. Search a lot.

Add Alibaba cloud warehouse in% user%/.gradle/ini.gradle

allprojects{
    repositories {
        def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
                    remove repo
                }
            }
        }
        maven {
            url REPOSITORY_URL
        }
    }
}

Go to the downloaded elasticsearch 6.1.2 directory, gradle elasticsearch, and start downloading some things.

 Task :buildSrc:compileGroovy FAILED

If you fail, just try a few more times.

2. Related issues of gradle

Enter build.gradle in the directory of IDEA buildSrc, right-click import gradle project, if an error is reported

A problem occurred evaluating project ':benchmarks'.
> Failed to apply plugin [id 'elasticsearch.build']
   > JAVA_HOME must be set to build Elasticsearch

Go to elasticsearch-6.1.2\buildSrc\src\main\groovy\org\elasticsearch\gradle\BuildPlugin.groovy directory

The 173 line of code

String javaHome = System.getenv('JAVA_HOME')

Change to the directory set by yourself

String javaHome = "D:\\soft\\Java\\jdk1.8.0_202";

Try to report an error again

A problem occurred evaluating project ':benchmarks'.
> Failed to apply plugin [id 'elasticsearch.build']
   > Gradle 4.3 or above is required to build elasticsearch

Download gradle 4.4 and start again

Change the maven url in build.gradle under the distribution directory to alicloud's

buildscript {
  repositories {
    maven {
      url "http://maven.aliyun.com/nexus/content/groups/public/"
    }
  }
  dependencies {
    classpath 'com.netflix.nebula:gradle-ospackage-plugin:3.4.0'
  }
}

Compile, execute. / gradlew assembly in ES directory

Compile successfully

The compiled project is in the elasticsearch-6.1.2\distribution\zip\build\distributions directory.

Three, operation

Local operation requires specifying the main class of ES source code

by

org.elasticsearch.bootstrap.Elasticsearch

Operation error reporting

path.home is not configured
vm option Add to
-Des.path.home=D:\workspace\elasticsearch-6.1.2\distribution\zip\build\distributions\elasticsearch-6.1.2 -Des.path.conf=D:\workspace\elasticsearch-6.1.2\distribution\zip\build\distributions\elasticsearch-6.1.2\config 

Operation continues to report errors:

Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "registe
Add to  
-Dlog4j2.disable.jmx=true

Run, display start success:

The free space of the disk is insufficient, and the es will report an error.

[2019-10-28T10:44:25,144][WARN ][o.e.c.r.a.DiskThresholdMonitor] [gX-XS76] high disk watermark [90%] exceeded on [gX-XS76eQ_qEWQUFNZKFLA][gX-XS76][D:\workspace\elasticsearch-6.1.2\distribution\zip\build\distributions\elasticsearch-6.1.2\data\nodes\0] free: 8.3gb[6%], shards will be relocated away from this node
[2019-10-28T10:44:25,144][INFO ][o.e.c.r.a.DiskThresholdMonitor] [gX-XS76] rerouting shards: [high disk watermark exceeded on one or more nodes]
[2019-10-28T10:44:55,149][WARN ][o.e.c.r.a.DiskThresholdMonitor] [gX-XS76] high disk watermark [90%] exceeded on [gX-XS76eQ_qEWQUFNZKFLA][gX-XS76][D:\workspace\elasticsearch-6.1.2\distribution\zip\build\distributions\elasticsearch-6.1.2\data\nodes\0] free: 8.3gb[6%], shards will be relocated away from this node
[2019-10-28T10:45:25,151][WARN ][o.e.c.r.a.DiskThresholdMonitor] [gX-XS76] high disk watermark [90%] exceeded on [gX-XS76eQ_qEWQUFNZKFLA][gX-XS76][D:\workspace\elasticsearch-6.1.2\distribution\zip\build\distributions\elasticsearch-6.1.2\data\nodes\0] free: 8.3gb[6%], shards will be relocated away from this node
[2019-10-28T10:45:25,151][INFO ][o.e.c.r.a.DiskThresholdMonitor] [gX-XS76] rerouting shards: [high disk watermark exceeded on one or more nodes]
......

Phase I complete

Posted by bradles on Sun, 27 Oct 2019 20:28:49 -0700