How can I setup and run/debug ElasticSearch in Int

2019-04-10 12:15发布

问题:

I am trying to learn how ES works however I haven't been able to run it from an IDE. I want to run the 2.3.3 build which still uses Maven as its build system but keep getting errors. Can someone tell me how I can do this in IDEA after I download the repository in detail ie. the configuration etc.

I downloaded the repository from github, then I imported the project into intellij and used the following configurations:

Main class: org.elasticsearch.bootstrap.Elasticsearch

Vm options:

-Xms256m
-Xmx1g
-Xss256k
-Djava.awt.headless=true
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=logs/heapdump.hprof
-Delasticsearch
-Des.foreground=yes
-Djava.library.path=lib/sigar
-ea
-Des.config=C:\elasticsearch-2.3.3\core\src\test\resources\config\elasticsearch.yaml>/elasticsearch.yml
-Des.logger.level=DEBUG
-Des.path.home=C:\elasticsearch-2.3.3

working directory: ES directory

environment variable: ES_TEST_LOCAL=true

use classpath of module: elasticsearch(1)(org.elasticsearch)

and then I get the following errors when i try to run:

error

回答1:

Pre-requisites:

  1. Build the root project : mvn clean package -DskipTests (or execute run.sh)
  2. copy ./distribution/src/main/resources/config to ./core/.

Create a Run/Debug configuration as follows:

Main Class: org.elasticsearch.bootstrap.Elasticsearch   
VM Options: -Des.path.home=/code/elasticsearch/core   
Program Arguments: start   
Classpath of Module : [select the core project]   


回答2:

For 5.x - From command line:

> gradle run --debug-jvm
Running elasticsearch in debug mode, suspending until connected on port 8000
[elasticsearch] Listening for transport dt_socket at address: 8000

From Intellij, create a Remote debug configuration and set the port to 8000.



回答3:

After downloading Elasticsearch from github, in the top level directory there is file called CONTRIBUTING.md which describes how to configure your IDE, and there is also a file called TESTING.asciidoc which describes how to debug.

Based on the instructions contained in those text files, I have written a blog post that gives step-by-step instructions on how to configure IntelliJ IDEA to debug Elasticsearch and Lucene.

https://alexmarquardt.com/2019/02/02/debugging-elasticsearch-and-lucene-with-intellij-idea/

Disclaimer: I am a consulting engineer at Elasticsearch