文章目錄
- 一、安裝Error彙總
- 1. 由於Elasticsearch可以輸入且執行腳本,爲了系統安全,不允許使用root啓動
- 2. 外部無法訪問
- 3. 解決 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- 4. sysctl: setting key "vm.max_map_count": Read-only file system
- 5. the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
- 二、kibana使用案例
一、安裝Error彙總
1. 由於Elasticsearch可以輸入且執行腳本,爲了系統安全,不允許使用root啓動
useradd -m work
su work
2. 外部無法訪問
vim elasticsearch.yml
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
3. 解決 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
// 修改下面的文件 裏面是一些內核參數
vi /etc/sysctl.conf
//添加以下配置
vm.max_map_count=655360
保存,然後:
sysctl -p
//-p 從指定的文件加載系統參數,如不指定即從/etc/sysctl.conf中加載
會提示錯誤:
4. sysctl: setting key “vm.max_map_count”: Read-only file system
這是因爲Docker的base image做的很精簡,甚至都沒有init進程,原本在OS啓動時執行生效系統變量的過程(sysctl -p)也給省略了,導致這些系統變量依舊保留着kernel默認值,這時候需要我們在容器啓動時加入 –privileged 來獲取修改系統參數的權限
這裏我選擇的是修改宿主機本身的配置文件,然後重新啓動鏡像,也能解決問題,退出容器,返回到宿主機
修改vm.max_map_count 可以通過命令行修改,但是在機器重啓時會失效,所以通過修改配置文件來解決問題
命令行修改辦法:
sudo sysctl -w vm.max_map_count=655360
5. the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
elasticsearch.yml文件
node.name: node-1 前面的#打開
cluster.initial_master_nodes: ["node-1"] 這裏一定要這樣設置,我就是這裏沒有這樣設置出問題的,弄了好久
二、kibana使用案例
1. 數據集
- William Shakespeare的全部作品,適當地解析成字段,下載
shakespeare.json
數據結構:
{
"line_id": INT,
"play_name": "String",
"speech_number": INT,
"line_number": "String",
"speaker": "String",
"text_entry": "String",
}
2. 設置映射
在Kibana Dev Tools > Console,爲Shakespeare數據集設置映射:
PUT /shakespeare
{
"mappings": {
"properties": {
"doc": {
"properties": {
"speaker": {
"type": "keyword"
},
"play_name": {
"type": "keyword"
},
"line_id": {
"type": "integer"
},
"speech_number": {
"type": "integer"
}
}
}
}
}
}
3. 加載數據集
curl -H 'Content-Type: application/x-ndjson' -XPOST '49.52.10.203:9200/shakespeare/doc/_bulk?pretty' --data-binary @shakespeare_6.0.json
驗證加載成功:
GET /_cat/indices?v
4. 定義索引模式
Error: FAILED TO PARSE MAPPING [_DOC]: ROOT MAPPING DEFINITION HAS UNSUPPORTED PARAMETERS
With Elastic search 7.0 , types were removed and when creating a mapping it no longer accepts types which is a breaking change
PUT /shakespeare
{
"mappings": {
"properties": {
"doc": {
"properties": {
"speaker": {
"type": "keyword"
},
"play_name": {
"type": "keyword"
},
"line_id": {
"type": "integer"
},
"speech_number": {
"type": "integer"
}
}
}
}
}
}