elasticsearch 命令
来源:互联网 发布:iphone投影到mac 编辑:程序博客网 时间:2024/06/11 03:56
elasticsearch 命令
elasticsearch 标准命令遵循Rest风格,使用 curl 方式调用
elasticsearch 命令分运维命令,索引管理命令两类。
- _cat
- _nodes
- _cluster
- index
_cat 接口查询elasticsearch集群状态的接口
_cat系列提供了一系列。你可以通过执行
curl -XGET localhost:9200/_cat
获取所有_cat系列的操作
/_cat/allocation/_cat/shards/_cat/shards/{index}/_cat/master/_cat/nodes/_cat/indices/_cat/indices/{index}/_cat/segments/_cat/segments/{index}/_cat/count/_cat/count/{index}/_cat/recovery/_cat/recovery/{index}/_cat/health/_cat/pending_tasks/_cat/aliases/_cat/aliases/{alias}/_cat/thread_pool/_cat/plugins/_cat/fielddata/_cat/fielddata/{fields}
你也可以后面加一个v,让输出内容表格显示表头,举例
_nodes 查询节点的状态
curl -XGET ‘http://localhost:9200/_nodes/stats?pretty=true’curl -XGET ‘http://localhost:9200/_nodes/192.168.1.2/stats?pretty=true’curl -XGET ‘http://localhost:9200/_nodes/process’curl -XGET ‘http://localhost:9200/_nodes/_all/process’curl -XGET ‘http://localhost:9200/_nodes/192.168.1.2,192.168.1.3/jvm,process’curl -XGET ‘http://localhost:9200/_nodes/192.168.1.2,192.168.1.3/info/jvm,process’curl -XGET ‘http://localhost:9200/_nodes/192.168.1.2,192.168.1.3/_allcurl -XGET ‘http://localhost:9200/_nodes/hot_threads
_cluster
1、查询设置集群状态
curl -XGET localhost:9200/_cluster/health?pretty=truepretty=true表示格式化输出level=indices 表示显示索引状态level=shards 表示显示分片信息
2、显示集群系统信息,包括CPU JVM等等
curl -XGET localhost:9200/_cluster/stats?pretty=true
3、集群的详细信息。包括节点、分片等。
curl -XGET localhost:9200/_cluster/state?pretty=true
4、获取集群堆积的任务
curl -XGET localhost:9200/_cluster/pending_tasks?pretty=true
5、修改集群配置
举例:
curl -XPUT localhost:9200/_cluster/settings -d '{ "persistent" : { "discovery.zen.minimum_master_nodes" : 2 }}'transient 表示临时的,persistent表示永久的
6、对shard的手动控制,
curl -XPOST ‘localhost:9200/_cluster/reroute’ -d ‘xxxxxx’
参考http://zhaoyanblog.com/archives/687.html
7、关闭节点
关闭指定192.168.1.1节点
curl -XPOST ‘http://192.168.1.1:9200/_cluster/nodes/_local/_shutdown’curl -XPOST ‘http://localhost:9200/_cluster/nodes/192.168.1.1/_shutdown’关闭主节点curl -XPOST ‘http://localhost:9200/_cluster/nodes/_master/_shutdown’关闭整个集群$ curl -XPOST ‘http://localhost:9200/_shutdown?delay=10s’$ curl -XPOST ‘http://localhost:9200/_cluster/nodes/_shutdown’$ curl -XPOST ‘http://localhost:9200/_cluster/nodes/_all/_shutdown’
delay=10s表示延迟10秒关闭
_index 索引操作
1、获取索引
curl -XGET ‘http://localhost:9200/{index}/{type}/{id}’
2、索引数据
curl -XPOST ‘http://localhost:9200/{index}/{type}/{id}’ -d'{“a”:”avalue”,”b”:”bvalue”}’
3、删除索引
curl -XDELETE ‘http://localhost:9200/{index}/{type}/{id}’
4、设置mapping
curl -XPUT http://localhost:9200/{index}/{type}/_mapping -d '{ "{type}" : { "properties" : { "date" : { "type" : "long" }, "name" : { "type" : "string", "index" : "not_analyzed" }, "status" : { "type" : "integer" }, "type" : { "type" : "integer" } } }}'
5、获取mapping
curl -XGET http://localhost:9200/{index}/{type}/_mapping
6、搜索
curl -XGET 'http://localhost:9200/{index}/{type}/_search' -d '{ "query" : { "term" : { "user" : "kimchy" } //查所有 "match_all": {} }, "sort" : [{ "age" : {"order" : "asc"}},{ "name" : "desc" } ], "from":0, "size":100}curl -XGET 'http://localhost:9200/{index}/{type}/_search' -d '{ "filter": {"and":{"filters":[{"term":{"age":"123"}},{"term":{"name":"张三"}}]}, "sort" : [{ "age" : {"order" : "asc"}},{ "name" : "desc" } ], "from":0, "size":100}
除非注明,赵岩的博客文章均为原创,转载请以链接形式标明本文地址
本文地址:http://zhaoyanblog.com/archives/732.html
0 0
- elasticsearch命令
- elasticsearch 命令
- ElasticSearch服务器操作命令
- Elasticsearch操作命令
- elasticSearch基本命令学习
- elasticsearch中的curl命令
- elasticsearch相关命令笔记
- elasticsearch 操作 index 命令
- curl命令操作elasticsearch
- elasticsearch命令大全
- elasticsearch命令简单介绍
- 使用curl命令操作elasticsearch
- 使用curl命令操作elasticsearch
- ElasticSearch关闭重启命令
- 使用curl命令操作elasticsearch
- ElasticSearch关闭重启命令
- elasticsearch命令curl(学习笔记)
- Elasticsearch常用操作命令大全
- React语法基础之JSX
- 用户登陆记住密码
- Atitit 常用sdk 模块 组织架构切分 规范与范例attilax总结
- 虚拟机性能监控与故障处理工具の6个命令工具
- ListView初级入门
- elasticsearch 命令
- java高并发锁的3种实现
- matlab学习笔记(一)
- 一个技术出身的市场人的小访谈
- node---fs模块
- 表的数据删除
- 算数和逻辑操作
- “欺骗JVM”
- NPM依赖包版本号~和^的区别及最佳实践