elasticsearch:
常用的es接口查詢操作命令:
curl http://elasticsearch:9200/
##這三條shell命令都可以監控到Elasticsearch健康狀態
curl http://elasticsearch:9200/_cat/health
curl http://elasticsearch:9200/_cluster/health
curl http://elasticsearch:9200/_cluster/health?pretty
##查看Elasticsearch健康狀態 (*表示ES集群的master主節點)
curl http://elasticsearch:9200/_cat/nodes?v
curl http://elasticsearch:9200/_cat/health?v
##查看Elasticsearch 索引狀態 (*表示ES集群的master主節點)
curl http://elasticsearch:9200/_cat/indices?v
curl http://elasticsearch:9200/_cluster/health?level=indices
##單節點 刪除那些指定不明確的副本分片 集群的狀態狀態變成了green
curl -XPUT -H 'Content-Type: application/json' "http://elasticsearch:9200/_settings" -d '{ "number_of_replicas" : 0 }'
##查看集群中不同節點、不同索引的狀態
curl http://elasticsearch:9200/_cat/shards?h=index,shard,prirep,state,unassigned.reason
##這個分片數據已經不可用,直接刪除該分片 (即刪除索引)--極端情況
curl -X DELETE http://elasticsearch:9200/索引名
##使用curl命令模擬訪問任意一個elasticsearch集群
curl http://elasticsearch:9200/_cluster/stats?human&pretty
##查看出問題的索引以及原因
curl http://elasticsearch:9200/_cluster/allocation/explain?pretty
##嘗試重新恢復失敗的分片
curl -XPOST -H 'Content-Type: application/json' http://elasticsearch:9200/_cluster/reroute?retry_failed=true
正常情況下,Elasticsearch 集群健康狀態分為三種:
green 最健康得狀態,說明所有的分片包括備份都可用; 這種情況Elasticsearch集群所有的主分片和副本分片都已分配, Elasticsearch集群是 100% 可用的。
yellow 基本的分片可用,但是備份不可用(或者是沒有備份); 這種情況Elasticsearch集群所有的主分片已經分片了,但至少還有一個副本是缺失的。不會有數據丟失,所以搜索結果依然是完整的。不過,你的高可用性在某種程度上被弱化。如果 更多的 分片消失,你就會丟數據了。把 yellow 想象成一個需要及時調查的警告。
red 部分的分片可用,表明分片有一部分損壞。此時執行查詢部分數據仍然可以查到,遇到這種情況,還是趕快解決比較好; 這種情況Elasticsearch集群至少一個主分片(以及它的全部副本)都在缺失中。這意味着你在缺少數據:搜索只能返回部分數據,而分配到這個分片上的寫入請求會返回一個異常。
單點單節點部署Elasticsearch, 集群狀態可能為yellow, 因為單點部署Elasticsearch, 默認的分片副本數目配置為1,而相同的分片不能在一個節點上,所以就存在副本分片指定不明確的問題,所以顯示為yellow
unassigned 分片問題可能的原因?
INDEX_CREATED: 由於創建索引的API導致未分配。
CLUSTER_RECOVERED: 由於完全集群恢復導致未分配。
INDEX_REOPENED: 由於打開open或關閉close一個索引導致未分配。
DANGLING_INDEX_IMPORTED: 由於導入dangling索引的結果導致未分配。
NEW_INDEX_RESTORED: 由於恢復到新索引導致未分配。
EXISTING_INDEX_RESTORED: 由於恢復到已關閉的索引導致未分配。
REPLICA_ADDED: 由於顯式添加副本分片導致未分配。
ALLOCATION_FAILED: 由於分片分配失敗導致未分配。
NODE_LEFT: 由於承載該分片的節點離開集群導致未分配。
REINITIALIZED: 由於當分片從開始移動到初始化時導致未分配(例如,使用影子shadow副本分片)。
REROUTE_CANCELLED: 作為顯式取消重新路由命令的結果取消分配。
REALLOCATED_REPLICA: 確定更好的副本位置被標定使用,導致現有的副本分配被取消,出現未分配。
kibana:
https://artifacts.elastic.co/downloads/kibana/kibana-oss-7.0.1-windows-x86_64.zip
##下載oos版本的kibana(應與es的版本保持一致,防止出現意外情況)
https://www.docker.elastic.co/r/kibana/kibana-oss
docker 方式:
docker pull docker.elastic.co/kibana/kibana-oss:7.0.1
docker run -d -p 5601:5601 --name kb 2c45a33188a0
find / -name kibana.yml ##找到容器對應的日志文件,將連接elasticsearch的url改成es的ip;
docker restart kb ## 修改完配置文件后需要重啟一下kibana容器,使配置生效;
/app/kibana ##7.x默認訪問路徑