日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

elasticsearch 常用命令

發布時間:2024/9/16 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 elasticsearch 常用命令 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

查看集群狀態:

curl -XGET 'http://localhost:9200/_cluster/health?pretty'

查看所有節點狀態:

curl -XGET -s "http://192.168.1.102:9200/_cat/nodes" curl -XGET "http:192.168.1.102:9200/_node/stats/process"

查看集群在recovery的index

GET */_recovery?active_only=true

當集群分片分配失敗后,執行:

POST _cluster/reroute?retry_failed=true

修改分片分配:

curl -XPUT 'http://192.168.1.101:9200/_cluster/settings' -H 'Content-Type: application/json' -d '{"transient":{"cluster.routing.allocation.enable": "none"}}'

Disable shard allocation.
When you shut down a node, the allocation process waits for index.unassigned.node_left.delayed_timeout (by default, one minute) before starting to replicate the shards on that node to other nodes in the cluster, which can involve a lot of I/O. Since the node is shortly going to be restarted, this I/O is unnecessary. You can avoid racing the clock by disabling allocation of replicas before shutting down the node:?

curl -X PUT "localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d' {"persistent": {"cluster.routing.allocation.enable": "none"} } '

當重啟節點時,移動分片會產生大量IO,這是沒必要的。往往在重啟節點的時候,將這個參數改為primaries。

可以是persistent 持久性的(重啟后依舊有效),也可以是 transient 臨時性的(完全重啟集群后失效)。

Allocation和Rebalancing的區別

Shard allocation is about taking unassigned shard copies and finding each of them a node to inhabit.

Rebalancing is about taking assigned shard copies and moving them to different nodes to even out the distribution of shards.

shard分配是指獲取未分配的shard副本,并找到它們中的每一個要駐留的節點。

重新平衡是指獲取分配的碎片副本并將其移動到不同的節點,以平衡碎片的分布。

cluster.routing.allocation.cluster_concurrent_rebalance

允許同時多少分片平衡數據,默認值為2,當集群狀態為green時,當一個節點加入進來,會執行此操作。

cluster.routing.allocation.node_concurrent_recoveries

從yellow到green的過程中,允許多少個分片平衡

創建index:

curl -XPUT 'http://192.168.1.101:9200/mobile_area' -H 'Content-Type: application/json' -d '"mappings":{"type":{"properties":{"name":{"type": "keyword"},"age":{"type": "keyword"}}}} '

bulk命令

curl -X POST "localhost:9200/_bulk" -H 'Content-Type: application/json' -d' { "index" : { "_index" : "test", "_id" : "1" } } { "field1" : "value1" } { "delete" : { "_index" : "test", "_id" : "2" } } { "create" : { "_index" : "test", "_id" : "3" } } { "field1" : "value3" } { "update" : {"_id" : "1", "_index" : "test"} } { "doc" : {"field2" : "value2"} } ' curl -X POST "http://192.168.159.128:9200/index_name/_index_type/_bulk" -H 'Content-type: application/json' --data-binary @file_name

文件內容:

{"index":{}} {"name": "tom", "age": "12"} {"index":{}} {"name": "jerry", "age": "15"}

?使用kibana進行bulk:

POST bzhan/type/_bulk { "index" : {}} {"name": "jack", "age": "12"} { "index" : {}} {"name": "rose", "age": "23"}

修改副本數量

PUT _settings {"number_of_replicas": 3 }

查看索引列表

curl -XGET 'http://192.168.171.39:9200/_cat/indices?v'

默認情況下,會把所有的列都顯示出來:

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

如果只想要列名:

curl -XGET 'http://192.168.171.39:9200/_cat/indices?v&h=index'

這樣就只把列名獲取出來了。

總結

以上是生活随笔為你收集整理的elasticsearch 常用命令的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。