Elasticsearch與Kibana部署及使用
安裝環境
Mac OS 適用於Linux
版本說明
Elasticsearch:6.4.0
Kibana:6.4.0
1 Elasticsearch部署及使用
1.1 下載Elasticsearch
下載地址:https://www.elastic.co/downloads/elasticsearch
選擇系統環境相應版本進行下載,這裏下載Mac 6.4.0版本(Linux通用)
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.tar.gz
解壓
tar -zxvf elasticsearch-6.4.0.tar.gz
1.2 配置
配置文件位置elasticsearch-6.4.0/config,修改文件elasticsearch.yml
vi elasticsearch.yml
修改內容如下:
bootstrap.system_call_filter: false
network.host: 0.0.0.0
說明:
-
bootstrap.system_call_filter: false # 防止系統不支持SecComp報錯
-
network.host: 0.0.0.0 # 綁定IP
1.3 啓動服務
在elasticsearch-6.4.0/bin目錄下啓動
nohup ./elasticsearch >elastic.out &
服務啓動後訪問地址http://192.168.1.196:9200/:
1.4 簡單使用
1.4.1 添加索引庫
服務地址http://192.168.1.196:9200/,命令行執行
curl -XPUT 'http://192.168.1.196:9200/test_es'
執行結果:
{"acknowledged":true,"shards_acknowledged":true,"index":"test_es"}
1.4.2 查看索引庫
curl -XGET 'http://192.168.1.196:9200/_search'
結果:
{
"took": 184,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
1.4.3 創建索引
curl -XPOST 'http://192.168.1.196:9200/test_es/student/1' -H 'Content-Type:application/json' -d '{
"name":"test",
"age":5,
"interests":["Spark","Hadoop"]
}'
執行結果:
{
"_index": "test_es",
"_type": "student",
"_id": "1",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1
}
1.4.4 查詢索引
curl -XGET 'http://192.168.1.196:9200/_search?pretty'
執行結果:
{
"took" : 19,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "test_es",
"_type" : "student",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"name" : "test",
"age" : 5,
"interests" : [
"Spark",
"Hadoop"
]
}
}
]
}
1.4.7 刪除索引
curl -XDELETE 'http://192.168.1.188:9200/wwaes'
{"acknowledged":true}
2 Kibana部署及使用
2.1 下載Kibana
下載地址:https://www.elastic.co/downloads/kibana
選擇系統環境相應版本進行下載,這裏下載Mac 6.4.0版本(Linux請選擇相應版本)
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.4.0-darwin-x86_64.tar.gz
解壓
tar -zxvf kibana-6.4.0-darwin-x86_64.tar.gz
2.2 配置
配置文件位置kibana-6.4.0-darwin-x86_64/config,修改文件kibana.yml
vi kibana.yml
修改內容如下:
server.port: 5601
server.host: "0.0.0.0"
說明:
- server.port: 5601 # 服務端口號
- server.host #服務IP
2.3 啓動服務
在kibana-6.4.0-darwin-x86_64/bin目錄下啓動
nohup ./kibana >kibana.out &
服務啓動後訪問地址http://192.168.1.196:5601/: