elasticsearch+kibana数据可视化

本文主要介绍基础的elasticsearch集群搭建,elasticsearch集群head组件以及利用kibana产品进行数据可视化,主要内容还是ELK中的EK, L(logstash)暂不介绍。

1 基础环境
首先是必须安装 java nodejs
因为es是java开发并使用Lucene作为其核心来实现所有索引和搜索的功能,但是它的目的是通过简单的RESTful API来隐藏Lucene的复杂性,从而让全文搜索变得简单,而head组件需要npm启动

2 es一整套产品线
https://www.elastic.co/downloads
elk

3 elasticsearch介绍及应用场景
(1)分布式的搜索引擎和数据分析引擎
(2)全文检索,结构化检索,数据分析
(3)对海量数据进行近实时的处理

4 elasticsearch文档
https://es.xiaoleilu.com/
https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

5 集群安装
安装比较简单,官网下载es安装包这里下载的Windows环境的包,解压到本地某个目录,然后复制两份,从而构建一个3节点的es集群。

#配置文件在每个node目录下的config/elasticsearch.yml,具体配置如下:
node-1
cluster.name: es-application
node.name: node-1
network.host: 127.0.0.1
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"]  
http.cors.enabled: true 
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.minimum_master_nodes: 2

node-2 
cluster.name: es-application
node.name: node-2
network.host: 127.0.0.1
http.port: 9201
transport.tcp.port: 9301
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"]  
http.cors.enabled: true 
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.minimum_master_nodes: 2

node-3
cluster.name: es-application
node.name: node-3
network.host: 127.0.0.1
http.port: 9202
transport.tcp.port: 9302
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9300", "127.0.0.1:9301", "127.0.0.1:9302"]  
http.cors.enabled: true 
http.cors.allow-origin: "*"
node.master: true
node.data: true
discovery.zen.minimum_master_nodes: 2

node.master:这个属性表示节点是否具有成为主节点的资格
注意:此属性的值为true,并不意味着这个节点就是主节点。因为真正的主节点,是由多个具有主节点资格的节点进行选举产生的。所以,这个属性只是代表这个节点是不是具有主节点选举资格。
node.data:这个属性表示节点是否存储数据。
discovery.zen.minimum_master_nodes: 2 Prevent the “split brain” by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1), 配置master node数量,防止脑裂问题。

分别到每个目录下的bin下执行elasticsearch.bat,即可启动集群,浏览器访问 localhost:9200即可看到集群信息

6 集群界面化管理
elasticsearch-head
在github上下载zip包并解压,https://github.com/mobz/elasticsearch-head

然后执行

npm install 
npm run
npm run start

在浏览器中访问 localhost:9100,即可看到head界面
es-head
如果集群无法连接,是跨域问题

http.cors.enabled: true
http.cors.allow-origin: "*"

在head界面上,可以查看集群、索引、节点、数据以及进行基本查询和复合查询。

7 kibana数据可视化
es官网下载kibana组件,解压并配置 kibana.yml 文件中的 Elasticsearch URL

elasticsearch.url: "http://localhost:9200"

执行bin/kibana.bat,会在es中创建.kibana索引
.kibana index
浏览器访问 localhost:5601,将看到kibana的界面
kibana interface
在management项里,使用create index pattern 把某个索引的数据加载进来

基本查询语法:
title:kibana # 搜索title中包含kibana的记录
content:*索* # 搜索content中包含‘索’的记录
title:kibana AND content:kibana # 搜索title 并且 content中都包含kibana的记录
title:kibana OR content:kibana # 搜索title 或者 content中都包含kibana的记录
NOT title:学习 #搜索title中不包含学习的记录
title:“学习123123” #精确匹配短语记录

8 elasticsearch内存分配问题
https://www.cnblogs.com/jiu0821/p/5650027.html

参考文档:
https://blog.csdn.net/u012270682/article/details/72934270 2
https://blog.csdn.net/laoyang360/article/details/52244917 3
https://www.elastic.co/guide/cn/kibana/current/connect-to-elasticsearch.html

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值