ElasticSearch是一个高度可扩展的开源搜索引擎并使用REST API,所以您值得拥有。 在本教程中,将介绍开始使用ElasticSearch的一些主要概念。
ElasticSearch可以从elasticsearch.org下载对应的文件格式,如ZIP
和TAR.GZ
。下载并提取一个运行它的软件包之后不会容易得多,需要提前安装Java运行时环境。
在本文章中,所使用的环境是Windows,所以这里只介绍在Windows上运行ElasticSearch,可从命令窗口运行位于bin
文件夹中的elasticsearch.bat
。这将会启动ElasticSearch在控制台的前台运行,这意味着我们可在控制台中看到运行信息或一些错误信息,并可以使用CTRL + C停止或关闭它。
当前版本是: elasticsearch-5.2.0
下载链接: http://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.0.zip
把下载好的文件 elasticsearch-5.2.0.zip
解压到 D:\software\elasticsearch-5.2.0
,其目录结构如下所示
启动 ElasticSearch
Microsoft Windows [版本 10.0.10586] (c) 2015 Microsoft Corporation。保留所有权利。 C:\Users\Administrator>d: D:\>cd software\elasticsearch-5.2.0 D:\software\elasticsearch-5.2.0>cd bin D:\software\elasticsearch-5.2.0\bin>elasticsearch.bat [2017-01-28T14:10:32,177][INFO ][o.e.n.Node ] [] initializing ... [2017-01-28T14:10:32,670][INFO ][o.e.e.NodeEnvironment ] [SnafGWM] using [1] data paths, mounts [[Software (D:)]], net usable_space [61.6gb], net total_space [139gb], spins? [unknown], types [NTFS] [2017-01-28T14:10:32,686][INFO ][o.e.e.NodeEnvironment ] [SnafGWM] heap size [1.9gb], compressed ordinary object pointers [true] [2017-01-28T14:10:32,686][INFO ][o.e.n.Node ] node name [SnafGWM] derived from node ID [SnafGWMWRzmfwTKP6VJClA]; set [node.name] to override [2017-01-28T14:10:32,717][INFO ][o.e.n.Node ] version[5.2.0], pid[9724], build[24e05b9/2017-01-24T19:52:35.800Z], OS[Windows 10/10.0/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_65/25.65-b01] [2017-01-28T14:10:35,271][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [aggs-matrix-stats] [2017-01-28T14:10:35,271][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [ingest-common] [2017-01-28T14:10:35,271][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [lang-expression] [2017-01-28T14:10:35,271][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [lang-groovy] [2017-01-28T14:10:35,271][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [lang-mustache] [2017-01-28T14:10:35,287][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [lang-painless] [2017-01-28T14:10:35,287][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [percolator] [2017-01-28T14:10:35,288][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [reindex] [2017-01-28T14:10:35,290][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [transport-netty3] [2017-01-28T14:10:35,291][INFO ][o.e.p.PluginsService ] [SnafGWM] loaded module [transport-netty4] [2017-01-28T14:10:35,292][INFO ][o.e.p.PluginsService ] [SnafGWM] no plugins loaded [2017-01-28T14:10:41,394][INFO ][o.e.n.Node ] initialized [2017-01-28T14:10:41,397][INFO ][o.e.n.Node ] [SnafGWM] starting ... [2017-01-28T14:10:42,657][INFO ][o.e.t.TransportService ] [SnafGWM] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300} [2017-01-28T14:10:46,439][INFO ][o.e.c.s.ClusterService ] [SnafGWM] new_master {SnafGWM}{SnafGWMWRzmfwTKP6VJClA}{vG5mFSENST6eo-yl_O8HuA}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-elected-as-master ([0] nodes joined) [2017-01-28T14:10:48,628][INFO ][o.e.h.HttpServer ] [SnafGWM] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200} [2017-01-28T14:10:48,628][INFO ][o.e.n.Node ] [SnafGWM] started [2017-01-28T14:10:48,928][INFO ][o.e.g.GatewayService ] [SnafGWM] recovered [0] indices into cluster_state在启动过程中,ElasticSearch的实例运行会占用大量的内存,所以在这一过程中,电脑会变得比较慢,需要耐心等待,启动加载完成后电脑就可以正常使用了。
如果您没有安装Java运行时或没有正确配置,应该不会看到像上面的输出,而是一个消息说“JAVA_HOME环境变量必须设置!“ 要解决这个问题,首先下载并安装Java,其次,确保已正确配置JAVA_HOME
环境变量。