1. 程式人生 > >ES常用命令-------------隨筆

ES常用命令-------------隨筆

【shrink】
要求如下
1首先,它使用與源索引相同的定義建立一個新的目標索引,但是比原索引的主碎片少。
2然後將源索引中的硬連結段與目標索引關聯起來。(如果檔案系統不支援硬連結,那麼所有的片段都被複制到新的索引中,這是一個更耗時的過程。)
3最後,它恢復了目標索引,就像它是一個剛剛重新開啟的封閉索引。


***為了縮小索引,索引必須被標記為只讀,索引中每個shard的(主或副本)副本必須遷移到相同的節點並具有健康綠色

強制將每個shard的副本遷移到具有名稱收縮的節點。【"index.routing.allocation.require._name": "node-1"】
將索引設定成 只讀模式【"index.blocks.write"
: true】 【不是隻讀模式,會報錯index test2 must be read-only to shrink index. use \"index.blocks.write=true\""】 curl -XPUT '172.16.2.99:9200/my_source_index/_settings?pretty' -H 'Content-Type: application/json' -d' { "settings": { "index.routing.allocation.require._name": "node-1", "index.blocks.write": true } } '
curl -XPOST '172.16.2.99:9200/test2/_shrink/test1?pretty' -H 'Content-Type: application/json' -d' { "settings": { "index.number_of_replicas": 0, "index.number_of_shards": 1, "index.codec": "best_compression" }, "aliases": { "my_search_indices": {} } } 給索引起的別名 "aliases": { "my_search_indices": {} } curl -XPOST '
172.16.2.99:9200/test2/_settings?pretty' -H 'Content-Type: application/json' -d' { "settings": {}, "aliases": { "my_search_indices": {} } }' 【delete index】 curl -XDELETE '172.16.2.99:9200/test1?pretty' 【delete by query】 curl -XPOST '172.16.2.99:9200/bank/_delete_by_query?pretty' -H 'Content-Type: application/json' -d' { "query": { "match_all": { } } } ' curl -XPOST 'localhost:9200/twitter,blog/tweet,post/_delete_by_query?pretty' -H 'Content-Type: application/json' -d' { "query": { "match_all": {} } } ' curl -XPOST 'localhost:9200/twitter,blog/tweet,post/_delete_by_query?pretty' -H 'Content-Type: application/json' -d' { "query": { "match_all": {} } } ' curl -XPOST 'localhost:9200/twitter/_delete_by_query?scroll_size=5000&pretty' -H 'Content-Type: application/json' -d' { "query": { "term": { "user": "kimchy" } } } ' 【cat】 curl -XGET '172.16.2.99:9200/_cat/indices/twi*?v&s=index&pretty' Which index has the largest number of documents? curl -XGET 'localhost:9200/_cat/indices?v&s=docs.count:desc&pretty' How much memory is used per index? curl -XGET 'localhost:9200/_cat/indices?v&h=i,tm&s=tm:desc&pretty' How many merge operations have the shards for the twitter completed? curl -XGET 'localhost:9200/_cat/indices/twitter?pri&v&h=health,index,pri,rep,docs.count,mt&pretty' 【cat recovery】 curl -XGET '172.16.2.99:9200/_cat/recovery?v' ------------------------------------ [[email protected] bin]# curl -XGET '172.16.2.99:9200/_cat/recovery?v' index shard time type stage source_host source_node target_host target_node repository snapshot files files_recovered files_percent files_total bytes bytes_recovered bytes_percent bytes_total translog_ops translog_ops_recovered translog_ops_percent test2 0 295ms existing_store done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 100.0% 10 0 0 100.0% 73797 0 0 100.0% test2 1 394ms existing_store done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 100.0% 10 0 0 100.0% 79051 0 0 100.0% test2 2 326ms existing_store done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 100.0% 13 0 0 100.0% 81701 0 0 100.0% .kibana 0 268ms existing_store done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 100.0% 7 0 0 100.0% 7817 0 0 100.0% filebeat-2017.06.22 0 176ms empty_store done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0% filebeat-2017.06.22 1 217ms empty_store done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0% filebeat-2017.06.22 2 209ms empty_store done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0% filebeat-2017.06.22 3 149ms empty_store done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0% filebeat-2017.06.22 4 141ms empty_store done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 0.0% 0 0 0 0.0% 0 0 0 100.0% test1 0 300ms local_shards done n/a n/a 172.16.2.99 node-1 n/a n/a 0 0 100.0% 33 0 0 100.0% 235792 -1 0 ------------------------------------ curl -XGET '172.16.2.99:9200/_cat/recovery?v&h=i,s,t,ty,st,shost,thost,f,fp,b,bp' ------------------------------------ [[email protected] bin]# curl -XGET '172.16.2.99:9200/_cat/recovery?v&h=i,s,t,ty,st,shost,thost,f,fp,b,bp' i s t ty st shost thost f fp b bp test2 0 295ms existing_store done n/a 172.16.2.99 0 100.0% 0 100.0% test2 1 394ms existing_store done n/a 172.16.2.99 0 100.0% 0 100.0% test2 2 326ms existing_store done n/a 172.16.2.99 0 100.0% 0 100.0% .kibana 0 268ms existing_store done n/a 172.16.2.99 0 100.0% 0 100.0% filebeat-2017.06.22 0 176ms empty_store done n/a 172.16.2.99 0 0.0% 0 0.0% filebeat-2017.06.22 1 217ms empty_store done n/a 172.16.2.99 0 0.0% 0 0.0% filebeat-2017.06.22 2 209ms empty_store done n/a 172.16.2.99 0 0.0% 0 0.0% filebeat-2017.06.22 3 149ms empty_store done n/a 172.16.2.99 0 0.0% 0 0.0% filebeat-2017.06.22 4 141ms empty_store done n/a 172.16.2.99 0 0.0% 0 0.0% test1 0 300ms local_shards done n/a 172.16.2.99 0 100.0% 0 100.0% ------------------------------------ 【aliases】 curl -XPOST '172.16.2.99:9200/_aliases?pretty' -H 'Content-Type: application/json' -d' { "actions" : [ { "add" : { "index" : "test3", "alias" : "my_search_indices" } } ] } ' curl -XPOST '172.16.2.99:9200/_aliases?pretty' -H 'Content-Type: application/json' -d' { "actions" : [ { "remove" : { "index" : "test3", "alias" : "my_search_indices" } } ] } ' 【reindex】 curl -XPOST '172.16.2.99:9200/_reindex?pretty' -H 'Content-Type: application/json' -d' { "source": { "index": "test2" }, "dest": { "index": "test3" } } ' ---------------------------------- //另一個叢集中copy 【【elasticsearch.yaml 中將遠端叢集新增到白名單】】 reindex.remote.whitelist: 172.16.2.97:9200 curl -XPOST '172.16.2.99:9200/_reindex?pretty' -H 'Content-Type: application/json' -d' { "source": { "remote": { "host": "http://172.16.2.97:9200" }, "index": "bank" }, "dest": { "index": "bank" } } ' curl -XPOST '172.16.2.99:9200/_reindex?pretty' -H 'Content-Type: application/json' -d' { "source": { "remote": { "host": "http://172.16.2.97:9200" }, "index": "bank", "size": 10 }, "dest": { "index": "bank" } } ' ------------------------------ 可以rename field curl -XPOST 'localhost:9200/test/test/1?refresh&pretty' -H 'Content-Type: application/json' -d' { "text": "words words", "flag": "foo" } ' curl -XPOST 'localhost:9200/_reindex?pretty' -H 'Content-Type: application/json' -d' { "source": { "index": "test" }, "dest": { "index": "test2" }, "script": { "inline": "ctx._source.tag = ctx._source.remove(\"flag\")" } } ' curl -XGET 'localhost:9200/test2/test/1?pretty' { "found": true, "_id": "1", "_index": "test2", "_type": "test", "_version": 1, "_source": { "text": "words words", "tag": "foo" } } 【open/close index】 curl -XPOST '172.16.2.99:9200/my_index/_close?pretty' curl -XPOST '172.16.2.99:9200/my_index/_open?pretty' 【update indice settings】 curl -XPUT '172.16.2.97:9200/bank/_settings' -d ' { "index" : { "number_of_replicas" : 0 } }' 【task】 curl -XGET 'localhost:9200/_tasks?detailed=true&actions=*reindex&pretty' 【load data】 curl -XPOST '172.16.2.97:9200/bank/account/_bulk?pretty&refresh' --data-binary "@accounts.json" curl 'localhost:9200/_cat/indices?v' 【mapping】 curl -XPUT '172.16.2.99:9200/my_index?pretty' -H 'Content-Type: application/json' -d' { "mappings": { "user": { "_all": { "enabled": false }, "properties": { "title": { "type": "text" }, "name": { "type": "text" }, "age": { "type": "integer" } } }, "blogpost": { "_all": { "enabled": false }, "properties": { "title": { "type": "text" }, "body": { "type": "text" }, "user_id": { "type": "keyword" }, "created": { "type": "date", "format": "strict_date_optional_time||epoch_millis" } } } } } '

