Elasticsearch基础教程之安装

主机采用的是Ubuntu-desktop-14.04  

 1、JDK  

    Elasticsearch依赖Java 7。本文使用的  java version "1.7.0_67",通过如下命令可以查看JDK版本:

<span style="color:#000099;">   java -version
   echo $JAVA_HOME</span>

  2、Elasticsearch

   http://www.elasticsearch.org/download 里下载。  (当前是 1.4.4版本)

   对于每个版本,你可以在zip、tar、DEB、RPM类型的包中选择下载。简单起见,我们使用tar包。

     curl -L -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.tar.gz

     tar -xzvf elasticsearch-1.4.4.tar.gz

可以看到生成一个elasticsearch-1.4.4文件夹,下面有如下目录:

  • bin: elasticsearch相关执行程序,如启动命令(elasticsearch),默认包括linux和windows的。
  • config: 配置文件,其中 elasticsearch.ymelasticsearch系统功能相关的配置,如node节点名称等,logging.yml则是log的配置,和系统功能无关。
  • data: 索引数据文件,按照集群分成不同的文件目录。
  • lib: 依赖的第三方jar包
  • logs: 日志文件,文件的目录结构和格式取决于于config/logging.yml中的配置。

    至此,我们已经准备好开启我们的节点和单节点集群(Windows用户应该运行elasticsearch.bat文件)

    然后,我们进入到bin目录下:

      cd elasticsearch-1.4.4/bin
     ./elasticsearch

    如果一切顺利,你将看到大量的如下信息:
 ./elasticsearch
<span style="color:#333333;">[2015-03-10 10:28:02,085][INFO ][node                     ] [Kang the Conqueror] version[1.4.4], pid[2685], build[c88f77f/2015-02-19T13:05:36Z]
[2015-03-10 10:28:02,086][INFO ][node                     ] [Kang the Conqueror] initializing ...
[2015-03-10 10:28:02,114][INFO ][plugins                  ] [Kang the Conqueror] loaded [], sites []
[2015-03-10 10:28:06,239][INFO ][node                     ] [Kang the Conqueror] initialized
[2015-03-10 10:28:06,240][INFO ][node                     ] [Kang the Conqueror] starting ...
[2015-03-10 10:28:06,448][INFO ][transport                ] [Kang the Conqueror] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/172.30.40.72:9300]}
[2015-03-10 10:28:06,489][INFO ][discovery                ] [Kang the Conqueror] elasticsearch/2FjTWGy0QmuPr5n7hWwEMg
[2015-03-10 10:28:10,275][INFO ][cluster.service          ] [Kang the Conqueror] new_master [Kang the Conqueror][2FjTWGy0QmuPr5n7hWwEMg][hayden-VirtualBox][inet[/172.30.40.72:9300]], reason: zen-disco-join (elected_as_master)
[2015-03-10 10:28:10,312][INFO ][http                     ] [Kang the Conqueror] bound_address {inet[/0:0:0:0:0:0:0:0:</span><strong style="color: rgb(51, 51, 51);">9200</strong><span style="color:#333333;">]}, publish_address {inet[/</span><strong><span style="color:#cc0000;">172.30.40.72:9200</span></strong><span style="color:#333333;">]}
[2015-03-10 10:28:10,313][INFO ][node                     ] [Kang the Conqueror] started
[2015-03-10 10:28:10,351][INFO ][gateway                  ] [Kang the Conqueror] recovered [0] indices into cluster_state
[2015-03-10 10:28:40,304][WARN ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark [10%] exceeded on [2FjTWGy0QmuPr5n7hWwEMg][Kang the Conqueror] free: 484.2mb[8.3%], shards will be relocated away from this node
[2015-03-10 10:28:40,306][INFO ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark exceeded on one or more nodes, rerouting shards
[2015-03-10 10:29:10,293][WARN ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark [10%] exceeded on [2FjTWGy0QmuPr5n7hWwEMg][Kang the Conqueror] free: 484.2mb[8.3%], shards will be relocated away from this node
[2015-03-10 10:29:40,293][WARN ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark [10%] exceeded on [2FjTWGy0QmuPr5n7hWwEMg][Kang the Conqueror] free: 484.2mb[8.3%], shards will be relocated away from this node
[2015-03-10 10:30:10,294][WARN ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark [10%] exceeded on [2FjTWGy0QmuPr5n7hWwEMg][Kang the Conqueror] free: 484.2mb[8.3%], shards will be relocated away from this node
[2015-03-10 10:30:10,297][INFO ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark exceeded on one or more nodes, rerouting shards
[2015-03-10 10:30:40,295][WARN ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark [10%] exceeded on [2FjTWGy0QmuPr5n7hWwEMg][Kang the Conqueror] free: 484.2mb[8.3%], shards will be relocated away from this node
[2015-03-10 10:31:10,297][WARN ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark [10%] exceeded on [2FjTWGy0QmuPr5n7hWwEMg][Kang the Conqueror] free: 484.2mb[8.3%], shards will be relocated away from this node
[2015-03-10 10:31:10,300][INFO ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark exceeded on one or more nodes, rerouting shards
[2015-03-10 10:31:40,297][WARN ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark [10%] exceeded on [2FjTWGy0QmuPr5n7hWwEMg][Kang the Conqueror] free: 484.2mb[8.3%], shards will be relocated away from this node
[2015-03-10 10:32:10,298][WARN ][cluster.routing.allocation.decider] [Kang the Conqueror] high disk watermark [10%] exceeded on [2FjTWGy0QmuPr5n7hWwEMg][Kang the Conqueror] free: 484.2mb[8.3%], shards will be relocated away from this node</span>

   至此系统启动完毕,  也要注意一下有http标记的那一行,它提供了有关HTTP地址(172.30.40.72)和端口(9200)的信息,通过这个地址和端口我们就可以访问我们的节点了。

默认情况下,Elasticsearch使用9200来提供对其REST API的访问。如果有必要,这个端口是可以配置的。通过如下url请求验证启动状态(http://172.30.40.72:9200/):

{
  "status" : 200,
  "name" : "Quasar",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "1.4.4",
    "build_hash" : "c88f77ffc81301dfa9dfd81ca2232f09588bd512",
    "build_timestamp" : "2015-02-19T13:05:36Z",
    "build_snapshot" : false,
    "lucene_version" : "4.10.3"
  },
  "tagline" : "You Know, for Search"
}

  此外 我们可以看到,启动的时候会有一个节点成为默认的master。
注1: 可以覆盖集群或者节点的名字,只需Elasticsearch的时候通过命令行来指定,如下:
        ./elasticsearch --cluster.name my_cluster_name --node.name my_node_name

注2: 可以通过在启动时增加“-d”参数让其在后台运行:

./elasticsearch -d -Xms512m -Xmx512m

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值