Elasticsearch 節點運維的那些套路,【杏耀註冊】寫的這篇文章是易懂的
阿新 • • 發佈:2022-04-12
一、節點相關命令
1、檢視節點基本資訊
GET /_nodes/<node_id>
該命令能夠一次性返回節點全部的資訊,如process、jvm、plugins以及節點角色roles、屬性 attributes 和 settings 等相關資訊。如果我們想要返回特定的資訊,如process,則可以使用如下API:
GET /_nodes/<node_id>/process
返回 Response:
{
"_nodes" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"cluster_name" : "es-xxxx",
"nodes" : {
"fdaOV16OQPq6-AUVihmq4A" : {
"name" : "162680s31430001456s32",
"transport_address" : "xx.0.96.22:9300",
"host" : "xx.0.96.22",
"ip" : "xx.0.96.22",
"version" : "7.10.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "119c2106d7bd8d206aa3b65dc43c87b8aa590b2b",
"roles" : [
"master",
"ml",
"remote_cluster_client"
],
"attributes" : {
"ml.machine_memory" : "16478932992",
"rack" : "cvm_4_200003",
"xpack.installed" : "true",
"set" : "200003",
"transform.node" : "false",
"ip" : "xx.20.58.221",
"temperature" : "hot",
"ml.max_open_jobs" : "20",
"region" : "4"
},
"process" : {
"refresh_interval_in_millis" : 1000,
"id" : 24918,
"mlockall" : false
}
}
}
}
2、檢視節點統計資訊
GET /_nodes/stats
GET /_nodes/<node_id>/stats
GET/_nodes/stats/<metric>
該API能夠獲取節點各項指標的統計資訊,如 JVM、CPU、記憶體、磁碟等使用率情況、該節點上有多少個索引,get請求、search請求、merge 操作、refresh 和 flush 的相關統計資訊,以及快取相關的如 fielddata、query_cache、request_cache 的統計資訊,還包括了 segment 和 translog 的相關統計資訊。
總之,通過該 API,我們能夠全方位獲取到節點維度相關的各種指標資訊。對於我們排查叢集問題非常有幫助,我們還了解到騰訊雲 ES 的部分大客戶,通過定期去請求該API,將返回資訊輸出到對應的監控系統,來自己做更加細粒度的叢集監控。
該API預設是返回節點所有的統計指標資訊,如果我們需要檢視部分指標或者特定指標統計資訊,也可以在 API 中進行指定,如我們想檢視特定節點的 JVM 使用情況:
GET /_nodes/1626803143000145632/stats/jvm
返回 Response 如下:
{
"_nodes" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"cluster_name" : "es-xxx",
"nodes" : {
"fdaOV16OQPq6-AUVihmq4A" : {
"timestamp" : 1639878427713,
"name" : "1626803143000145632",
"transport_address" : "xx.0.96.22:9300",
"host" : "xx.0.96.22",
"ip" : "xx.0.96.22:9300",
"roles" : [
"master",
"ml",
"remote_cluster_client"
],
"attributes" : {
"ml.machine_memory" : "16478932992",
"rack" : "cvm_4_200003",
"xpack.installed" : "true",
"set" : "200003",
"transform.node" : "false",
"ip" : "xx.20.58.221",
"temperature" : "hot",
"ml.max_open_jobs" : "20",
"region" : "4"
},
"jvm" : {
"timestamp" : 1639878427713,
"uptime_in_millis" : 13037976328,
"mem" : {
"heap_used_in_bytes" : 214161760,
"heap_used_percent" : 2,
"heap_committed_in_bytes" : 8555069440,
"heap_max_in_bytes" : 8555069440,
"non_heap_used_in_bytes" : 178981224,
"non_heap_committed_in_bytes" : 195989504,
"pools" : {
"young" : {
"used_in_bytes" : 104047328,
"max_in_bytes" : 279183360,
"peak_used_in_bytes" : 279183360,
"peak_max_in_bytes" : 279183360
},
"survivor" : {
"used_in_bytes" : 545616,
"max_in_bytes" : 34865152,
"peak_used_in_bytes" : 34865144,
"peak_max_in_bytes" : 34865152
},
"old" : {
"used_in_bytes" : 109568816,
"max_in_bytes" : 8241020928,
"peak_used_in_bytes" : 127845408,
"peak_max_in_bytes" : 8241020928
}
}
},
"threads" : {
"count" : 41,
"peak_count" : 43
},
"gc" : {
"collectors" : {
"young" : {
"collection_count" : 4718,
"collection_time_in_millis" : 162825
},
"old" : {
"collection_count" : 3,
"collection_time_in_millis" : 359
}
}
},
"buffer_pools" : {
"direct" : {
"count" : 16,
"used_in_bytes" : 4300808,
"total_capacity_in_bytes" : 4300807
},
"mapped" : {
"count" : 0,
"used_in_bytes" : 0,
"total_capacity_in_bytes" : 0
}
},
"classes" : {
"current_loaded_count" : 21255,
"total_loaded_count" : 21361,
"total_unloaded_count" : 106
}
}
}
}
}
或者我們想看該節點上索引的 merge 統計資訊:
GET /_nodes/1626803143000145632/stats/indices/merge
返回 Response 如下:
{
"_nodes" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"cluster_name" : "es-xxx",
"nodes" : {
"fdaOV16OQPq6-AUVihmq4A" : {
"timestamp" : 1639878633590,
"name" : "1626803143000145632",
"transport_address" : "xx.0.96.22:9300",
"host" : "xx.0.96.22",
"ip" : "xx.0.96.22:9300",
"roles" : [
"master",
"ml",
"remote_cluster_client"
],
"attributes" : {
"ml.machine_memory" : "16478932992",
"rack" : "cvm_4_200003",
"xpack.installed" : "true",
"set" : "200003",
"transform.node" : "false",
"ip" : "xx.20.58.221",
"temperature" : "hot",
"ml.max_open_jobs" : "20",
"region" : "4"
},
"indices" : {
"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" : 0
}
}
}
}
}
以及檢視節點索引 segment 和 translog 統計資訊:
GET /_nodes/1626803143000145632/stats/indices/segments,translog
{
"_nodes" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"cluster_name" : "es-xxxx",
"nodes" : {
"fdaOV16OQPq6-AUVihmq4A" : {
"timestamp" : 1639878746911,
"name" : "1626803143000145632",
"transport_address" : "xx.0.96.22:9300",
"host" : "xx.0.96.22",
"ip" : "xx.0.96.22:9300",
"roles" : [
"master",
"ml",
"remote_cluster_client"
],
"attributes" : {
"ml.machine_memory" : "16478932992",
"rack" : "cvm_4_200003",
"xpack.installed" : "true",
"set" : "200003",
"transform.node" : "false",
"ip" : "xx.20.58.221",
"temperature" : "hot",
"ml.max_open_jobs" : "20",
"region" : "4"
},
"indices" : {
"segments" : {
"count" : 0,
"memory_in_bytes" : 0,
"terms_memory_in_bytes" : 0,
"stored_fields_memory_in_bytes" : 0,
"term_vectors_memory_in_bytes" : 0,
"norms_memory_in_bytes" : 0,
"points_memory_in_bytes" : 0,
"doc_values_memory_in_bytes" : 0,
"index_writer_memory_in_bytes" : 0,
"version_map_memory_in_bytes" : 0,
"fixed_bit_set_memory_in_bytes" : 0,
"max_unsafe_auto_id_timestamp" : -9223372036854775808,
"file_sizes" : { }
},
"translog" : {
"operations" : 0,
"size_in_bytes" : 0,
"uncommitted_operations" : 0,
"uncommitted_size_in_bytes" : 0,
"earliest_last_modified_age" : 0
}
}
}
}
}
也可以通過該API來檢視每個節點上所分配的索引儲存資訊:
GET /_nodes/stats/indices/store
更多靈活用法請參考【杏耀註冊】官方文件。