相關推薦

ES常用命令-------------隨筆

【shrink】 要求如下 1首先,它使用與源索引相同的定義建立一個新的目標索引,但是比原索引的主碎片少。 2然後將源索引中的硬連結段與目標索引關聯起來。(如果檔案系統不支援硬連結,那麼所有的片段都被複制到新的索引中,這是一個更耗時的過程。) 3最後,它恢復了目

ES常用命令

一個 update prim 降序排序 highlight 想要 rms 插入 名稱 1.快速檢查集群的健康狀況 GET /_cat/health?v Green:每個索引的primary shard和replica shard都是active狀態 yell

linux常用命令-隨筆

-type admin 查看 puts min log ftp tmp pmod 文件和目錄 cd /home 進入 ‘/ home‘ 目錄‘ cd .. 返回上一級目錄 cd ../.. 返回上兩級目錄 cd 進入個人的主目錄 cd ~user1 進入個人的主目錄 cd

Linux系統常用命令--LInix系統隨筆(四)

不完全 apropos 軟鏈接文件 chown 技術分享 ctrl+d log 常用選項 exec 前言:雖然一直在用linux但是一直沒有系統的學習過,趁著暑假花了幾天看著鳥哥的書學習了一下。下面是我記錄的一些筆記,本人屬於入門的小白所以難免有不足之處,還望發現的表哥

