英文官方文档来自:
https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html
Installationedit
ES安装条件的要求,Java版本最低是Java7,推荐JDK1.8.0_25及以上的版本。不同Java版本的安装细节在不同平台上也不相同,所以不做详细介绍,Oracle的安装需求文档可以在这里查看: Oracle’s website。所以在安装ES之前,最好查看一下你的Java版本,可以通过下面的命令查看(之后,你可以进行安装/更新操作):
Elasticsearch requires at least Java 7. Specifically as of this writing, it is recommended that you use the Oracle JDK version 1.8.0_25. Java installation varies from platform to platform so we won’t go into those details here. Oracle’s recommended installation documentation can be found on Oracle’s website. Suffice to say, before you install Elasticsearch, please check your Java version first by running (and then install/upgrade accordingly if needed):
java -version echo $JAVA_HOME
一旦你把Java安装好了,我们就可以下载和运行ES了。二进制文件可以在这里得到:www.elastic.co/downloads,
这里也包括以前的旧版本。你可以选择zip,tar,deb或rpm版本。为了简便,我们选择了tar版本。
可以在下面下载Elasticsearch 1.7.4 tar版本(Windows用户应该下载zip安装包)。
Once we have Java set up, we can then download and run Elasticsearch. The binaries are available fromwww.elastic.co/downloads
along with all the releases that have been made in the past. For each release, you have a choice among a zip
or tar
archive, or a DEB
or RPM
package. For simplicity, let’s use the tar file.
Let’s download the Elasticsearch 1.7.4 tar as follows (Windows users should download the zip package):
curl -L -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.4.tar.gz
解压过程如下(Windows用户应该使用unzip命令来解压zip包):
Then extract it as follows (Windows users should unzip the zip package):
tar -xvf elasticsearch-1.7.4.tar.gz
解压后,会在当前目录下生成一些列文件和文档,接着进一步打开文件。
It will then create a bunch of files and folders in your current directory. We then go into the bin directory as follows:
cd elasticsearch-1.7.4/bin
现在可以启动(Windows用户应该运行elasticsearch.bat文件):
And now we are ready to start our node and single cluster (Windows users should run the elasticsearch.bat file):
./elasticsearch
如果一切顺利,你将看到下面的内容:
If everything goes well, you should see a bunch of messages that look like below:
./elasticsearch [2014-03-13 13:42:17,218][INFO ][node ] [New Goblin] version[1.7.4], pid[2085], build[5c03844/2014-02-25T15:52:53Z] [2014-03-13 13:42:17,219][INFO ][node ] [New Goblin] initializing ... [2014-03-13 13:42:17,223][INFO ][plugins ] [New Goblin] loaded [], sites [] [2014-03-13 13:42:19,831][INFO ][node ] [New Goblin] initialized [2014-03-13 13:42:19,832][INFO ][node ] [New Goblin] starting ... [2014-03-13 13:42:19,958][INFO ][transport ] [New Goblin] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.8.112:9300]} [2014-03-13 13:42:23,030][INFO ][cluster.service] [New Goblin] new_master [New Goblin][rWMtGj3dQouz2r6ZFL9v4g][mwubuntu1][inet[/192.168.8.112:9300]], reason: zen-disco-join (elected_as_master) [2014-03-13 13:42:23,100][INFO ][discovery ] [New Goblin] elasticsearch/rWMtGj3dQouz2r6ZFL9v4g [2014-03-13 13:42:23,125][INFO ][http ] [New Goblin] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.8.112:9200]} [2014-03-13 13:42:23,629][INFO ][gateway ] [New Goblin] recovered [1] indices into cluster_state [2014-03-13 13:42:23,630][INFO ][node ] [New Goblin] started
不去过分在意细节,我们可以看到我们的节点名:New Gobin,它已经启动了,并且把自己作为只有一台机器集群里的master。现在不要在意master是什么,现在重要的是把这个只有一台机器的集群启动起来。
前面提到,我们可以更改集群或节点名,用到的指令如下所示:
Without going too much into detail, we can see that our node named "New Goblin" (which will be a different Marvel character in your case) has started and elected itself as a master in a single cluster. Don’t worry yet at the moment what master means. The main thing that is important here is that we have started one node within one cluster.
As mentioned previously, we can override either the cluster or node name. This can be done from the command line when starting Elasticsearch as follows:
./elasticsearch --cluster.name my_cluster_name --node.name my_node_name
也要注意http那一行,它包含了一些信息,使用HTTP地址:192.168.8.112和端口9200。
ES给它的REST API提供了9200端口。如果需要的话,这个端口可以更改。
Also note the line marked http with information about the HTTP address (192.168.8.112
) and port (9200
) that our node is reachable from. By default, Elasticsearch uses port 9200
to provide access to its REST API. This port is configurable if necessary.