一、cluster API详解
1、cluster health(获取集群的状态)
集群状态:
green:绿色表示所有的碎片都被分配
yellow:黄色表示主碎片被分配,但副本不是
red:表示特定的碎片没有在集群中分配
请求参数
level: cluster,indices,shards
wait_for_status: green,yellow,red
[[email protected] ~]# curl -XGET ‘:9200/_cluster/health/tomcat-access-log-2017.05.11?level=shards&pretty‘ -u adminName -p
2、索引状态(cluster state)
2.1)nodes(节点状态)
2.2)显示主节点状态(master_node)
3、集群数据(cluster stats)
[[email protected] ~]# curl -XGET ‘:9200/_cluster/stats?human&pretty‘ -u adminName -p
Enter host password for user ‘adminName‘:
{
"timestamp" : 1494680352006,
"cluster_name" : "myelk",
"status" : "green",
"indices" : {
"count" : 5,
"shards" : {
"total" : 42,
"primaries" : 21,
"replication" : 1.0,
"index" : {
"shards" : {
"min" : 2,
"max" : 10,
"avg" : 8.4
},
"primaries" : {
"min" : 1,
"max" : 5,
"avg" : 4.2
},
"replication" : {
"min" : 1.0,
"max" : 1.0,
"avg" : 1.0
}
}
},
"docs" : {
"count" : 11047,
"deleted" : 0
},
"store" : {
"size" : "6.4mb",
"size_in_bytes" : 6802156,
"throttle_time" : "0s",
"throttle_time_in_millis" : 0
},
"fielddata" : {
"memory_size" : "0b",
"memory_size_in_bytes" : 0,
"evictions" : 0
},
"query_cache" : {
"memory_size" : "0b",
"memory_size_in_bytes" : 0,
"total_count" : 144823,
"hit_count" : 0,
"miss_count" : 144823,
"cache_size" : 0,
"cache_count" : 0,
"evictions" : 0
},
"completion" : {
"size" : "0b",
"size_in_bytes" : 0
},
"segments" : {
"count" : 213,
"memory" : "1.3mb",
"memory_in_bytes" : 1367681,
"terms_memory" : "1mb",
"terms_memory_in_bytes" : 1049853,
"stored_fields_memory" : "65.7kb",
"stored_fields_memory_in_bytes" : 67360,
"term_vectors_memory" : "0b",
"term_vectors_memory_in_bytes" : 0,
"norms_memory" : "199.3kb",
"norms_memory_in_bytes" : 204096,
"doc_values_memory" : "45.2kb",
"doc_values_memory_in_bytes" : 46372,
"index_writer_memory" : "0b",
"index_writer_memory_in_bytes" : 0,
"index_writer_max_memory" : "20.5mb",
"index_writer_max_memory_in_bytes" : 21504000,
"version_map_memory" : "0b",
"version_map_memory_in_bytes" : 0,
"fixed_bit_set" : "0b",
"fixed_bit_set_memory_in_bytes" : 0
},
"percolate" : {
"total" : 0,
"time" : "0s",
"time_in_millis" : 0,
"current" : 0,
"memory_size_in_bytes" : -1,
"memory_size" : "-1b",
"queries" : 0
}
},
"nodes" : {
"count" : {
"total" : 3,
"master_only" : 0,
"data_only" : 0,
"master_data" : 3,
"client" : 0
},
"versions" : [ "2.3.3" ],
"os" : {
"available_processors" : 3,
"allocated_processors" : 3,
"mem" : {
"total" : "312.1mb",
"total_in_bytes" : 327274496
},
"names" : [ {
"name" : "Linux",
"count" : 3
} ]
},
"process" : {
"cpu" : {
"percent" : 0
},
"open_file_descriptors" : {
"min" : 266,
"max" : 281,
"avg" : 272
}
},
"jvm" : {
"max_uptime" : "2.1d",
"max_uptime_in_millis" : 188337407,
"versions" : [ {
"version" : "1.8.0_111",
"vm_name" : "Java HotSpot(TM) 64-Bit Server VM",
"vm_version" : "25.111-b14",
"vm_vendor" : "Oracle Corporation",
"count" : 3
} ],
"mem" : {
"heap_used" : "203.7mb",
"heap_used_in_bytes" : 213674160,
"heap_max" : "2.9gb",
"heap_max_in_bytes" : 3195076608
},
"threads" : 88
},
"fs" : {
"total" : "40.7gb",
"total_in_bytes" : 43701583872,
"free" : "27.1gb",
"free_in_bytes" : 29138677760,
"available" : "25gb",
"available_in_bytes" : 26898292736,
"spins" : "true"
},
"plugins" : [ {
"name" : "head",
"version" : "master",
"description" : "head - A web front end for an elastic search cluster",
"url" : "/_plugin/head/",
"jvm" : false,
"site" : true
}, {
"name" : "license",
"version" : "2.3.3",
"description" : "Internal Elasticsearch Licensing Plugin",
"jvm" : true,
"classname" : "org.elasticsearch.license.plugin.LicensePlugin",
"isolated" : false,
"site" : false
}, {
"name" : "shield",
"version" : "2.3.3",
"description" : "Elasticsearch Shield (security)",
"jvm" : true,
"classname" : "org.elasticsearch.shield.ShieldPlugin",
"isolated" : false,
"site" : false
} ]
}
}
[[email protected] ~]# curl -XGET ‘:9200/_nodes/stats/indices?pretty‘ -u adminName -p----统计节点信息
二、CAT API
1、master---查找主节点