一、集群搭建测试
修改配置文件:
vim ./config/elasticsearch.yml
修改三个地方:
#
# Use a descriptive name for the node:
#
节点名称,注意,前面需要空格
node.name: node-2
# Set the bind address to a specific IP (IPv4 or IPv6):
#
这里是本机的ip地址
network.host: 192.168.16.191
# discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
这里设置的是集群中其他主机地址
discovery.zen.ping.unicast.hosts: ["192.168.16.195"]
1. 先启动一台主机,观察
二、集群API访问和介绍
一共有四种集群监控的API
,分别介绍如下:
集群健康诊断的API
,主要有集群的名称、健康状态、节点数、
pengding
任务等信息。
部分
API参数的解释:
{
"cluster_name" : "elasticsearch",
#集群名称
"status" : "green",
#集群的健康状态,green健康,red表示不可用
"timed_out" : false,
"number_of_nodes" : 2,
# 节点数
"number_of_data_nodes" : 2,
#数据节点数
"active_primary_shards" : 14,
"active_shards" : 28,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
#没有分配数据的分片
"delayed_unassigned_shards" : 0,
#延迟的没有分配数据的分片
"number_of_pending_tasks" : 0,
#pending状态的任务
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
相比第一个监控集群的API
,这是一个比较详细的监控集群状态的
API
。包含了
status
、文件存储、
jvm
等信息。截图如下:
监控Pending Task
列表的信息。
监控节点统计信息的API
,可以监控每个节点的信息。
Indices
里面包含了
indexing
、
get
、
search
、
merges
的一些统计信息。
Os
里面包含了一些操作系统相关的信息,比如
CPU
、内存等使用信息。
JVM
包含堆栈的使用比等。
Fs
是磁盘的使用情况。
{
"cluster_name" : "elasticsearch",
"nodes" : {
"kNdpkbGgQue0OhXUyg_7Zg" : {
"timestamp" : 1475987512564,
"name" : "node-2",
"transport_address" : "192.168.16.191:9300",
"host" : "192.168.16.191",
"ip" : [ "192.168.16.191:9300", "NONE" ],
"indices" : {
"docs" : {
"count" : 8,
"deleted" : 0
},
"store" : {
"size_in_bytes" : 34728,
"throttle_time_in_millis" : 0
},
"indexing" : {
"index_total" : 0,
"index_time_in_millis" : 0,
"index_current" : 0,
"index_failed" : 0,
"delete_total" : 0,
"delete_time_in_millis" : 0,
"delete_current" : 0,
"noop_update_total" : 0,
"is_throttled" : false,
"throttle_time_in_millis" : 0
},
"get" : {
"total" : 0,
"time_in_millis" : 0,
"exists_total" : 0,
"exists_time_in_millis" : 0,
"missing_total" : 0,
"missing_time_in_millis" : 0,
"current" : 0
},
"search" : {
"open_contexts" : 0,
"query_total" : 0,
"query_time_in_millis" : 0,
"query_current" : 0,
"fetch_total" : 0,
"fetch_time_in_millis" : 0,
"fetch_current" : 0,
"scroll_total" : 0,
"scroll_time_in_millis" : 0,
"scroll_current" : 0
},
"merges" : {
"current" : 0,
"current_docs" : 0,
"current_size_in_bytes" : 0,
"total" : 0,
"total_time_in_millis" : 0,
"total_docs" : 0,
"total_size_in_bytes" : 0,
"total_stopped_time_in_millis" : 0,
"total_throttled_time_in_millis" : 0,
"total_auto_throttle_in_bytes" : 293601280
},
"refresh" : {
"total" : 0,
"total_time_in_millis" : 0
},
"flush" : {
"total" : 0,
"total_time_in_millis" : 0
},
"warmer" : {
"current" : 0,
"total" : 42,
"total_time_in_millis" : 286
},
"query_cache" : {
"memory_size_in_bytes" : 0,
"total_count" : 0,
"hit_count" : 0,
"miss_count" : 0,
"cache_size" : 0,
"cache_count" : 0,
"evictions" : 0
},
"fielddata" : {
"memory_size_in_bytes" : 0,
"evictions" : 0
},
"percolate" : {
"total" : 0,
"time_in_millis" : 0,
"current" : 0,
"memory_size_in_bytes" : -1,
"memory_size" : "-1b",
"queries" : 0
},
"completion" : {
"size_in_bytes" : 0
},
"segments" : {
"count" : 8,
"memory_in_bytes" : 20704,
"terms_memory_in_bytes" : 15936,
"stored_fields_memory_in_bytes" : 2496,
"term_vectors_memory_in_bytes" : 0,
"norms_memory_in_bytes" : 1536,
"doc_values_memory_in_bytes" : 736,
"index_writer_memory_in_bytes" : 0,
"index_writer_max_memory_in_bytes" : 7168000,
"version_map_memory_in_bytes" : 0,
"fixed_bit_set_memory_in_bytes" : 0
},
"translog" : {
"operations" : 0,
"size_in_bytes" : 602
},
"suggest" : {
"total" : 0,
"time_in_millis" : 0,
"current" : 0
},
"request_cache" : {
"memory_size_in_bytes" : 0,
"evictions" : 0,
"hit_count" : 0,
"miss_count" : 0
},
"recovery" : {
"current_as_source" : 0,
"current_as_target" : 0,
"throttle_time_in_millis" : 0
}
},
"os" : {
"timestamp" : 1475987512574,
"load_average" : 0.0,
"mem" : {
"total_in_bytes" : 2877353984,
"free_in_bytes" : 2389590016,
"used_in_bytes" : 487763968,
"free_percent" : 83,
"used_percent" : 17
},
"swap" : {
"total_in_bytes" : 2080366592,
"free_in_bytes" : 2080366592,
"used_in_bytes" : 0
}
},
"process" : {
"timestamp" : 1475987512575,
"open_file_descriptors" : 158,
"max_file_descriptors" : 4096,
"cpu" : {
"percent" : 0,
"total_in_millis" : 24560
},
"mem" : {
"total_virtual_in_bytes" : 2012266496
}
},
"jvm" : {
"timestamp" : 1475987512575,
"uptime_in_millis" : 1080084,
"mem" : {
"heap_used_in_bytes" : 148908680,
"heap_used_percent" : 13,
"heap_committed_in_bytes" : 259719168,
"heap_max_in_bytes" : 1065025536,
"non_heap_used_in_bytes" : 39992544,
"non_heap_committed_in_bytes" : 40828928,
"pools" : {
"young" : {
"used_in_bytes" : 47079640,
"max_in_bytes" : 69795840,
"peak_used_in_bytes" : 69795840,
"peak_max_in_bytes" : 69795840
},
"survivor" : {
"used_in_bytes" : 8716288,
"max_in_bytes" : 8716288,
"peak_used_in_bytes" : 8716288,
"peak_max_in_bytes" : 8716288
},
"old" : {
"used_in_bytes" : 93112752,
"max_in_bytes" : 986513408,
"peak_used_in_bytes" : 93112752,
"peak_max_in_bytes" : 986513408
}
}
},
"threads" : {
"count" : 25,
"peak_count" : 31
},
"gc" : {
"collectors" : {
"young" : {
"collection_count" : 6,
"collection_time_in_millis" : 1399
},
"old" : {
"collection_count" : 0,
"collection_time_in_millis" : 0
}
}
},
"buffer_pools" : {
"direct" : {
"count" : 19,
"used_in_bytes" : 2501918,
"total_capacity_in_bytes" : 2501918
},
"mapped" : {
"count" : 0,
"used_in_bytes" : 0,
"total_capacity_in_bytes" : 0
}
}
},
"thread_pool" : {
"bulk" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"fetch_shard_started" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"fetch_shard_store" : {
"threads" : 1,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 2,
"completed" : 14
},
"flush" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"force_merge" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"generic" : {
"threads" : 1,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 5,
"completed" : 1255
},
"get" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"index" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"listener" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"management" : {
"threads" : 3,
"queue" : 0,
"active" : 1,
"rejected" : 0,
"largest" : 3,
"completed" : 78
},
"percolate" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"refresh" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"search" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"snapshot" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"suggest" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"warmer" : {
"threads" : 1,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 1,
"completed" : 14
}
},
"fs" : {
"timestamp" : 1475987512575,
"total" : {
"total_in_bytes" : 39706910720,
"free_in_bytes" : 34210103296,
"available_in_bytes" : 32193064960,
"spins" : "true"
},
"data" : [ {
"path" : "/home/elk/es/escluster/es_node/data/elasticsearch/nodes/0",
"mount" : "/ (/dev/mapper/vg_dtgr-lv_root)",
"type" : "ext4",
"total_in_bytes" : 39706910720,
"free_in_bytes" : 34210103296,
"available_in_bytes" : 32193064960,
"spins" : "true"
},
"transport" : {
"server_open" : 13,
"rx_count" : 2325,
"rx_size_in_bytes" : 283291,
"tx_count" : 2324,
"tx_size_in_bytes" : 413666
},
"http" : {
"current_open" : 0,
"total_opened" : 0
},
"breakers" : {
"fielddata" : {
"limit_size_in_bytes" : 639015321,
"limit_size" : "609.4mb",
"estimated_size_in_bytes" : 0,
"estimated_size" : "0b",
"overhead" : 1.03,
"tripped" : 0
},
"request" : {
"limit_size_in_bytes" : 426010214,
"limit_size" : "406.2mb",
"estimated_size_in_bytes" : 0,
"estimated_size" : "0b",
"overhead" : 1.0,
"tripped" : 0
},
"parent" : {
"limit_size_in_bytes" : 745517875,
"limit_size" : "710.9mb",
"estimated_size_in_bytes" : 0,
"estimated_size" : "0b",
"overhead" : 1.0,
"tripped" : 0
}
},
"script" : {
"compilations" : 0,
"cache_evictions" : 0
}
},
"U3LHH9f8S7uZjbdx39MK3g" : {
"timestamp" : 1475987512339,
"name" : "node-1",
"transport_address" : "192.168.16.195:9300",
"host" : "192.168.16.195",
"ip" : [ "192.168.16.195:9300", "NONE" ],
"indices" : {
"docs" : {
"count" : 8,
"deleted" : 0
},
"store" : {
"size_in_bytes" : 34728,
"throttle_time_in_millis" : 0
},
"indexing" : {
"index_total" : 0,
"index_time_in_millis" : 0,
"index_current" : 0,
"index_failed" : 0,
"delete_total" : 0,
"delete_time_in_millis" : 0,
"delete_current" : 0,
"noop_update_total" : 0,
"is_throttled" : false,
"throttle_time_in_millis" : 0
},
"get" : {
"total" : 0,
"time_in_millis" : 0,
"exists_total" : 0,
"exists_time_in_millis" : 0,
"missing_total" : 0,
"missing_time_in_millis" : 0,
"current" : 0
},
"search" : {
"open_contexts" : 0,
"query_total" : 0,
"query_time_in_millis" : 0,
"query_current" : 0,
"fetch_total" : 0,
"fetch_time_in_millis" : 0,
"fetch_current" : 0,
"scroll_total" : 0,
"scroll_time_in_millis" : 0,
"scroll_current" : 0
},
"merges" : {
"current" : 0,
"current_docs" : 0,
"current_size_in_bytes" : 0,
"total" : 0,
"total_time_in_millis" : 0,
"total_docs" : 0,
"total_size_in_bytes" : 0,
"total_stopped_time_in_millis" : 0,
"total_throttled_time_in_millis" : 0,
"total_auto_throttle_in_bytes" : 293601280
},
"refresh" : {
"total" : 0,
"total_time_in_millis" : 0
},
"flush" : {
"total" : 0,
"total_time_in_millis" : 0
},
"warmer" : {
"current" : 0,
"total" : 28,
"total_time_in_millis" : 39
},
"query_cache" : {
"memory_size_in_bytes" : 0,
"total_count" : 0,
"hit_count" : 0,
"miss_count" : 0,
"cache_size" : 0,
"cache_count" : 0,
"evictions" : 0
},
"fielddata" : {
"memory_size_in_bytes" : 0,
"evictions" : 0
},
"percolate" : {
"total" : 0,
"time_in_millis" : 0,
"current" : 0,
"memory_size_in_bytes" : -1,
"memory_size" : "-1b",
"queries" : 0
},
"completion" : {
"size_in_bytes" : 0
},
"segments" : {
"count" : 8,
"memory_in_bytes" : 20704,
"terms_memory_in_bytes" : 15936,
"stored_fields_memory_in_bytes" : 2496,
"term_vectors_memory_in_bytes" : 0,
"norms_memory_in_bytes" : 1536,
"doc_values_memory_in_bytes" : 736,
"index_writer_memory_in_bytes" : 0,
"index_writer_max_memory_in_bytes" : 7168000,
"version_map_memory_in_bytes" : 0,
"fixed_bit_set_memory_in_bytes" : 0
},
"translog" : {
"operations" : 0,
"size_in_bytes" : 602
},
"suggest" : {
"total" : 0,
"time_in_millis" : 0,
"current" : 0
},
"request_cache" : {
"memory_size_in_bytes" : 0,
"evictions" : 0,
"hit_count" : 0,
"miss_count" : 0
},
"recovery" : {
"current_as_source" : 0,
"current_as_target" : 0,
"throttle_time_in_millis" : 0
}
},
"os" : {
"timestamp" : 1475987512357,
"load_average" : 0.0,
"mem" : {
"total_in_bytes" : 2877353984,
"free_in_bytes" : 2385223680,
"used_in_bytes" : 492130304,
"free_percent" : 83,
"used_percent" : 17
},
"swap" : {
"total_in_bytes" : 2080366592,
"free_in_bytes" : 2080366592,
"used_in_bytes" : 0
}
},
"process" : {
"timestamp" : 1475987512357,
"open_file_descriptors" : 232,
"max_file_descriptors" : 4096,
"cpu" : {
"percent" : 0,
"total_in_millis" : 28390
},
"mem" : {
"total_virtual_in_bytes" : 2010710016
}
},
"jvm" : {
"timestamp" : 1475987512358,
"uptime_in_millis" : 1283338,
"mem" : {
"heap_used_in_bytes" : 118976424,
"heap_used_percent" : 11,
"heap_committed_in_bytes" : 259719168,
"heap_max_in_bytes" : 1065025536,
"non_heap_used_in_bytes" : 41382256,
"non_heap_committed_in_bytes" : 42008576,
"pools" : {
"young" : {
"used_in_bytes" : 18972864,
"max_in_bytes" : 69795840,
"peak_used_in_bytes" : 69795840,
"peak_max_in_bytes" : 69795840
},
"survivor" : {
"used_in_bytes" : 4439248,
"max_in_bytes" : 8716288,
"peak_used_in_bytes" : 8716288,
"peak_max_in_bytes" : 8716288
},
"old" : {
"used_in_bytes" : 95564312,
"max_in_bytes" : 986513408,
"peak_used_in_bytes" : 95564312,
"peak_max_in_bytes" : 986513408
}
}
},
"threads" : {
"count" : 27,
"peak_count" : 32
},
"gc" : {
"collectors" : {
"young" : {
"collection_count" : 7,
"collection_time_in_millis" : 1392
},
"old" : {
"collection_count" : 0,
"collection_time_in_millis" : 0
}
}
},
"buffer_pools" : {
"direct" : {
"count" : 26,
"used_in_bytes" : 5398444,
"total_capacity_in_bytes" : 5398444
},
"mapped" : {
"count" : 0,
"used_in_bytes" : 0,
"total_capacity_in_bytes" : 0
}
},
"classes" : {
"current_loaded_count" : 7364,
"total_loaded_count" : 7364,
"total_unloaded_count" : 0
}
},
"thread_pool" : {
"bulk" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"fetch_shard_started" : {
"threads" : 1,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 2,
"completed" : 14
},
"fetch_shard_store" : {
"threads" : 1,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 2,
"completed" : 14
},
"flush" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"force_merge" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"generic" : {
"threads" : 1,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 4,
"completed" : 177
},
"get" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"index" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"listener" : {
"threads" : 1,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 1,
"completed" : 38
},
"management" : {
"threads" : 3,
"queue" : 0,
"active" : 1,
"rejected" : 0,
"largest" : 3,
"completed" : 183
},
"percolate" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"refresh" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"search" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"snapshot" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"suggest" : {
"threads" : 0,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 0,
"completed" : 0
},
"warmer" : {
"threads" : 1,
"queue" : 0,
"active" : 0,
"rejected" : 0,
"largest" : 1,
"completed" : 14
}
},
"fs" : {
"timestamp" : 1475987512358,
"total" : {
"total_in_bytes" : 39706910720,
"free_in_bytes" : 34209550336,
"available_in_bytes" : 32192512000,
"spins" : "true"
},
"data" : [ {
"path" : "/home/elk/es/escluster/es_node/data/elasticsearch/nodes/0",
"mount" : "/ (/dev/mapper/vg_dtgr-lv_root)",
"type" : "ext4",
"total_in_bytes" : 39706910720,
"free_in_bytes" : 34209550336,
"available_in_bytes" : 32192512000,
"spins" : "true"
},
"transport" : {
"server_open" : 13,
"rx_count" : 2325,
"rx_size_in_bytes" : 422787,
"tx_count" : 2325,
"tx_size_in_bytes" : 283291
},
"http" : {
"current_open" : 6,
"total_opened" : 28
},
"breakers" : {
"fielddata" : {
"limit_size_in_bytes" : 639015321,
"limit_size" : "609.4mb",
"estimated_size_in_bytes" : 0,
"estimated_size" : "0b",
"overhead" : 1.03,
"tripped" : 0
},
"request" : {
"limit_size_in_bytes" : 426010214,
"limit_size" : "406.2mb",
"estimated_size_in_bytes" : 0,
"estimated_size" : "0b",
"overhead" : 1.0,
"tripped" : 0
},
"parent" : {
"limit_size_in_bytes" : 745517875,
"limit_size" : "710.9mb",
"estimated_size_in_bytes" : 0,
"estimated_size" : "0b",
"overhead" : 1.0,
"tripped" : 0
}
},
"script" : {
"compilations" : 0,
"cache_evictions" : 0
}
}
}
}