Elasticsearch技术解析与实战
上QQ阅读APP看书,第一时间看更新

1.4.4 运行

在Windows下执行elasticsearch.bat,在Linux下运行./elasticsearch。

如果一切顺利的话,你应该看到如下信息:

[2016-02-03 16:53:31122][INFO ][node] [Rintrah] version[2.2.0] pid[6840] build[8ff36d1/2016-01-27T13:32:39Z]
[2016-02-03 16:53:31122][INFO ][node] [Rintrah] initializing ...
[2016-02-03 16:53:31668][INFO ][plugins] [Rintrah] modules [lang-groovy lang-expression] plugins [] sites []
[2016-02-03 16:53:31684][INFO ][env] [Rintrah] using [1] data paths mounts [[work (D:)]] net usable_space [67.2gb] net total_space [99.9gb] spins? [unknown] types [NTFS]
[2016-02-03 16:53:31684][INFO ][env] [Rintrah] heap size [910.5mb] compressed ordinary object pointers [true]
[2016-02-03 16:53:33637][INFO ][node] [Rintrah] initialized
[2016-02-03 16:53:33637][INFO ][node] [Rintrah] starting ...
[2016-02-03 16:53:33918][INFO ][transport] [Rintrah] publish_address {127.0.0.1:9300} bound_addresses {[::1]:9300} {127.0.0.1:9300}
[2016-02-03 16:53:33934][INFO ][discovery] [Rintrah] elasticsearch/ 1oo5dtelT8ax-3LmnTrs8g
[2016-02-03 16:53:37982][INFO ][cluster.service] [Rintrah] new_master {Rintrah}{1oo5dtelT8ax-3LmnTrs8g}{127.0.0.1}{127.0.0.1:9300} reason: zen-disco-join(elected_as_master [0] joins received)
[2016-02-03 16:53:40363][INFO ][gateway] [Rintrah] recovered [0] indices into cluster_state
[2016-02-03 16:53:40567][INFO ][http] [Rintrah] publish_address {127.0.0.1:9200} bound_addresses {[::1]:9200} {127.0.0.1:9200}
[2016-02-03 16:53:40567][INFO ][node] [Rintrah] started

这样我们就已经启动了Elasticsearch,当然我们也可以在启动的时候修改集群的名称和节点的名称。例如:

./elasticsearch --cluster.name my_cluster_name --node.name my_node_name

默认情况下,Elasticsearch使用9200端口提供的REST API。该端口是可配置的。

在本机访问http://127.0.0.1:9200/

将会得到以下内容:

{
  "name" : "Rintrah"
  "cluster_name" : "elasticsearch"
  "version" : {"number" : "2.2.0"
    "build_hash" : "8ff36d139e16f8720f2947ef62c8167a888992fe"
    "build_timestamp" : "2016-01-27T13:32:39Z""build_snapshot" : false
    "lucene_version" : "5.4.1"
  }
  "tagline" : "You Know for Search"
}

现在,我们的节点(和集群)将正确运行,下一步就是要了解如何进行使用。Elasticsearch提供了非常全面和强大的REST API,通过这些API,我们可以了解集群的信息。这些API可以做如下事情:

1)检查集群、节点和索引的情况、状态和统计。

2)管理集群、节点、索引数据和文档数据。

3)执行CRUD(创建、读取、更新和删除)操作,可以对索引进行操作。

4)执行高级搜索操作,如分页、排序、过滤、脚本、聚合及其他操作。