查看ES集群状态:
bash
GET /_cluster/health?pretty=true
当一个节点加入集群的时候,ES会自动地尝试将分片在所有节点上进行均匀分配.
如果更多的节点加入集群,ES将试图在所有节点上均匀分配分片数量.这样每一个新加入的节点都能通过部分数据来分担负载
第二个节点发现第一个节点,并且加入集群的方式: 广播或单播.ES可同时使用两者,不过默认的配置时仅使用广播,因为单播需要已知节点列表来进行链接
获取集群节点状态信息
bash
GET /_cluster/state/master_node,nodes?pretty
#响应:
{
"cluster_name": "elasticsearch",
"cluster_uuid": "TmUQBp_9TsSG93CKys-WNg",
"master_node": "I-O0ckoiRwOqqsU2Y_4bAw",
"nodes": {
"I-O0ckoiRwOqqsU2Y_4bAw": {
"name": "hecs-21906",
"ephemeral_id": "J0VupwLZQVGQkKWsD4BknQ",
"transport_address": "127.0.0.1:9300",
"external_id": "hecs-21906",
"attributes": {
"ml.allocated_processors": "2",
"ml.max_jvm_size": "1790967808",
"ml.allocated_processors_double": "2.0",
"xpack.installed": "true",
"ml.machine_memory": "3576066048"
},
"roles": [
"data",
"data_cold",
"data_content",
"data_frozen",
"data_hot",
"data_warm",
"ingest",
"master",
"ml",
"remote_cluster_client",
"transform"
],
"version": "8.8.2"
}
},
"transport_versions": [
{
"node_id": "I-O0ckoiRwOqqsU2Y_4bAw",
"transport_version": "8080299"
}
]
}