1、在github上可以下载其发布的任意一个版本 地址:https://github.com/elastic/elasticsearch/releases
1、 Elasticsearch使用gradle对依赖的jar进行维护,工程可以转为Eclipse或者IDEA的工程。解压elasticsearch-6.1.3.zip,在其目录下执行gradle eclipse就可以将elasticsearch的工程转为eclipse工程了,转换时间比较长。
2、接下来就将转换好的工程导入到Eclipse中即可,导入的工程在core目录下main和cli两个工程
导入main工程
导入cli工程
1、将工程导入到Eclipse中,接下来就需要运行,在core的main工程中找到Elasticsearch类,其有main函数就可以启动,但是在启动前需要做一些配置,elasticsearch在启动时需要工作路径、配置文件路径等等,可以下载一个elasticsearch将其相关的配置文件等复制到工程的运行目录下如下:
2、运行elacticsearch的工程需要在jvm options中配置其配置文件路径及工作目录,配置如下:
-Des.path.conf=F:\elasticsearch\elasticsearch-config\config
-Delasticsearch
-Dlog4j2.disable.jmx=true
-Des.path.home=F:\elasticsearch\elasticsearch-config
-Des.path.conf :配置elasticsearch的elasticsearch.yml等配置文件路径
-Des.path.home:配置elasticsearch的运行空间地址
接下来在core工程中找到Elasticsearch类,执行main函数就可以看到Elasticsearch的启动,启动日志如下:
[2018-05-27T17:10:32,944][INFO ][o.e.n.Node ] [] initializing ...
[2018-05-27T17:10:36,273][INFO ][o.e.e.NodeEnvironment ] [6Ff7VQm] using [1] data paths, mounts [[(F:)]], net usable_space [95.2gb], net total_space [103gb], types [NTFS]
[2018-05-27T17:10:36,274][INFO ][o.e.e.NodeEnvironment ] [6Ff7VQm] heap size [869.5mb], compressed ordinary object pointers [true]
[2018-05-27T17:10:36,276][INFO ][o.e.n.Node ] node name [6Ff7VQm] derived from node ID [6Ff7VQmjTJ-6MMNtFnpo5A]; set [node.name] to override
[2018-05-27T17:10:36,277][INFO ][o.e.n.Node ] version[6.1.3-SNAPSHOT], pid[3700], build[Unknown/Unknown], OS[Windows 8.1/6.3/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_144/25.144-b01]
[2018-05-27T17:10:36,277][INFO ][o.e.n.Node ] JVM arguments [-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:60576, -Des.path.conf=F:\elasticeasrch\config, -Delasticsearch, -Dlog4j2.disable.jmx=true, -Des.path.home=F:\elasticeasrch, -Dfile.encoding=UTF-8]
[2018-05-27T17:10:36,277][WARN ][o.e.n.Node ] version [6.1.3-SNAPSHOT] is a pre-release version of Elasticsearch and is not suitable for production
[2018-05-27T17:11:09,797][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [aggs-matrix-stats]
[2018-05-27T17:11:09,797][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [analysis-common]
[2018-05-27T17:11:09,797][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [ingest-common]
[2018-05-27T17:11:09,797][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [lang-expression]
[2018-05-27T17:11:09,798][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [lang-mustache]
[2018-05-27T17:11:09,798][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [lang-painless]
[2018-05-27T17:11:09,798][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [mapper-extras]
[2018-05-27T17:11:09,798][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [parent-join]
[2018-05-27T17:11:09,798][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [percolator]
[2018-05-27T17:11:09,798][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [reindex]
[2018-05-27T17:11:09,799][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [repository-url]
[2018-05-27T17:11:09,799][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [transport-netty4]
[2018-05-27T17:11:09,799][INFO ][o.e.p.PluginsService ] [6Ff7VQm] loaded module [tribe]
[2018-05-27T17:11:09,800][INFO ][o.e.p.PluginsService ] [6Ff7VQm] no plugins loaded
[2018-05-27T17:11:10,877][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.
[2018-05-27T17:11:25,726][INFO ][o.e.d.DiscoveryModule ] [6Ff7VQm] using discovery type [zen]
[2018-05-27T17:11:30,399][INFO ][o.e.n.Node ] initialized
[2018-05-27T17:11:30,400][INFO ][o.e.n.Node ] [6Ff7VQm] starting ...
[2018-05-27T17:11:31,436][INFO ][o.e.t.TransportService ] [6Ff7VQm] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300}
[2018-05-27T17:11:31,538][WARN ][o.e.b.BootstrapChecks ] [6Ff7VQm] initial heap size [65011712] not equal to maximum heap size [1025507328]; this can cause resize pauses and prevents mlockall from locking the entire heap
[2018-05-27T17:11:35,122][INFO ][o.e.c.s.MasterService ] [6Ff7VQm] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {6Ff7VQm}{6Ff7VQmjTJ-6MMNtFnpo5A}{djMfS1nOT3SmiGWr9IIR5A}{127.0.0.1}{127.0.0.1:9300}
[2018-05-27T17:11:35,153][INFO ][o.e.c.s.ClusterApplierService] [6Ff7VQm] new_master {6Ff7VQm}{6Ff7VQmjTJ-6MMNtFnpo5A}{djMfS1nOT3SmiGWr9IIR5A}{127.0.0.1}{127.0.0.1:9300}, reason: apply cluster state (from master [master {6Ff7VQm}{6Ff7VQmjTJ-6MMNtFnpo5A}{djMfS1nOT3SmiGWr9IIR5A}{127.0.0.1}{127.0.0.1:9300} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2018-05-27T17:11:35,333][INFO ][o.e.h.n.Netty4HttpServerTransport] [6Ff7VQm] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
[2018-05-27T17:11:35,334][INFO ][o.e.n.Node ] [6Ff7VQm] started
[2018-05-27T17:11:35,417][INFO ][o.e.g.GatewayService ] [6Ff7VQm] recovered [0] indices into cluster_state