# Cluster Health
原文链接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-health.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/cluster-health.html)
译文链接 : [http://www.apache.wiki/display/Elasticsearch/Cluster+Health](http://www.apache.wiki/display/Elasticsearch/Cluster+Health)
贡献者 : [那伊抹微笑](/display/~wangyangting)
**cluster health**(集群健康)**API** 可以获取一个集群健康的简单状态。例如,在一个单节点的集群上,存在一个有 **5** 个分片和 **1** 个副本的索引,如下操作 :
```
curl -XGET 'localhost:9200/_cluster/health?pretty'
```
响应如下 :
```
{
"cluster_name" : "testcluster",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 5,
"active_shards" : 5,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 5,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 50.0
}
```
该 **API** 也可以针对一个或多个索引执行请求以获得指定索引的健康状态 :
```
curl -XGET 'localhost:9200/_cluster/health/test1,test2?pretty'
```
集群健康的状态是 : **green**,**yellow** 或 **red**。从分片的角度来说,**red** 状态的索引表示集群中指定的分片没有分配,**yellow** 意味着主分片已经分配成功但是副本还没有分配,**green** 意味着所有的分片已经分配成功。索引级别的状态由最差的分片状态所控制。集群状态由最差的索引状态所控制。
该 **API** 其中的一个好处是有等到直到集群达到了某个标记的健康级别的阀值的能力。例如,为了集群达到 **yellow** 级别下面将等待 **50** 秒(如果在 **50** 秒之前达到了 **green** 或 **yellow** 状态,它将在这时候返回):
```
curl -XGET 'localhost:9200/_cluster/health?wait_for_status=yellow&timeout=50s&pretty'
```
## Request Parameters
该集群 **API** 接受下列的请求参数 :
| 请求参数 | 描述 |
| --- | --- |
| level | Can be one of `cluster`, `indices` or `shards`. Controls the details level of the health information returned. Defaults to `cluster`. |
| wait_for_status | One of `green`, `yellow` or `red`. Will wait (until the timeout provided) until the status of the cluster changes to the one provided or better, i.e. `green` > `yellow` > `red`. By default, will not wait for any status. |
| wait_for_no_relocating_shards | A boolean value which controls whether to wait (until the timeout provided) for the cluster to have no shard relocations. Defaults to false, which means it will not wait for relocating shards. |
| wait_for_active_shards | A number controlling to how many active shards to wait for, `all` to wait for all shards in the cluster to be active, or `0` to not wait. Defaults to `0`. |
| wait_for_nodes | The request waits until the specified number `N` of nodes is available. It also accepts `>=N`, `<=N`, `>N` and `<N`. Alternatively, it is possible to use `ge(N)`, `le(N)`, `gt(N)` and `lt(N)` notation. |
| timeout | A time based parameter controlling how long to wait if one of the wait_for_XXX are provided. Defaults to `30s`. |
| local | If `true` returns the local node information and does not provide the state from master node. Default: `false`. |
下面是一个获取集群中 shards(分片)级别的集群健康的示例 :
```
curl -XGET 'localhost:9200/_cluster/health/twitter?level=shards&pretty'
```
- Getting Started(入门指南)
- Basic Concepts(基础概念)
- Installation(安装)
- Exploring Your Cluster(探索集群)
- Cluster Health(集群健康)
- List All Indices(列出所有索引)
- Create an Index(创建索引)
- Index and Query a Document(索引和查询文档)
- Delete an Index(删除索引)
- Modifying Your Data(修改数据)
- Updating Documents(更新文档)
- Deleting Documents(删除文档)
- Batch Processing(批处理)
- Exploring Your Data(探索数据)
- The Search API(搜索 API)
- Introducing the Query Language(介绍查询语言)
- Executing Searches(执行查询)
- Executing Filters(执行过滤)
- Executing Aggregations(执行聚合)
- Conclusion(总结)
- Setup Elasticsearch(设置)
- Installing Elasticsearch(安装)
- zip 或 tar.gz 安装
- Debian软件包安装Elasticsearch
- 用RPM安装Elasticsearch
- Windows 环境下安装ES
- Docker 方式安装
- 配置Elasticsearch
- 重要Elasticsearch配置
- 安全配置
- 启动前检查
- 堆大小检查
- 文件描述符检查
- 内存锁定检查
- 最大线程数检查
- 最大虚拟内存检查
- 最大map数检查
- JVM Client模式检查
- 串行收集使用检查
- 系统调用过滤检查
- OnError与OnOutOfMemoryError检查
- G1GC检查
- 重要的系统配置
- 系统设置
- 在jvm.options中设置JVM堆大小
- 禁用swapping
- 文件描述符
- 虚拟内存
- 线程数
- 升级Elasticsearch
- Elasticsearch停机
- 重大改变
- 在5.3 重大改变
- 在5.2 重大改变
- Shadow Replicas已被弃用
- 在5.1 重大改变
- 在5.0 重大改变
- 搜索和查询DSL改变
- 映射改变
- 过滤器改变
- Suggester变化
- 索引API改变
- 文档API改变
- 设置的改变
- 分配改变
- HTTP改变
- REST API改变
- CAT API改变
- Java API改变
- Packaging
- Plugin改变
- 文件系统相关改变
- 磁盘上数据的路径
- 聚合改变
- 脚本相关改变
- API 规范
- Multiple Indices(多个索引)
- Date math support in index names(索引名称对 Date 和 Math 的支持)
- 常见选项
- URL-based access control(基于 URL 的访问控制)
- Document APIS
- Index API
- Get API
- Update API
- 通过查询 API 更新
- 多个 GET API
- Bulk API
- Reading and Writing documents(读写文档)
- Delete API
- Delete By Query API
- Reindex API
- Term Vectors
- Multi termvectors API
- ?refresh
- Search APIs
- Search
- URI Search
- Request Body Search
- Query
- From / Size
- Sort
- Source filtering
- Fields
- Script Fields
- Doc value Fields
- Post filter
- Highlighting
- Rescoring
- Search Type
- Scroll
- Preference
- Explain
- Version
- Index Boost
- min_score
- Named Queries
- Inner hits
- Search After
- Field Collapsing 字段折叠
- Search 模板
- Multi Search 模板
- Search Shards API
- Suggesters
- Completion Suggester
- Context Suggester
- Phrase Suggester
- Term suggester
- Multi Search API
- Count API
- Validate API
- Explain API
- Profile API
- Profiling Queries
- Profiling Aggregations
- Profiling Considerations
- Aggregations
- Metric Aggregations
- 值计数聚合(Value Count Aggregation)
- 地理边界聚合
- 地理重心聚合
- 基数聚合
- 平均值聚合
- 扩展统计聚合
- 最大值聚合
- 最小值聚合
- Bucket Aggregations
- Children Aggregation
- Date Histogram Aggregation
- Date Range Aggregation
- Diversified Sampler Aggregation
- Filter Aggregation(过滤器聚合)
- Filters Aggregation
- Geo Distance Aggregation(地理距离聚合)
- GeoHash grid Aggregation(GeoHash网格聚合)
- Global Aggregation(全局聚合)
- Histogram Aggregation
- IP Range Aggregation(IP范围聚合)
- Missing Aggregation
- Nested Aggregation(嵌套聚合)
- Range Aggregation(范围聚合)
- Reverse nested Aggregation
- Sampler Aggregation
- Significant Terms Aggregation
- 邻接矩阵聚合
- Pipeline Aggregations
- Avg Bucket Aggregation
- Derivative Aggregation(导数聚合)
- Max Bucket Aggregation
- Min Bucket Aggregation
- Sum Bucket Aggregation
- Stats Bucket Aggregation
- Extended Stats Bucket Aggregation(扩展信息桶聚合)
- Percentiles Bucket Aggregation(百分数桶聚合)
- Cumulative Sum Aggregation(累积汇总聚合)
- Bucket Script Aggregation(桶脚本聚合)
- Bucket Selector Aggregation(桶选择器聚合)
- Serial Differencing Aggregation(串行差异聚合)
- Matrix Aggregations
- Matrix Stats
- Matrix Stats(矩阵统计)
- Caching heavy aggregations(缓存频繁聚合)
- Returning only aggregation results(仅返回需要聚合的结果)
- Aggregation Metadata(聚合元数据)
- Returning the type of the aggregation(返回聚合的类型)
- 索引 API
- Create Index /创建索引
- Delete Index /删除索引
- Get Index /获取索引
- Indices Exists /索引存在
- Open / Close Index API /启动关闭索引
- Shrink Index /缩小索引
- Rollover Index/滚动索引
- Put Mapping /提交映射
- Get Mapping /获取映射
- Get Field Mapping /获取字段映射
- 卷影副本索引
- 依赖卷影副本的节点级设置
- 索引统计信息
- 索引段
- 索引恢复
- 索引分片存储
- 清理缓存
- 刷新
- 同步刷新
- 重新加载
- 强制合并
- cat APIs
- cat aliases
- cat allocation
- cat count
- cat fielddata
- cat health
- cat indices
- cat master
- cat nodeattrs
- cat nodes
- cat pending tasks
- cat plugins
- cat recovery
- cat repositories
- cat thread pool
- cat shards
- cat segments
- cat snapshots
- 集群 API
- Cluster Allocation Explain API
- Cluster Health
- Cluster Reroute
- Cluster State
- Cluster Stats
- Cluster Update Settings
- Nodes hot_threads
- Nodes Info
- Nodes Stats
- Pending cluster tasks
- Task Management API
- 查询 DSL
- 查询和过滤上下文
- Match ALL 查询
- 全文搜索
- 匹配查询
- 短语匹配查询
- 短语前缀匹配查询
- 多字段查询
- 常用术语查询
- 查询语句查询
- 简单查询语句
- 复合查询家族
- Constant Score 查询
- Bool 查询
- Dis Max 查询
- Function Score 查询
- Boosting 查询
- Indices 查询
- Join 查询
- Has Child Query
- Has Parent Query
- Nested Query(嵌套查询)
- Parent Id Query
- 术语查询
- Exists Query(非空值查询)
- Fuzzy Query(模糊查询)
- Ids Query(ID 查询)
- Prefix Query(前缀查询)
- Range Query(范围查询)
- Regexp Query(正则表达式查询)
- Term Query(项查询)
- Terms Query(多项查询)
- Type Query(类型查询)
- Wildcard Query(通配符查询)
- 地理位置查询
- GeoShape Query(地理形状查询)
- Geo Bounding Box Query(地理边框查询)
- Geo Distance Query(地理距离查询)
- Geo Distance Range Query(地理距离范围查询)
- Geo Polygon Query(地理多边形查询)
- Span 查询
- Span Term 查询
- Span Multi Term 查询
- Span First 查询
- Span Near 查询
- Span Or 查询
- Span Not 查询
- Span Containing 查询
- Span Within 查询
- Span Field Masking 查询
- Specialized queries(专业查询)
- Mapping(映射)
- 字段类型
- Array
- Binary
- Range
- Boolean
- Date
- Geo-point datatype
- String
- Text
- Token数
- 渗滤型
- KeyWord
- Nested
- Object
- Numeric
- Meta-Fields(元字段)
- _all field
- _field_names field
- _id field
- _index field
- _meta field
- _parent field
- _routing field
- _source field
- _type field
- _uid field
- Mapping parameters(映射参数)
- analyzer(分析器)
- normalizer(归一化)
- boost(提升)
- Coerce(强制类型转换)
- copy_to(合并参数)
- doc_values(文档值)
- dynamic(动态设置)
- enabled(开启字段)
- fielddata(字段数据)
- format (日期格式)
- ignore_above(忽略超越限制的字段)
- ignore_malformed(忽略格式不对的数据)
- include_in_all(_all 查询包含字段)
- index_options(索引设置)
- index (索引)
- fields(字段)
- Norms (标准信息)
- null_value(空值)
- position_increment_gap(短语位置间隙)
- properties (属性)
- search_analyzer (搜索分析器)
- similarity (匹配方法)
- store(存储)
- Term_vectors(词根信息)
- Dynamic Mapping(动态映射)
- default mapping(mapping中的_default_)
- Dynamic field mapping(动态字段映射)
- Dynamic templates(动态模板)
- Override default template(覆盖默认模板)
- Mapping(映射)
- Analysis
- Tokenizers(分词器)
- Standard Tokenizer(标准分词器)
- Letter Tokenizer
- Lowercase Tokenizer (小写分词器)
- Whitespace Analyzer
- 停止分析器
- UAX URL Email Tokenizer
- Classic Tokenizer
- Thai Tokenizer(泰语分词器)
- NGram Tokenizer
- Keyword Analyzer
- Path Hierarchy Tokenizer(路径层次分词器)
- Pattern Tokenizer
- Token Filters(词元过滤器)
- Apostrophe Token Filter(撇号/单引号过滤器)
- ASCII Folding Token Filter(ASCII Folding 词元过滤器)
- CJK Bigram Token Filter(CJK Bigram词元过滤器)
- CJK Width Token Filter(CJK宽度过滤器)
- Classic Token Filter(经典过滤器)
- Common Grams Token Filter(近义词词元过滤器)
- Compound Word Token Filter(复合词过滤器)
- Decimal Digit Token Filter(十进制数字过滤器)
- Delimited Payload Token Filter(Delimited Payload词元分析器)
- Edge NGram Token Filter(Edge NGram 词元过滤器)
- Elision Token Filter(Elision词元过滤器)
- Fingerprint Token Filter(指纹过滤器)
- Flatten Graph Token Filter(Flatten Graph 词元过滤器)
- Hunspell Token Filter(Hunspell 词元过滤器)
- Keep Types Token Filter(保留指定类型过滤器)
- Keep Words Token Filter(保留字过滤器)
- Keyword Marker Token Filter(Keyword Marker 词元过滤器)
- Keyword Repeat Token Filter(Keyword Repeat 词元过滤器)
- KStem Token Filter(KStem 词元过滤器)
- Length Token Filter(长度词元过滤器)
- Limit Token Count Token Filter(限制词元数量过滤器)
- Lowercase Token Filter(Lowercase 词元过滤器)
- Minhash Token Filter(Minhash过滤器)
- NGram Token Filter(NGram词元过滤器)
- Normalization Token Filter(标准化词元过滤器)
- Pattern Capture Token Filter(模式匹配词元过滤器)
- Pattern Replace Token Filter(模式替换词元过滤器)
- Phonetic Token Filter(Phonetic 词元过滤器)
- Porter Stem Token Filter(Porter Stem 词元过滤器)
- Reverse Token Filteredit(反向词元过滤器)
- Shingle Token Filter(Shingle 词元过滤器)
- Snowball Token Filter(Snowball 词元过滤器)
- Standard Token Filters(标准词元过滤器)
- Stemmer Override Token Filter(Stemmer Override 词元过滤器)
- Stemmer Token Filter(Stemmer 词元过滤器)
- Stop Token Filter(Stop 词元过滤器)
- Synonym Graph Token Filter(Synonym Graph 词元过滤器)
- Synonym Token Filter(Synonym 词元过滤器)
- Trim Token Filter(Trim词元过滤器)
- Truncate Token Filter(截断词元过滤器)
- Unique Token Filter(唯一词元过滤器)
- Uppercase Token Filter(Uppercase词元过滤器)
- Word Delimiter Token Filter(Word Delimiter 词元过滤器)
- Character Filters(字符过滤器)
- md Strip Character Filter
- Mapping Character Filter
- Pattern Replace Character Filter
- Anatomy of an analyzer(分析器的分析)
- Testing analyzers(测试分析器)
- Analyzers(分析器)
- Configuring built-in analyzers(配置内置分析器)
- Standard Analyzer(标准分析器)
- Simple Analyzer(简单分析器)
- 空白分析器
- Stop Analyzer
- 指纹分析器
- 模式分析器
- 自定义分析器
- 语言分析器
- 模块
- Indices(索引)
- Circuit breakers(熔断器)
- Fielddata cache(列数据缓存)
- indexing buffer(索引写入缓冲)
- indices Recovery(索引恢复)
- NetWork Setting(网络配置)
- Node Query Cache(节点查询缓存)
- Shard request cache(分片请求缓存)
- 脚本
- Groovy 脚本语言
- Painless 脚本语言
- Painless 语法
- Painless 调试
- Lucene表达式语言
- 原生(Java)脚本
- 高级文本评分脚本
- 快照和还原
- 线程池
- 传输
- HTTP
- Tribe Node (部落节点)
- 跨集群搜索
- Cluster(集群)
- Disk-based Shard Allocation ( 基于磁盘的分片分配 )
- Shard Allocation Awareness ( 分片分配意识 )
- 群集级别分片分配
- Node
- 插件
- Index Modules(索引模块)
- Analysis(分析)
- 索引分片分配
- 分片分配过滤
- 节点丢失时的延迟分配
- 索引恢复的优先级
- 每个节点的总分片数
- Mapper(映射)
- Merge(合并)
- Similarity module(相似模块)
- Slow log(慢日志)
- Store
- 预加载数据到文件系统缓存
- Translog(事务日志)
- Ingest Node(预处理节点)
- Pipeline Definition(管道定义)
- Ingest APIs
- Put Pipeline API
- Get Pipeline API
- Delete Pipeline API
- Simulate Pipeline API(模拟管道 API)
- Accessing Data in Pipelines(访问管道中的数据)
- Handling Failures in Pipelines(处理管道中的故障)
- Processors(处理器)
- Append Processor(追加处理器)
- Convert Processor(转换处理器)
- Date Processor(日期处理器)
- Date Index Name Processor(日期索引名称处理器)
- Fail Processor(故障处理器)
- Foreach Processor(循环处理器)
- Grok Processor(Grok 处理器)
- Gsub Processor(Gsub 处理器)
- Join Processor(连接处理器)
- JSON Processor(JSON 处理器)
- KV Processor(KV 处理器)
- Lowercase Processor(小写处理器)
- Remove Processor(删除处理器)
- Rename Processor(重命名处理器)
- Script Processor(脚本处理器)
- Set Processor(设置处理器)
- Split Processor(拆分处理器)
- Sort Processor(排序处理器)
- Trim Processor(修剪处理器)
- Uppercase Processor(大写处理器)
- Dot Expander Processor(点扩展器处理器)
- How to(操作方式)
- 一些建议
- Recipes(诀窍)
- 索引速率调优
- 查询优化
- 磁盘使用调优
- Testing(测试)
- Java Testing Framework(测试框架)
- ( why randomized testing ) 为什么随机测试?
- Using the elasticsearch test classes ( 使用 elasticsearch 测试类 )
- unit tests(单元测试)
- integreation test(集成测试)
- Randomized testing(随机测试)
- Assertions()
- Glossary of terms (词汇表)
- Release Notes(版本说明)
- 5.3.0 版本说明
- 5.2.2 Release Notes
- 5.2.1 Release Notes
- 5.2.0 Release Notes
- 5.1.2 Release Notes
- 5.1.1 Release Notes
- 5.1.0 Release Notes
- 5.0.1 Release Notes