es 常用命令總結(jié)

  1. 查看每個節(jié)點的磁盤使用情況
    "/_cat/allocation/{node_id}?v"

  2. 查看fielddata數(shù)據(jù)
    "/_cat/fielddata", "/_cat/fielddata/{fields}"

fielddata是全加載進入內(nèi)存,主要用處在排序和聚合字段
fielddata與doc values區(qū)別:
4.1 相同點

都要創(chuàng)建正排索引,數(shù)據(jù)結(jié)構(gòu)類似于列式存儲

都是為了可以聚合,排序之類的操作

4.2 不同點

存儲索引數(shù)據(jù)的方式不一樣:

fielddata: 內(nèi)存存儲;doc_values: OS Cache+磁盤存儲

對應的字段類型不一樣

fielddata: 對應的字段類型是text; doc_values:對應的字段類型是keyword

針對的類型,也不一樣

field_data主要針對的是分詞字段;doc_values針對大是不分詞字段

是否開啟

fielddata默認不開啟;doc_values默認是開啟

  1. 查看索引的狀態(tài)
    "/_cat/indices/index_name?format=json"
    4.查看索引分片恢復的詳細消息
    "/{index}/_recovery?detailed=true"

  2. 查看master節(jié)點
    "/_cat/master"
    6.查看es返回錯誤的全部堆棧
    error_trace
    /company_meta111/_settings?error_trace=true

7 bm2.5文檔 The Probabilistic Relevance Framework: BM25 and Beyond.
https://blog.mimacom.com/bm25-got/

  1. 線程池相關命令
    查看當前線程池設置大?。?_nodes/thread_pool
    查看當前使用線程池情況:/_cat/thread_pool/search?format=json
    查看指定節(jié)點熱線程情況:/_nodes/<node_id>/hot_threads
    9.查看某個分片分配原因
    /_cluster/allocation/explain
    {
    "index": "company_meta_v3",
    "shard": 6,
    "primary": false
    }

  2. es升級到7.x后,在_search后面加上rest_total_hits_as_int=true參數(shù),可以把totals 在7.x的json改成成6.x的整型

  3. 關閉磁盤容量檢測
    curl -XPUT ip:9200/_cluster/settings -d '{ "transient" : { "cluster.routing.allocation.disk.threshold_enabled" : false } }'

  4. 自定義es similarty
    https://github.com/sdauletau/elasticsearch-simple-similarity
    https://github.com/stefansavev/elasticsearch-custom-similarity-example/blob/master/src/main/java/stefansavev/esplugins/OverlapSimilarityProvider.java

  5. 查看當前正在運行的命令

查詢正在運行的task

GET _tasks?detailed=true&actions=*indices:data/read/search

取消任務

POST _tasks/CdoilmnzRVyllc0PbRbB2w:7280/_cancel

  1. 查看索引的段內(nèi)存
    /_cat/segments/company_risk_info?v&h=shard,segment,size,size.segment&format=json
  2. 拷貝一個分片從一個節(jié)點到另外一個節(jié)點:POST /_cluster/reroute
    {
    "commands" : [
    {
    "allocate_replica" : {
    "index" : "test", "shard" : 1,
    "node" : "node3"
    }
    }
    ]
    }

16 查看節(jié)點所占內(nèi)存
/_cat/nodes?v&format=json&h=ip,port,v,m,fdp,mc,mcs,sc,sm,qcm,fm,im,siwm,svmm

  1. dump es堆內(nèi)存

獲取二進制的head dump文件 jmap -dump:format=b,file=/tmp/es_heap.bin <pid> 其中pid是ES JAVA進程的進程號。

  1. 添加慢日志

PUT /索引名稱/_settings
{
"index.search.slowlog.threshold.query.warn": "1s",
"index.search.slowlog.threshold.query.info": "500ms",
"index.search.slowlog.threshold.query.debug": "300ms",
"index.search.slowlog.threshold.query.trace": "100ms",
"index.search.slowlog.threshold.fetch.warn": "1s",
"index.search.slowlog.threshold.fetch.info": "500ms",
"index.search.slowlog.threshold.fetch.debug": "300ms",
"index.search.slowlog.threshold.fetch.trace": "100ms",
"index.search.slowlog.level": "info"
}

  1. git 修改commit信息
    git commit --amend

  2. 統(tǒng)計指定文件的總大小
    du -sk * | grep vector | awk '{sum+=$1} END {print sum}'

  3. elasticsearch jdk支持版本圖
    https://www.elastic.co/cn/support/matrix#matrix_jvm

  4. 查看各文件大小
    ls -alht

  5. arthas以utf-8編碼啟動
    java -Dfile.encoding=UTF-8 -jar arthas-boot.jar

  6. 查看節(jié)點內(nèi)存
    /_cat/nodes?format=json&v&h=id,ip,port,v,master,name,heap.current,heap.percent,heap.max,ram.current,ram.percent,ram.max,fielddata.memory_size,fielddata.evictions,query_cache.memory_size,query_cache.evictions,request_cache.memory_size,request_cache.evictions,request_cache.hit_count,request_cache.miss_count

?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容