《Elasticsearch权威指南2016》初识&安装

《Elasticsearch权威指南2016》初识&安装

编码文章call10242025-08-12 15:21:031A+A-

计划:翻译计划《Elasticsearch权威指南2016》

Elasticsearch 是一个建立在全文搜索引擎 Apache Lucene(TM) 基础上的搜索引擎,可以说 Lucene 是当今最先进,最高效的全功能开源搜索引擎框架。

但是 Lucene 只是一个框架,要充分利用它的功能,你需要使用 JAVA,并且在你的程序中集成 Lucene。更糟的是,你需要做很多的学习了解,才能明白它是如何运行的,Lucene 确实非常复杂。

Elasticsearch 使用 Lucene 作为内部引擎,但是在你使用它做全文搜索时,只需要使用统一开发好的API即可,而并不需要了解其背后复杂的 Lucene 的运行原理。

当然 Elasticsearch 并不仅仅是 Lucene 那么简单,它不仅包括了全文搜索功能,还可以进行以下工作:

  • 分布式实时文件存储,并将每一个字段都编入索引,使其可以被搜索。

  • 实时分析的分布式搜索引擎。

  • 可以扩展到上百台服务器,处理PB级别的结构化或非结构化数据。

这么多的功能被集成到一台服务器上,你可以轻松地通过客户端或者任何你喜欢的程序语言与 ES 的 RESTful API 进行交流。

Elasticsearch 的上手是非常简单的。它附带了很多非常合理的默认值,这让初学者很好地避免一上手就要面对复杂的理论,它安装好了就可以使用了,用很小的学习成本就可以变得很有生产力。

随着学习的深入,你还可以使用 Elasticsearch 更多高级的功能,整个引擎可以很灵活地进行配置。你可以根据自身需求来定制属于你自己的 Elasticsearch。

安装 JAVA

yum install java-1.7.0-openjdk -y

安装 Elasticsearch

了解 Elasticsearch 最简单的方法就是去尽情的玩儿它(汗),准备好了我们就开始吧。

安装 Elasticsearch 只有一个要求,就是要安装最新版本的JAVA。你可以到官方网站下载它:www.java.com.

你可以在这里下载到最新版本的 Elasticsearch:
elasticsearch.org/download.

curl -L -O http://download.elasticsearch.org/PATH/TO/LATEST/$VERSION.zipunzip elasticsearch-$VERSION.zip

cd elasticsearch-$VERSION

提示: 当你安装 Elasticsearch 时,你可以到 下载页面 选择Debian或者RP安装包。或者你也可以使用官方提供的 Puppet module 或者 Chef cookbook.

安装 Marvel

这是个付费的监控插件 暂时先不翻译

Marvel is a management and monitoring tool for Elasticsearch which is free for development use. It comes with an interactive console called Sense which makes it very easy to talk to Elasticsearch directly from your browser.

Many of the code examples in this book include a ``View in Sense'' link. When clicked, it will open up a working example of the code in the Sense console. You do not have to install Marvel, but it will make this book much more interactive by allowing you to experiment with the code samples on your local Elasticsearch cluster.

Marvel is available as a plugin. To download and install it, run this command in the Elasticsearch directory:

./bin/plugin -i elasticsearch/marvel/latest

You probably don't want Marvel to monitor your local cluster, so you can disable data collection with this command:

echo 'marvel.agent.enabled: false' >> ./config/elasticsearch.yml

运行 Elasticsearch

Elasticsearch 已经蓄势待发,现在你便可以运行它了:

./bin/elasticsearch

如果你想让它在后台保持运行的话可以在命令后面再加一个 -d

开启后你就可以使用另一个终端窗口来进行测试了:

curl 'http://localhost:9200/?pretty'

你应该看到如下提示:

{ "status": 200, "name": "Shrunken Bones", "version": { "number": "1.4.0", "lucene_version": "4.10"

}, "tagline": "You Know, for Search"}

这就说明你的 Elasticsearch 集群 已经上线运行了,这时我们就可以进行各种实验了。

集群和节点

节点 是 Elasticsearch 运行的实例。集群 是一组有着同样cluster.name的节点,它们协同工作,互相分享数据,提供了故障转移和扩展的功能。当然一个节点也可以是一个集群。

点击这里复制本文地址 以上内容由文彬编程网整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!
qrcode

文彬编程网 © All Rights Reserved.  蜀ICP备2024111239号-4