GET _cat/nodes?vGET _cluster/health?pretty
现在有两个节点node1/node2
1.副本数设置为0
PUT _all/_settings
{
"index.number_of_replicas": 0
}2.排除不需要的节点
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.exclude._name": "node2"
}
}3. 监控迁移进度(可反复执行,直到完成)
确认 niewj2 不再出现在结果里,或者它对应的分片 state 都是 STARTED 且 node 已经变成 niewjGET _cat/shards?v&h=index,shard,prirep,state,node
index shard prirep state node
kibana_sample_data_flights-new 0 p STARTED node1
recruit_wutong_application_index 0 p STARTED node1
.ds-.logs-deprecation.elasticsearch-default-2025.09.24-000007 0 p STARTED node1
.ds-kibana_sample_data_logs-2025.02.25-000001 0 p STARTED node1
kibana_sample_data_ecommerce 0 p STARTED node1
.internal.alerts-ml.anomaly-detection-health.alerts-default-000001 0 p STARTED node1
movies 0 p STARTED node1
books 0 p STARTED node1
.kibana-observability-ai-assistant-conversations-000001 0 p STARTED node1
my_index 0 p STARTED node1
.ds-.kibana-event-log-ds-2025.03.01-000002 0 p STARTED node1
.internal.alerts-observability.logs.alerts-default-000001 0 p STARTED node1
.async-search 0 p STARTED node1
movies-new 0 p STARTED node14.查看集群状态
GET _cluster/health
{
"cluster_name": "clusternie",
"status": "green",
"timed_out": false,
"number_of_nodes": 2,
"number_of_data_nodes": 2,
"active_primary_shards": 57,
"active_shards": 57,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"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": 100
}5. 停止并禁用 node2 服务(需要在服务器终端执行)
sudo systemctl stop es2.service
sudo systemctl disable es2.service6.修改node1的配置文件elasticsearch.yml
discovery.seed_hosts: ["127.0.0.1:9300"] # 只保留 node1 的 transport 端口
cluster.initial_master_nodes: ["node1"] # 只保留 node17. 重启node1
sudo systemctl restart elasticsearch
8.最后确认单节点 Green 状态
GET _cluster/health
"status" : "green","number_of_nodes" : 1
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用。你还可以使用@来通知其他用户。