挑選對應版本, 從release
中選擇:https://github.com/elastic/elasticsearch/releases
Elasticsearch
版本:6.1.2
環境準備:Java 8
零、國內鏡像加速
- 修改配置(可不修改)
$ cd elasticsearch-6.1.2/benchmarks
$ vim build.gradle
buildscript {
repositories {
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
}
}
- 修改配置(可不修改)
$ cd elasticsearch-6.1.2/client/benchmark/
$ vim build.gradle
buildscript {
repositories {
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public/'
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
}
}
- 更改全局
Maven
配置
$ cd ~/.gradle
$ touch init.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://repo.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
}
}
}
一、編譯、導入IDEA
- 執行編譯
$ cd elasticsearch-6.1.2
$ ./gradlew assemble
# 編譯成功,會顯示如下
BUILD SUCCESSFUL in 4m 48s
elasticsearch
編譯爲idea
工程
$ cd elasticsearch-6.1.2
$ ./gradlew idea
# 成功會顯示如下:
BUILD SUCCESSFUL in 1m 43s
- 打開
IDEA
,導入此項目
二、本地運行
在IDEA
菜單中選擇Run -> Edit Configurations
點擊 + ,選擇
Application
VM options
中增加如下:
-Des.path.home=/home/donald/Documents/Code/Source/elasticsearch-6.1.2/eshome -Des.path.conf=/home/donald/Documents/Code/Source/elasticsearch-6.1.2/eshome/config -Xms1g -Xmx1g -Dlog4j2.disable.jmx=true -Djava.security.policy=/home/donald/Documents/Code/Source/elasticsearch-6.1.2/eshome/config/elasticsearch.policy
distribution
下的 src/config
grant {
permission javax.management.MBeanTruxtPermission "register";
permission javax.management.MBeanServerPermission "createMBeanServer";
permission java.lang.RuntimePermission "createClassLoader";
};
[2020-06-14T14:10:11,160][INFO ][o.e.n.Node ] [] initializing ...
[2020-06-14T14:10:11,238][INFO ][o.e.e.NodeEnvironment ] [apVPSbl] using [1] data paths, mounts [[/ (/dev/nvme0n1p2)]], net usable_space [150.5gb], net total_space [233.2gb], types [ext4]
[2020-06-14T14:10:11,239][INFO ][o.e.e.NodeEnvironment ] [apVPSbl] heap size [981.5mb], compressed ordinary object pointers [true]
[2020-06-14T14:10:11,240][INFO ][o.e.n.Node ] node name [apVPSbl] derived from node ID [apVPSblPRoCNe-jxN4uBdg]; set [node.name] to override
[2020-06-14T14:10:11,240][INFO ][o.e.n.Node ] version[6.1.2-SNAPSHOT], pid[5916], build[Unknown/Unknown], OS[Linux/4.15.0-50-generic/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_162/25.162-b12]
[2020-06-14T14:10:11,240][INFO ][o.e.n.Node ] JVM arguments [-Des.path.home=/home/donald/Documents/Code/Source/elasticsearch-6.1.2/eshome, -Des.path.conf=/home/donald/Documents/Code/Source/elasticsearch-6.1.2/eshome/config, -Xms1g, -Xmx1g, -Dlog4j2.disable.jmx=true, -Djava.security.policy=/home/donald/Documents/Code/Source/elasticsearch-6.1.2/eshome/config/elasticsearch.policy, -javaagent:/software/Tools/IDE/IDEA/lib/idea_rt.jar=38911:/software/Tools/IDE/IDEA/bin, -Dfile.encoding=UTF-8]
[2020-06-14T14:10:11,240][WARN ][o.e.n.Node ] version [6.1.2-SNAPSHOT] is a pre-release version of Elasticsearch and is not suitable for production
[2020-06-14T14:10:13,874][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [aggs-matrix-stats]
[2020-06-14T14:10:13,874][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [analysis-common]
[2020-06-14T14:10:13,874][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [ingest-common]
[2020-06-14T14:10:13,874][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [lang-expression]
[2020-06-14T14:10:13,874][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [lang-mustache]
[2020-06-14T14:10:13,874][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [lang-painless]
[2020-06-14T14:10:13,874][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [mapper-extras]
[2020-06-14T14:10:13,875][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [parent-join]
[2020-06-14T14:10:13,875][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [percolator]
[2020-06-14T14:10:13,875][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [reindex]
[2020-06-14T14:10:13,875][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [repository-url]
[2020-06-14T14:10:13,875][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [transport-netty4]
[2020-06-14T14:10:13,875][INFO ][o.e.p.PluginsService ] [apVPSbl] loaded module [tribe]
[2020-06-14T14:10:13,875][INFO ][o.e.p.PluginsService ] [apVPSbl] no plugins loaded
[2020-06-14T14:10:13,981][INFO ][i.n.u.i.PlatformDependent] 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.
[2020-06-14T14:10:15,210][INFO ][o.e.d.DiscoveryModule ] [apVPSbl] using discovery type [zen]
[2020-06-14T14:10:15,606][INFO ][o.e.n.Node ] initialized
[2020-06-14T14:10:15,606][INFO ][o.e.n.Node ] [apVPSbl] starting ...
[2020-06-14T14:10:15,723][INFO ][o.e.t.TransportService ] [apVPSbl] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2020-06-14T14:10:15,730][WARN ][o.e.b.BootstrapChecks ] [apVPSbl] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2020-06-14T14:10:18,790][INFO ][o.e.c.s.MasterService ] [apVPSbl] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {apVPSbl}{apVPSblPRoCNe-jxN4uBdg}{ahl6fjbOSeWwUYLnokoS7g}{127.0.0.1}{127.0.0.1:9300}
[2020-06-14T14:10:18,794][INFO ][o.e.c.s.ClusterApplierService] [apVPSbl] new_master {apVPSbl}{apVPSblPRoCNe-jxN4uBdg}{ahl6fjbOSeWwUYLnokoS7g}{127.0.0.1}{127.0.0.1:9300}, reason: apply cluster state (from master [master {apVPSbl}{apVPSblPRoCNe-jxN4uBdg}{ahl6fjbOSeWwUYLnokoS7g}{127.0.0.1}{127.0.0.1:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2020-06-14T14:10:18,808][INFO ][o.e.h.n.Netty4HttpServerTransport] [apVPSbl] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2020-06-14T14:10:18,808][INFO ][o.e.n.Node ] [apVPSbl] started
二、遠程調試
除了在本地環境調試ES
,有時還需要遠程調試某個節點。
分佈式系統總會遇到很多千奇百怪的問題,很多時候問題無法復現,或者某種問題只出現在特定環境中。
- 配置
RUN -> Edit Configurations
三、代碼書籤和斷點組
添加:Navigate -> Bookmarks -> Toggle Bookmark