ElasticSearch 慕课网(一)

第一章 ElasticSearch 和 kibana 入门

第一节  ElasticSearch 的安装与运行

1、下载 jdk 1.8 版本

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

2、下载 ElasticSearch 

https://www.elastic.co/cn/downloads/elasticsearch

3、运行 ElasticSearch 

bin/elasticsearch 

4、Chrome 访问  http://127.0.0.1:9200/

第二节 ElasticSearch 的配置说明

一、配置文件位于 config 目录中:

1、elasticsearch.yml  es的相关配置;

cluster_name :集群名称,以此作为是否同一集群的判断条件

node.name :节点名称,以此作为集群中不同节点的区分条件

network.host/http.port : 网络地址和端口 ,用于 http 和 transport 服务使用

path.data :数据存储地址

path.log : 日志存储地址

2、jvm.options  jvm的相关参数  (例如内存大小)

3、log4j2.properties 日志相关配置  (例如日志的级别)

二、两种开发模式 Development (开发者模式) 和 Production(线上跑) 的模式

ElasticSearch 在运行之前会对电脑进行检查,例如检查你的磁盘是否够用,当前内存设置是不是正确的,当前操作系统的版本对于一些特性是否支持。

判断是哪个模式的标准:以 transport 的地址是否绑定在localhost 为判断标准 network.host 

二者区别:

Development 模式下在启动时会以warning 的方式提示配置检查异常

Production模式下载启动时会以error 的方式提示配置检查异常并退出

第三节 如何搭建 ElasticSearch 的集群

1、ElasticSearch 的本地集群启动方式

①、bin/elasticsearch.bat

②、bin/elasticsearch -Ehttp.port=8200 -Epath.data = node2

③、bin/elasticsearch -Ehttp.port=7200 -Epath.data = node3

2、进行查看

http://127.0.0.1:9200/_cat/nodes?v

http://127.0.0.1:9200/_cluster/stats

第四节  Kibana 安装与演示

1、官网下载

https://www.elastic.co/downloads/kibana

 

2、运行

bin/Kibana

http://localhost:5601/app/kibana#/home?_g=()

3、配置说明

配置位于 config 文件夹中 

kibana.yml 关键配置说明

   server.host/server.port 访问 kibana 用的地址和端口

   elasticsearch.url 待访问 elasticsearch 的地址

4、kibana 的常用功能

discover 数据搜索查看

visualize 图表制作

dashboard 仪表盘制作

timelion 时序数据的高级可视化分析

devtools 开发者工具

management 配置

第五节 Elasticsearch 术语介绍和 CRUD 操作

1、Elasticsearch  常用语法

常用术语

Document 文档数据

Index 索引

Type 索引中的数据类型

Field字段,文档的属性

Query DSL 查询语法

2、增删改查

增 :POST /accounts/person/1
{
  "name":"wenyan",
  "lastname":"cxm",
  "job_description": "Systems administrator and Linux specialit"

}

查:GET /accounts/person/1

改:POST /accounts/person/1/_update
{
  "doc":{
    "job_description" : "Teacher"
  }
}

删:DELETE /accounts/person/1_updat

查:GET /accounts/person/1_update

第六节 Elasticsearch 的查询方式 -- Elasticsearch Qusery

1、两种方式 :Query  String  和 Query DSL 

Query String :

GET /accounts/person/_search?q=cxm

Query DSL : 是按照 json 语法

GET /accounts/person/_search
{
  "query": {
    "term": {
      "name": {
        "value": "wenyan"
      }
    }
  }
}

两个查询结果都一样!!! 

2、更多的查询语法详见文档

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html

猜你喜欢

转载自blog.csdn.net/qq_28289405/article/details/87933786