一. kibana安裝java
1.到官網或是用brew下載kibana 安裝包,這邊咱們選擇在官網下載對應的安裝包 https://www.elastic.co/cn/downloads/kibana
node
2.解壓縮到對應的目錄下,咱們解壓縮到了 /usr/local/kibana-6.5.2-darwin-x86_64webpack
解壓縮後的相關目錄以下:web
➜ kibana-6.5.2-darwin-x86_64 ls LICENSE.txt bin node package.json webpackShims NOTICE.txt config node_modules plugins README.txt data optimize src
3.快速啓動 數據庫
cd 到對應的bin目錄下,執行nohup sh kibana &json
查看啓動日誌:api
1 {"type":"response","@timestamp":"2018-12-19T11:20:30Z","tags":[],"pid":8563,"method":"post","statusCode":200,"req":{"url":"/api/console/proxy?path=_template&method=GET","method":"post","headers":{"host":"localhost:5601","connection":"keep-alive","content-length":"0","accept":"text/plain, */*; q=0.01","origin":"http://localhost:5601","kbn-version":"6.5.2","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36","referer":"http://localhost:5601/app/kibana","accept-encoding":"gzip, deflate, br","accept-language":"zh-CN,zh;q=0.9,en;q=0.8"},"remoteAddress":"::1","userAgent":"::1","referer":"http://localhost:5601/app/kibana"},"res":{"statusCode":200,"responseTime":22,"contentLength":9},"message":"POST /api/console/proxy?path=_template&method=GET 200 22ms - 9.0B"}
能夠看到綁定端口爲5601瀏覽器
4.查看進程數據結構
執行ps -ef|grep nodeapp
501 8563 2099 0 6:43下午 ttys000 0:27.66 ./../node/bin/node --no-warnings ./../src/cli
5.瀏覽器訪問 http://localhost:5601/app/kibana 進入Dev Tools界面
1.document數據格式
面向文檔的搜索分析引擎
(1)應用系統的數據結構都是面向對象的,複雜的
(2)對象數據存儲到數據庫中,只能拆解開來,變爲扁平的多張表,每次查詢的時候還得還原回對象格式,至關麻煩
(3)ES是面向文檔的,文檔中存儲的數據結構,與面向對象的數據結構是同樣的,基於這種文檔數據結構,es能夠提供複雜的索引,全文檢索,分析聚合等功能
(4)es的document用json數據格式來表達
2.簡單的集羣管理
(1)快速檢查集羣的健康情況
es提供了一套api,叫作cat api,能夠查看es中各類各樣的數據
GET /_cat/health?v
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1545272412 02:20:12 elasticsearch green 1 1 1 1 0 0 0 0 - 100.0%
如何快速瞭解集羣的健康情況?green、yellow、red?
green:每一個索引的primary shard和replica shard都是active狀態的
yellow:每一個索引的primary shard都是active狀態的,可是部分replica shard不是active狀態,處於不可用的狀態
red:不是全部索引的primary shard都是active狀態的,部分索引有數據丟失了
(2)快速查看集羣中有哪些索引
GET /_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .kibana_1 4OzsBQhJROuREyl8ZadWCQ 1 0 3 0 11.9kb 11.9kb
(3)簡單的索引操做
建立索引:PUT /test_index?pretty
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size green open .kibana_1 4OzsBQhJROuREyl8ZadWCQ 1 0 3 0 11.9kb 11.9kb yellow open test_index QmrZBLhPQkG41DSt-rLzfQ 5 1 0 0 1.1kb 1.1kb
刪除索引:DELETE /test_index?pretty
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open .kibana_1 4OzsBQhJROuREyl8ZadWCQ 1 0 3 0 11.9kb 11.9kb
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1545275286 03:08:06 elasticsearch yellow 1 1 6 6 0 0 5 0 - 54.5%
(1)新增:新增文檔,創建索引
PUT /index/type/id { "json數據" } PUT /ecommerce/product/1 { "name" : "gaolujie yagao", "desc" : "gaoxiao meibai", "price" : 30, "producer" : "gaolujie producer", "tags": [ "meibai", "fangzhu" ] } { "_index": "ecommerce", "_type": "product", "_id": "1", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "created": true } PUT /ecommerce/product/2 { "name" : "jiajieshi yagao", "desc" : "youxiao fangzhu", "price" : 25, "producer" : "jiajieshi producer", "tags": [ "fangzhu" ] } PUT /ecommerce/product/3 { "name" : "zhonghua yagao", "desc" : "caoben zhiwu", "price" : 40, "producer" : "zhonghua producer", "tags": [ "qingxin" ] }
es會自動創建index和type,不須要提早建立,並且es默認會對document每一個field都創建倒排索引,讓其能夠被搜索
(2)查詢:檢索文檔
GET /index/type/id GET /ecommerce/product/1 { "_index": "ecommerce", "_type": "product", "_id": "1", "_version": 1, "found": true, "_source": { "name": "gaolujie yagao", "desc": "gaoxiao meibai", "price": 30, "producer": "gaolujie producer", "tags": [ "meibai", "fangzhu" ] } }
(3)修改:替換文檔
PUT /ecommerce/product/1 { "name" : "jiaqiangban gaolujie yagao", "desc" : "gaoxiao meibai", "price" : 30, "producer" : "gaolujie producer", "tags": [ "meibai", "fangzhu" ] } { "_index": "ecommerce", "_type": "product", "_id": "1", "_version": 1, "result": "created", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "created": true } { "_index": "ecommerce", "_type": "product", "_id": "1", "_version": 2, "result": "updated", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "created": false } PUT /ecommerce/product/1 { "name" : "jiaqiangban gaolujie yagao" }
替換方式有一個很差,即便必須帶上全部的field,才能去進行信息的修改
(4)修改:更新文檔
POST /ecommerce/product/1/_update { "doc": { "name": "jiaqiangban gaolujie yagao" } } { "_index": "ecommerce", "_type": "product", "_id": "1", "_version": 8, "result": "updated", "_shards": { "total": 2, "successful": 1, "failed": 0 } }
(5)刪除:刪除文檔
DELETE /ecommerce/product/1 { "found": true, "_index": "ecommerce", "_type": "product", "_id": "1", "_version": 9, "result": "deleted", "_shards": { "total": 2, "successful": 1, "failed": 0 } } { "_index": "ecommerce", "_type": "product", "_id": "1", "found": false }