【ES】探索集群 <二>
来源:互联网 发布:顾城之死 知乎 编辑:程序博客网 时间:2024/05/16 12:55
来自于 ElasticSearch 参考的 Getting started 章节
1. 集群的健康
★ 使用 _cat API 查看集群状态,如下的命令
curl "http://localhost:9200/_cat/health?v" // v 会显示出各个字段值代表的含义
返回的信息 大致如下 :
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent1472117090 17:24:50 elasticsearch green 1 1 0 0 0 0 0 0 - 100.0%
★★ 集群的健康状态可以用三个不同的颜色表示,分别为:
· green :绿色 代表一切正常
· yellow :黄色 代表所有的数据可用,但是 还有一些数据没有拷贝 ,此时集群完全可以工作
· red :红色 代表一些数据不可用 ,此时 集群仍然可用,只是会丢失 部分数据
★ 查看 节点 信息:
curl "http://localhost:9200/_cat/nodes?v"
响应如下:
host ip heap.percent ram.percent load node.role master name127.0.0.1 127.0.0.1 6 81 -1.00 d * Madelyne Pryor
2. 列出所有索引 (indices)
命令如下 :
curl "http://localhost:9200/_cat/indices?v"
响应如下:
health status index pri rep docs.count docs.deleted store.size pri.store.size //此时集群中还未添加 索引,所以为空
3. 创建索引
使用 PUT 创建名为 customer 索引
curl -XPUT "http://localhost:9200/customer?pretty" // pretty 输出优美的 json 格式
响应 如下:
{ "acknowledged":true}
此时查看所有的索引效果如下:
health status index pri rep docs.count docs.deleted store.size pri.store.sizeyellow open customer 5 1 0 0 795b 795b
4. 索引文档 和 查询文档
★ 索引文档:使用 PUT ,同时增加 type 为 external , id 为 1 (这里使用 chrome 的 sense 插件 发送 ES 请求,可以很好的感知 json 数据)
如果索引文档时 ,该索引并不存在 ,则会自动创建该索引 。
将指定的文档索引到 index 为 customer , type 为 external ,id 为 1 中
★ 查询文档 : 使用 GET :
curl -XGET "http://localhost:9200/customer/external/1?pretty" // X 必须都要大写
响应 :
{ "_index" : "customer", "_type" : "external", "_id" : "1", "_version" : 1, "found" : true, "_source" : { "name" : "xiaoming" }}
5. 删除 索引
使用 DELETE :
curl -XDELETE "http://localhost:9200/customer?pretty"
响应 :
{ "acknowledged" : true}
综上,可以总结出 使用 curl 获取 ES 数据 的 一般形式 如下 :
curl -X<REST Verb> <Node>:<Port>/<Index>/<Type>/<ID>
linux 中 用单引号 ,windows 中 用双引号
curl -X<VERB> '<PROTOCOL>://<HOST>:<PORT>/<PATH>?<QUERY_STRING>' -d '<BODY>'
VERBHttp请求方法: GET, POST, PUT, HEAD, or DELETE.PROTOCOLEither http or https (if you have an https proxy in front of Elasticsearch.)HOSTThe hostname of any node in your Elasticsearch cluster, or localhost for a node on your local machine.PORTThe port running the Elasticsearch HTTP service, which defaults to 9200.PATHAPI Endpoint (for example _count will return the number of documents in the cluster). Path may contain multiple components, such as _cluster/stats or _nodes/stats/jvmQUERY_STRINGAny optional query-string parameters (for example ?pretty will pretty-print the JSON response to make it easier to read.)BODYA JSON-encoded request body (if the request needs one.)
- 【ES】探索集群 <二>
- es 二 ---- elasticsearch多节点集群不成功
- Elasticsearch学习笔记之二(ES集群)
- 【ES】探索数据 <四>
- es分布式集群初探
- es-ehcache分布式集群
- es 集群配置文件示例
- ES集群读写分离
- ES集群安装配置
- ES 5.3 集群安装
- es集群设计
- es集群概述
- ES集群安重启节点
- ES集群搭建
- ES集群和分片
- ES集群监控总结
- ES的zen探索方法
- elasticsearch es分布式集群初探
- Unity Shader 常用函数列表
- MySql索引算法原理解析(通俗易懂,只讲B-tree)
- java+mysql中文乱码
- Floyd求所有端点的最短路径
- awk出现次数最多的行进行统计
- 【ES】探索集群 <二>
- Java:类与继承
- 在hive中实现之定义函数UDF
- 个人工作经验积累——SPI
- js验证只能输入字母,数字或字母数字组合正则表达式
- ToStringBuilder学习(一):常用方法介绍
- View的事件分发机制
- poj1408 Fishnet
- Java基本类型和引用类型