ElasticSearch use a (Installation Guide)

ElasticSearch Profile

Elaticsearch,简称为es, es是一个开源的高扩展的分布式全文检索引擎,它可以近乎实时的存储、检索
数据;本身扩展性很好,可以扩展到上百台服务器,处理PB级别的数据。es也使用Java开发并使Lucene
作为其核心来实现所有索引和搜索的功能,但是它的目的是通过简单的RESTful API来隐藏Lucene的复杂
性,从而让全文搜索变得简单。

ElasticSearch use cases

1、2013年初,GitHub抛弃了Solr,采取ElasticSearch 来做PB级的搜索。 “GitHub使用ElasticSearch搜索
20TB的数据,包括13亿文件和1300亿行代码”
2、维基百科:启动以elasticsearch为基础的核心搜索架构
3、SoundCloud:“SoundCloud使用ElasticSearch为1.8亿用户提供即时而精准的音乐搜索服务”
4、百度:百度目前广泛使用ElasticSearch作为文本数据分析,采集百度所有服务器上的各类指标数据及用户自定义数据,通过对各种数据进行多维分析展示,辅助定位分析实例异常或业务层面异常。目前覆盖
百度内部20多个业务线(包括casio、云分析、网盟、预测、文库、直达号、钱包、风控等),单集群最
大100台机器,200个ES节点,每天导入30TB+数据
5、新浪使用ES 分析处理32亿条实时日志
6、阿里使用ES 构建挖财自己的日志采集和分析体系

ElasticSearch contrast Solr

Solr 利用 Zookeeper 进行分布式管理,而 Elasticsearch 自身带有分布式协调管理功能;
Solr 支持更多格式的数据,而 Elasticsearch 仅支持json文件格式;
Solr 官方提供的功能更多,而 Elasticsearch 本身更注重于核心功能,高级功能多有第三方插件提供;
Solr 在传统的搜索应用中表现好于 Elasticsearch,但在处理实时搜索应用时效率明显低于 Elasticsearch

Installation and start ElasticSearch

Download ES archive
official address ElasticSearch of: https://www.elastic.co/products/elasticsearch

ElasticSearch分为Linux和Window版本,基于我们主要学习的是ElasticSearch的Java客户端的使用,所以
我们课程中使用的是安装较为简便的Window版本,项目上线后,公司的运维人员会安装Linux版的ES供我
们连接使用。

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
ES installation service
install Window version ElasticSearch is very simple, similar to the Window version of Tomcat, unpack means that the installation is complete, the directory structure ElasticSearch after decompression as follows:
Here Insert Picture Description
Modify elasticsearch configuration file, config / elasticsearch.yml, add the following two commands ( there are problems start after the end of file can be added to, pay attention to modify the format of the bars can manually adjust the space between the colon and allow-origin behind the times in question):

http.cors.enabled: true
http.cors.allow-origin: "*"
//此步为允许elasticsearch跨越访问,如果不安装后面的elasticsearch-head是可以不修改,直接启动。

Start ES Service
elasticsearch.bat in the bin directory under ElasticSearch Click Start, log information console display is as follows:
Here Insert Picture Description
Here Insert Picture Description
Note: 9300 is the communication between tcp port, clusters and TCPClient perform the port, 9200 is RESTful interface http protocol.
Browser to access the server via ElasticSearch, see the following information json returned, on behalf of the service starts successfully:
Here Insert Picture Description
Note:

ElasticSearch是使用java开发的,且本版本的es需要的jdk版本要是1.8以上,所以安ElasticSearch
之前保证JDK1.8+安装完毕,并正确的配置好JDK环境变量,否则启动ElasticSearch失败。

Installation of the graphical interface plug-ES

ElasticSearch不同于Solr自带图形化界面,我们可以通过安装ElasticSearch的head插件,完成图形化界面
的效果,完成索引数据的查看。安装插件的方式有两种,在线安装和本地安装。本文档采用本地安装方式
进行head插件的安装。elasticsearch-5-*以上版本安装head需要安装node和grunt

Download head plug: https: //github.com/mobz/elasticsearch-head
Here Insert Picture Description
will elasticsearch-head-master archive into any directory, but to distinguish elasticsearch installation directory and open
download nodejs: https: //nodejs.org/ en / download /
Here Insert Picture Description
click the installer, screenshot steps as follows:
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
all the way next. . . The installation is complete, you can enter cmd console: node -v view the version number
will grunt installed as global commands, Grunt is Node.js project-based build tool
, enter the following command in cmd execution console: npm install -g grunt-cli
execution the results shown below:
Here Insert Picture Description
enter elasticsearch-head-master directory of the boot head, enter the command at the command prompt:
npm install
Grunt Server
Here Insert Picture Description
open the browser, type http: // localhost: 9100, see the following page:
Here Insert Picture Description
If you can not successfully connect to es service, you need to modify the configuration files in the config directory ElasticSearch: config / elasticsearch.yml, add the following two commands can be accessed across domains:
http.cors.enabled: to true
http.cors.allow-Origin: "*"
then restart ElasticSearch service.

Elasticsearch是面向文档(document oriented)的,这意味着它可以存储整个对象或文档(document)。然而
它不仅仅是存储,还会索引(index)每个文档的内容使之可以被搜索。在Elasticsearch中,你可以对文档
(而非成行成列的数据)进行索引、搜索、排序、过滤。Elasticsearch比传统关系型数据库如下:
Relational DB ‐> Databases ‐> Tables ‐> Rows ‐> Columns
Elasticsearch ‐> Indices   ‐> Types  ‐> Documents ‐> Fields

Elasticsearch core concepts

Index index

一个索引就是一个拥有几分相似特征的文档的集合。比如说,你可以有一个客户数据的索引,另一个产品
目录的索引,还有一个订单数据的索引。一个索引由一个名字来标识(必须全部是小写字母的),并且当
我们要对对应于这个索引中的文档进行索引、搜索、更新和删除的时候,都要使用到这个名字。在一个集
群中,可以定义任意多的索引。

Type type

在一个索引中,你可以定义一种或多种类型。一个类型是你的索引的一个逻辑上的分类/分区,其语义完全
由你来定。通常,会为具有一组共同字段的文档定义一个类型。比如说,我们假设你运营一个博客平台并
且将你所有的数据存储到一个索引中。在这个索引中,你可以为用户数据定义一个类型,为博客数据定义
另一个类型,当然,也可以为评论数据定义另一个类型。

Field field
equivalent to a field data table, the document data classified according to different attribute identification
mappings mapping

mapping是处理数据的方式和规则方面做一些限制,如某个字段的数据类型、默认值、分析器、是否被索
引等等,这些都是映射里面可以设置的,其它就是处理es里面数据的一些使用规则设置也叫做映射,按着
最优规则处理数据对性能提高很大,因此才需要建立映射,并且需要思考如何建立映射才能对性能更好。

Documentation document

一个文档是一个可被索引的基础信息单元。比如,你可以拥有某一个客户的文档,某一个产品的一个文
档,当然,也可以拥有某个订单的一个文档。文档以JSON(Javascript Object Notation)格式来表示,
而JSON是一个到处存在的互联网数据交互格式。在一个index/type里面,你可以存储任意多的文档。注
意,尽管一个文档,物理上存在于一个索引之中,文档必须被索引/赋予一个索引的type。

Near real-time NRT
elasticsearch is a near real-time search platform. This means that a document from the index until this document can be searched there is a slight delay (usually within 1 second)

Published 81 original articles · won praise 5 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_36205206/article/details/104642614