Installation(安装)

原文链接 : https://www.elastic.co/guide/en/elasticsearch/reference/5.4/_installation.html

译文链接 : http://www.apache.wiki/pages/viewpage.action?pageId=4260676

贡献者 : 那伊抹微笑ApacheCNApache中文网

Elasticsearch 需要的 Java 最低版本为 Java 8。在该文档中,建议您使用 Oracle JDK version 1.8.0_131Java 的安装因平台而异,所以我们不会在这里详细的介绍。在 Oracle 的官网 上可以找到 Oracle 的推荐安装文档。我想说的是,在安装 Elasticsearch 之前,首先请您检查的 Java 版本,运行以下命令 :

  1. java -version
  2. echo $JAVA_HOME

如果 Java 安装完成之后,我们可以下载并运行 Elasticsearch。二进制包与所有历史版本都可以从 [www.elastic.co/downloads](http://www.elastic.co/downloads) 中获得。对于每一个版本,您可以选择 ziptarDEB 或者 RPM 包。为了简单期间,我们使用 tar 文件。

让我们下载 Elasticsearch 5.4.0 tar,如下所示(Windows 用户应该下载 zip 包) :

  1. curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz

然后抽取文件,如下所示(Windows 用户应该 unzip(解压缩)该 zip 包) :

  1. tar -xvf elasticsearch-5.4.0.tar.gz

然后会在您当前目录中创建一堆文件和文件夹。然后转到 bin 目录中起,如下所示 :

  1. cd elasticsearch-5.4.0/bin

现在我们准备启动我们的节点,单个集群(Windows 用户应该运行 elasticsearch.bat 文件) :

  1. ./elasticsearch

如果一切顺利,你应该看到一堆看起来像下面的消息 :

  1. [2016-09-16T14:17:51,251][INFO ][o.e.n.Node ] [] initializing ...
  2. [2016-09-16T14:17:51,329][INFO ][o.e.e.NodeEnvironment ] [6-bjhwl] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [317.7gb], net total_space [453.6gb], spins? [no], types [ext4]
  3. [2016-09-16T14:17:51,330][INFO ][o.e.e.NodeEnvironment ] [6-bjhwl] heap size [1.9gb], compressed ordinary object pointers [true]
  4. [2016-09-16T14:17:51,333][INFO ][o.e.n.Node ] [6-bjhwl] node name [6-bjhwl] derived from node ID; set [node.name] to override
  5. [2016-09-16T14:17:51,334][INFO ][o.e.n.Node ] [6-bjhwl] version[5.0.0], pid[21261], build[f5daa16/2016-09-16T09:12:24.346Z], OS[Linux/4.4.0-36-generic/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_60/25.60-b23]
  6. [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [aggs-matrix-stats]
  7. [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [ingest-common]
  8. [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [lang-expression]
  9. [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [lang-groovy]
  10. [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [lang-mustache]
  11. [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [lang-painless]
  12. [2016-09-16T14:17:51,967][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [percolator]
  13. [2016-09-16T14:17:51,968][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [reindex]
  14. [2016-09-16T14:17:51,968][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [transport-netty3]
  15. [2016-09-16T14:17:51,968][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded module [transport-netty4]
  16. [2016-09-16T14:17:51,968][INFO ][o.e.p.PluginsService ] [6-bjhwl] loaded plugin [mapper-murmur3]
  17. [2016-09-16T14:17:53,521][INFO ][o.e.n.Node ] [6-bjhwl] initialized
  18. [2016-09-16T14:17:53,521][INFO ][o.e.n.Node ] [6-bjhwl] starting ...
  19. [2016-09-16T14:17:53,671][INFO ][o.e.t.TransportService ] [6-bjhwl] publish_address {192.168.8.112:9300}, bound_addresses {{192.168.8.112:9300}
  20. [2016-09-16T14:17:53,676][WARN ][o.e.b.BootstrapCheck ] [6-bjhwl] max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
  21. [2016-09-16T14:17:56,731][INFO ][o.e.h.HttpServer ] [6-bjhwl] publish_address {192.168.8.112:9200}, bound_addresses {[::1]:9200}, {192.168.8.112:9200}
  22. [2016-09-16T14:17:56,732][INFO ][o.e.g.GatewayService ] [6-bjhwl] recovered [0] indices into cluster_state
  23. [2016-09-16T14:17:56,748][INFO ][o.e.n.Node ] [6-bjhwl] started

没有过多的细节,我们可以看到我们节点名 “6-bjhwl”(在您的例子中将会不一样)已经启动,并且选举它自己作为一个单个集群中的 Master。不用担心目前该 Master 到底意味着什么。这里重要的事情是我们已经在一个集群上启动了一个节点。

像前面提到的一样,我们可以覆盖集群或者节点的名称。在命令行中启动 Elasticsearch 时是可以做到的,如下所示 :

  1. ./elasticsearch -Ecluster.name=my_cluster_name -Enode.name=my_node_name

另外需要注意到 http 那行关于 HTTP 地址(192.168.8.112)和端口(9200)的信息。默认情况下,Elasticsearch 使用端口 9200 来访问它的 REST API。如果有必要,该端口也可以配置。