数据分析框架
来源:互联网 发布:centos7 软件管理器 编辑:程序博客网 时间:2024/06/06 19:48
ELK
是Elastic
公司推出的开源数据分析框架,目前流行于构建Log/Trace
分析平台,该框架主要由三个开源软件Elasticsearch
,Logstash
和kibana
组成,这三者构成数据分析框架的通用范式,即Ingest Pipeline => Database & Indexing => Logical Frontend
。
数据分析范式 + 数据存储格式
1. Ingest Pipeline
,将原始数据转化为数据库所对应的存储格式。
2. Database & Indexing
,以特定格式存储数据并通过外部接口提供数据索引检索功能。
3. Logical Frontend
,基于特定逻辑发送数据检索消息并对回馈的数据进行相应的分析处理。
数据存储格式是实现数据库存储功能的关键技术点,传统的关系型数据使用所谓“表类型”的存储方式,这种方式的特点是其“表头(Column)
”字段固定且表建立后无法更改,在如今大数据应用的背景下愈发不灵活,因此出现了摒弃“表”的所谓NoSQL
数据库,例如MongoDB
就使用JSON
条目({ xx : yy }
)替代传统表的Record
,Elasticsearch
采用MongoDB
所使用的“JSON
文档”方式,对比下表可以发现Elasticsearch
中没有所谓DB
的概念,其顶级节点Index
直接类似于MySQL
的Table
以及MongoDB
的Collection
,于其中存储格式数据即JSON
条目,根据Elasticsearch
的方案规定,每条JSON
记录都要定义其Type
和Document ID
,分别对应字段_type
和_id
以用于后期检索,记录数据存放在_source
子字段中。
MySQL: DB -> Table <=> Column&Record (TABLE-TYPE)MongoDB: DB -> Collection <=> { field : value } (JSON-TYPE)Elasticsearch: Index <=> { _index : xx , _type : xx, _id : xx, _source : { field : value } } {JSON-TYPE}
ELK
Elastic
产品的UG
内容详实非常实用,用于指导How to do
绰绰有余,且软件均基于Java
等跨平台语言开发因此无需安装只需配置Java
环境下载解压即可运行程序。
https://www.elastic.co/guide/en/logstash/current/index.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
https://www.elastic.co/guide/en/kibana/current/index.html
1. Logstash
Logstash
是对数据处理的管道工具,其中两个必须定义的管道为Input
和Output
,可选的中间管道为Filter
,所以Logstash
的数据处理流程即为Source -> Input -> Filter -> Output -> Destination
,管道配置可以通过“-e
”参数直接在命令行中指定,也可以定义在文件中通过“-f
”参数指定文件,管道配置如下所示。
input { file { path => "/var/log/syslog" } tcp { port => 13000 type => syslog } udp { port => 13000 type => syslog }}filter { grok { match => { "message" => "%{COMBINEDAPACHELOG}" } } date { match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ] }}output { stdout { codec => rubydebug } file { path => "/home/ce/file" } elasticsearch { hosts => localhost }}
其中各个管道中子命令都是可选配置,最简单的执行命令是bin/logstash -e 'input { stdin { } } output { stdout { } }'
。
2. Elasticsearch
Elasticsearch
是数据分析的核心,用于数据的格式化存储以及索引检索,其数据库功能类似于MongoDB
使用Index
记录若干个JSON
条目,其检索功能基于开源项目Lucene
并提供基于JSON
交互的RESTful
接口,下载Elasticsearch
软件包解压后直接执行bin/elasticsearch
即可运行程序,因对内核性能要求较高所以需要优化内核参数。
sysctl -w vm.max_map_count=262144#/etc/sysctl.confvm.max_map_count=262144#/etc/security/limits.conf* soft nofile 65536* hard nofile 131072* soft nproc 2048* hard nproc 4096
Elasticsearch
启动后默认监听127.0.0.1
的9200
端口,如需外部流量访问的话就要更改config/elasticsearch.yml
中network.host: 0.0.0.0
即可通过http://<IP>:9200
访问RESTful
接口。
curl -XGET 'localhost:9200/_cat/health?v'curl -XGET 'localhost:9200/_cat/indices?v'#Data Addcurl -XPUT 'localhost:9200/customer?pretty'curl -XPUT 'localhost:9200/customer/doc/1?pretty' -H 'Content-Type: application/json' -d'{ "name": "John Doe" }'curl -XPOST 'localhost:9200/customer/doc/_bulk?pretty' -H 'Content-Type: application/json' -d'{"index":{"_id":"2"}}{"name": "John Doe", "yesno": "yes", "goodbad": "bad"}{"index":{"_id":"3"}}{"name": "Jane Doe" ,"yesno": "yes", "goodbad": "good"}{"index":{"_id":"4"}}{"name": "Tom Doe" ,"yesno": "yesd", "goodbad": "goodd"}'curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary @accounts.json###accounts.json###{"index":{"_id":"1"}}{"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/shakespeare/doc/_bulk?pretty' --data-binary @shakespeare_6.0.json###shakespeare_6.0.json###{"index":{"_index":"shakespeare","_id":0}}{"type":"act","line_id":1,"play_name":"Henry IV", "speech_number":"","line_number":"","speaker":"","text_entry":"ACT I"}curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/_bulk?pretty' --data-binary @logs.jsonl###logs.jsonl###{"index":{"_index":"logstash-2015.05.18","_type":"log"}}{"@timestamp":"2015-05-18T09:03:25.877Z","ip":"185.124.182.126","extension":"gif","response":"404","@version":"1"}#Data Deletecurl -XDELETE 'localhost:9200/customer?pretty'#Data Getcurl -XGET 'localhost:9200/customer/doc/1?pretty'#Data Searchcurl -XGET 'localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'{ "query": { "match_all": {} }}'curl -XGET 'http://localhost:9200/_search?pretty' -H 'Content-Type: application/json' -d'{"query": { "match": {"name":"Jane"} }}'
3. Kibana
Kibana
是架构中的Web
前端,用于检索数据并对回馈的数据进行可视化处理,下载软件包解压后首先编辑config/kibana.yml
配置文件指定Elasticsearch RESTful
接口地址和Kibana Web
服务监听IP
。
server.host: "0.0.0.0"elasticsearch.url: "http://localhost:9200"
执行bin/kibana
启动Kibana
服务,默认监听port
口为5601
,访问http://<ip>:5601
即可进入Kibana Web
页面。
a. Management - Index Patterns
Index Pattern
即对Elasticsearch
数据库中的Index
名称进行匹配,如使用通配符*
即可匹配多个Index
,建立Index Pattern
后对应Index
的数据就可以在Discover
页面检索到。
b. Discover
该页面可以显示相应Index
中的数据,注意左上角的TimeRange
,如果提示No Data Found
调整时间范围即可。
c. Visualize
该页面可以使用Index
中某些字段的数据进行绘图,功能比较强大。
d. Dashboard
该页面可以将上步建立的可视化图表作为独立模块显示。
PS: Dev Tools - Console
该工具类似于curl
用于发送RESTful
接口消息给Elasticsearch
,通常用于调试,比直接使用curl
用户体验好。
- 游戏数据分析框架
- 数据分析框架
- Android_ics_stagefright框架数据流向分析
- 数据分析框架Pandas入门
- 数据分析框架Pandas进阶
- 数据分析挖掘框架总结
- python短域名数据分析框架
- 如何建立数据分析的思维框架
- grafana-大数据图表监控分析框架
- 数据分析处理开源框架杂谈
- 如何建立数据分析的思维框架
- Flume源码分析—数据流转框架分析(五)
- spring.net 框架分析(六)数据访问
- Apache Drill: 大数据集互动分析的分布式框架
- Apache Drill: 大数据集互动分析的分布式框架
- 可视化设计数据分析统计图形框架总结
- 高并发大数据采集分析系统框架设计
- Spark大数据分析框架的核心部件
- java:23种设计模式详解
- Ubuntu 使用HugePage 加速应用
- Eclipse rcp 开发中常用快捷键和相关功能
- 解决 Android 中 View 的 setPivotX 和 setPivotY 不生效的问题以及设置缩放中心的方法
- 安全(主要XSS与CSRF)
- 数据分析框架
- 解决eclipse中maven项目build的时候,console显示teminated,没有任何打印信息
- clone 克隆
- 数据存储全方案--详解持久化技术
- Maven学习笔记
- JS封装类或对象的最佳方案
- linux 工作服务器环境切换
- 前端常用开发工具
- (洛谷 1108)低价购买