ELK搭建步骤以及使用API的基本操作

ELK=elasticsearch+Logstash+kibana 
elasticsearch:后台分布式存储以及全文检索 
logstash: 日志加工、“搬运工” 
kibana:数据可视化展示。 
ELK架构为数据分布式存储、可视化查询和日志解析创建了一个功能强大的管理链。 三者相互配合,取长补短,共同完成分布式大数据处理工作。
2. ES特点和优势
    1)分布式实时文件存储,可将每一个字段存入索引,使其可以被检索到。 
    2)实时分析的分布式搜索引擎。 
        分布式:索引分拆成多个分片,每个分片可有零个或多个副本。集群中的每个数据节点都可承载一个或多个分片,并且协调和处理各种操作; 
        负载再平衡和路由在大多数情况下自动完成。 
    3)可以扩展到上百台服务器,处理PB级别的结构化或非结构化数据。也可以运行在单台PC上(已测试) 
    4)支持插件机制,分词插件、同步插件、Hadoop插件、可视化插件等。
--------------------- 
ES科普教程:https://blog.csdn.net/laoyang360/article/details/52244917
为什么要用ES:https://www.quora.com/Why-do-people-use-Hadoop-or-Spark-when-there-is-ElasticSearch
curl -X PUT "localhost:9200/customer?pretty"       创建一个index  

curl -X GET "localhost:9200/_cat/indices?v"            查看index的状态信息

curl -X PUT "localhost:9200/customer/doc/2?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Leo"
}
'                                                    在index里插入一些json数据

curl -X DELETE "localhost:9200/customer?pretty"       删除一个index(此处customer为一个index名)
--------
<REST Verb> /<Index>/<Type>/<ID>                      REST访问模式

curl -X POST "localhost:9200/customer/doc/2?pretty" -H 'Content-Type: application/json' -d'
{
  "name": "Jane Doe"  
}
'                                           修改index为customer,type为doc下,id为2的json,name改为“Jane Doe”

curl -X POST "localhost:9200/customer/doc/1/_update?pretty" -H 'Content-Type: application/json' -d'
{
  "doc": { "name": "Jane Doe", "age": 20 }
}
'                                             更新操作 添加了属性age 

curl -X POST "localhost:9200/customer/doc/1/_update?pretty" -H 'Content-Type: application/json' -d'
{
  "script" : "ctx._source.age += 5"
}
'                                             更新操作 更新了age的值

curl -X DELETE "localhost:9200/customer/doc/2?pretty"     删除id为2的所有json

curl -X POST "localhost:9200/customer/doc/_bulk?pretty" -H 'Content-Type: application/json' -d'
{"index":{"_id":"1"}}
{"name": "John Doe" }
{"index":{"_id":"2"}}
{"name": "Jane Doe" }
'
curl -X POST "localhost:9200/customer/doc/_bulk?pretty" -H 'Content-Type: application/json' -d'
{"update":{"_id":"1"}}
{"doc": { "name": "John Doe becomes Jane Doe" } }
{"delete":{"_id":"2"}}
'
以上为调用了_bulk API 实现批处理,可以同时实现多种操作

curl -H "Content-Type: application/json" -XPOST 'localhost:9200/bank/account/_bulk?pretty&refresh' --data-binary

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值