es相关命令记录

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 :确定更好的副本位置被标定使用,导致现有的副本分配被取消,出现未分配

#清除指定索引只读
curl -X PUT “127.0.0.1:9200/identity-vehicle-ln-202304/_settings?pretty” -H ‘Content-Type: application/json’ -d’
{
“index.blocks.read_only_allow_delete”: null
}’
#清除全部只读索引
curl -XPUT -H “Content-Type: application/json” http://127.0.0.1:9200/_all/_settings -d ‘{
“index.blocks.read_only_allow_delete”: null
}’

#设置每个分片有1个副本
curl -X PUT “127.0.0.1:9200/identity-vehicle-ln-202306/_settings?pretty” -H ‘Content-Type: application/json’ -d’
{
“settings”: {
“index.number_of_replicas”: “1”
}
}’

“index.unassigned.node_left.delayed_timeout”: “30s”

#es更新数据
curl -X POST -H ‘Content-Type:application/json’ -d ‘{
“doc”: {
“plateNo”: “黑AA644警”
}
}’ http://127.0.0.1:9200/identity-vehicle-ln-202301/_update/5f74ba04194c4e425f8850e3c43fb6b1

#范围查询
curl -X POST -H ‘Content-Type:application/json’ -d ‘{
“query”: {
“range”: {
“createTime”: {
“gt”: 1677919464000,
“lt”: 1678005864000
}
}
}
}’ http://127.0.0.1:9200/identity-vehicle-ln-202306/_search

#精确匹配
curl -X POST -H ‘Content-Type:application/json’ -d ‘{
“query”: {
“match”: {
“imgId”: “NECAM-20B-LS20030250_2023062000000339_cs”
}
}
}’ http://127.0.0.1:9200/identity-vehicle-ln-202306/_search

#初始化指定分片
curl -X POST -H ‘Content-Type:application/json’ -d ‘{
“commands”: [
{
“allocate_stale_primary”: {
“index”: “identity-vehicle-ln-202306”,
“shard”: 14,
“node”: “es-node3”,
“accept_data_loss”: true
}
}
]
}’ http://127.0.0.1:9200/_cluster/reroute?pretty

#删除指定数据
curl -X DELETE 127.0.0.1:9200/identity-vehicle-ln-202212/_doc/9a579175e0f9550be56626bb017311ab
#查看集群节点
curl 127.0.0.1:9200/_cat/indices?v
#查看分片恢复情况
curl 127.0.0.1:9200/_cat/recovery
#查看集群配置
curl 127.0.0.1:9200/_settings/_all
#搜索指定索引的全部数据
curl 127.0.0.1:9200/identity-vehicle-ln-202306/_search

#查看指定文档id
curl 127.0.0.1:9200/identity-vehicle-ln-202306/_doc/2a11941f7ab3bf62be07187bc36d3b23

#返回集群不健康的原因
curl -XGET localhost:9200/_cat/shards?h=index,shard,prirep,state,unassigned.reason | grep UNASSIGNED
#查看节点情况
curl -XGET localhost:9200/_cat/nodes?v
#返回集群不健康的详细原因
curl -XGET localhost:9200/_cluster/allocation/explain?pretty

#查看集群设置
curl 127.0.0.1:9200/_cluster/settings
#查看集群状态
curl 127.0.0.1:9200/_cluster/health?filter_path=status,*_shards

all - (默认值)允许为所有类型的分片分配分片。
primaries - 仅允许分配主分片的分片。
new_primaries - 仅允许为新索引的主分片分配分片。
none - 任何索引都不允许任何类型的分片。
curl -XPUT ‘localhost:9200/_cluster/settings’-d’{ “transient”:{“cluster.routing.allocation.enable” : “all”}}’

curl -XGET 127.0.0.1:9200/_cluster/allocation/explain?filter_path=index,node_allocation_decisions.node_name,node_allocation_decisions.deciders.*{
“index”: “identity-vehicle-ln-202306”,
“shard”: 0,
“primary”: false}

#关闭集群自动均衡
curl -XPUT “http://172.170.200.15:9200/_cluster/settings?pretty” -H ‘Content-Type:application/json’ -d ‘{“persistent” :{“cluster.routing.rebalance.enable”: “none”},
“transient” :{“cluster.routing.rebalance.enable”: “none”}}’

参数取值:
all:默认选项,允许所有种类的分片的分片平衡
primaries:仅允许主分片的分片平衡。
replicas:仅允许副本分片的分片平衡。
none:任何索引都不允许任何形式的分片平衡。

#检查集群自动均衡是否关闭
curl -XGET “http://172.170.200.15:9200/_cluster/settings?pretty”

#禁止集群写入
curl -XPUT “http://172.170.200.15:9200/_cluster/settings?pretty” -H ‘Content-Type:application/json’ -d ‘{“persistent” :{“cluster.blocks.read_only” : “true”},“transient” :{“cluster.blocks.read_only” : “true”}}’

#检查集群写入是否已经关闭
curl -XGET “http://172.170.200.15:9200/_cluster/settings?pretty”

–先打开写入,再打开自动均衡
#打开集群写入
curl -XPUT “http://172.170.200.17:9200/_cluster/settings?pretty” -H ‘Content-Type:application/json’ -d ‘{“persistent” :{“cluster.blocks.read_only” : “false”}}’
curl -XPUT “http://172.170.200.17:9200/_cluster/settings?pretty” -H ‘Content-Type:application/json’ -d ‘{“transient” :{“cluster.blocks.read_only” : “false”}}’

#检查集群写入是否已经打开
curl -XGET “http://172.170.200.17:9200/_cluster/settings?pretty”

#打开集群自动均衡
curl -XPUT “http://172.170.200.17:9200/_cluster/settings?pretty” -H ‘Content-Type:application/json’ -d ‘{“persistent” :{“cluster.routing.rebalance.enable”: “all”}}’
curl -XPUT “http://172.170.200.17:9200/_cluster/settings?pretty” -H ‘Content-Type:application/json’ -d ‘{“transient” :{“cluster.routing.rebalance.enable”: “all”}}’

#检查集群自动均衡是否打开
curl -XGET “http://172.170.200.17:9200/_cluster/settings?pretty”

GET /ics-business-2022.09.25/_search
{
“query”: {
“multi_match”: {
“query”: “LB300404 车辆时运行数据”,
“fields”: [“message”]

}

},
“track_total_hits”:true
}

GET /identity-vehicle-ln-202301/_doc/5f74ba04194c4e425f8850e3c43fb6b1
GET /_cat/indices?v
GET /_cluster/settings?pretty

GET /_cat/nodes?v
GET /_cat/master?v

GET /ics-business-2022.09.25/_search
{
“query”: {
“term”: {
“event.dataset”: “ics-business”
, “message”: {
“LB300404”
}
}
}
“track_total_hits”:true
}

GET /identity-vehicle-ln-202212/_search
{
“query”: {
“terms”: {
“message”: [“LB300404”,“车辆时运行数据”]
}
},
“track_total_hits”:true
}

GET _analyze
{
“analyzer”:“standard”,
“text”:“LB300404 车辆时运行数据”
}

GET /ics-business-2022.09.25/_search
{
“query”: {
“match”: {
“message”: {
“query”: “LB200472 车辆运行时数据”,
“operator”: “and”
}
}
},
“from”: 0,
“size”: 100,
“_source”: [“message”,“event.dataset”],
“track_total_hits”: true
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值