編程隨筆(知識收納)-git常用命令示例

reset 圖形 delete ins htm git常用命令 ads 顯示 leaves 1. 直接提交文件   對於git 在本地版本庫中已有的文件,可以不用執行“git add”操作,直接將工作區的文件提交到版本庫(非index區) $ gi

oozie 常用命令

3.3 ued submit operation -s clean up sim killed require 1.驗證wokflow.xmloozie validate /appcom/apps/hduser0401/mbl_webtrends/workflow.xml 

Linux下常用命令之sed學習總結

linux sed sed命令 正則表達式 sed總結 Sed功能說明:Sed是linux下一個強大的文本文件處理工具,通過對文件增加、刪除、查找、查詢操作,配合正則表達式以實現工作中的各種需求。同時也是一名運維人員必須掌握的核心技能。---------------------------

【長期更新】Ubuntu常用命令備忘錄

err bsp ubuntu lib ubunt clas apt 問題 error Error Could not get lock /var/lib/dpkg/lock 出現這個問題可能是有另外一個程序正在運行,導致資源被鎖不可用。而導致資源被鎖的原因可能是上次運行安

mysql 常用命令

mysql命令說明BEGIN COMMITmysql在客戶端執行更新、刪除開啟一個事務:BEGIN;UPDATE driver SET phone=‘11601620000‘ WHERE id=1;--ROLLBACK;COMMIT;DATE_FORMAT%Y-%m-%d %H-%iIFNULL(price,

Linux的常用命令

linux的常用命令 lofout 退出登錄 mount 查看系統當中已經掛載的設備 mount -a 依據配置文件/etc/fstab的內容,自動掛載 who 查看系統登錄了哪些用戶(能看到用戶名,登錄終端,登陸時間登錄IP) w 查看系統登錄了哪些用戶(跟who一樣,但是還能

【Mysql】常用命令

flush mysq tmp pri nec 清除 int 用戶 創建 登錄mysql -uroot -p 查看有哪些數據庫show databases; 創建一個普通用戶 sa ,密碼是 some_passCREATE USER [email protecte

Linux GCC常用命令

靜態加載 配置文件 情況 窗口 連接器 執行 二進制 c 語言 標準輸入輸出 Linux GCC常用命令 1簡介 2簡單編譯 2.1預處理 2.2編譯為匯編代碼(Compilation) 2.3匯編(Assembly) 2.4連接(Linking) 3

Docker常用命令詳解

nbsp 詳解 .cn 本地 test 並且 www 更多 top docker ps 查看當前正在運行的容器 docker ps -a 查看所有容器的狀態 docker start/stop id/name 啟動/停止某個容器 docker attach id 進

Linux常用命令

log rep 移動 文件權限 查看 his 問題 文件 學習 以下是本人在工作中常用到的Linux命令,記錄下來,方便日常工作學習查用翻閱。 Git管理代碼 【系統操作】 cd 進入目錄 cd ~ 回到根目錄 ls 查看當前目錄下的文件 less 查看某個文件內

Linux常用命令總結

bashrc 命令 配置環境 bit stat 用戶權限 復制 rtu one Linux文件的目錄結構:樹狀結構,/為最高的根目錄 root:root用戶的個人文件夾(家目錄) bin:存放多數用戶可用的命令 boot:存放啟動文件和

DOS常用命令集錦

dos1 復制文件夾(目錄樹): 例1: xcopy dir1 dir2 /E [/I] dir2已存在的情況下,會把dir1目錄裏的所有文件子目錄復制到dir2目錄中, dir2不存在的情況下,會有提示詢問你dir2是文件呢?還是目錄呢?手動選擇目錄選項自動創建d

npm常用命令

全局環境 cache 寫入 -m 指定 .json 其中 body 依賴 npm install xxx 安裝模塊 npm install xxx -g 將模塊安裝到全局環境中 參考http://goddyzhao.tumblr.com/post/9835631010

Git使用:安裝,使用及常用命令整理

reset short 配置文件 res 命名 nbsp class 名詞 如果 對於程序猿而言,git是最常接觸的工具之一,因此需要熟練快速掌握其技巧。 git安裝: windwos: 【原創】Windows平臺下Git的安裝與配置 Ubuntu:git與github在

Linux運維常用命令

second prev tin -html root repl rep amp pan propos word 顯示和word相關的命令 which command 顯示命令的完整路徑名 time command 計算命令運行的時間 time cat 開始計時. Ctr

[Linux]-Linux常用命令之文件解壓

壓縮 com nbsp linux常用命令 inux 不同 gunzip gzip all 不壓縮方式壓縮的文件需要不同的命令來解壓縮,下面是Linux的各種文件解壓命令。 對於.tar結尾的文件: tar -xf 對於.gz結尾的文件 : gzip -d all.