# Closing node

**URL:** <https://discuss.elastic.co/t/closing-node/325913>\
**Category:** Elasticsearch\
**Created:** [February 19, 2023, 12:43pm UTC](https://discuss.elastic.co/t/closing-node/325913 "2023-02-19T12:43:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![avnere](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@avnere](https://discuss.elastic.co/u/avnere)\
**Post date:** [February 19, 2023, 12:43pm UTC](https://discuss.elastic.co/t/closing-node/325913/1 "2023-02-19T12:43:04Z")

</div>

Hi,

I want to close node, and want elastic to move his to different node.  
What is the procedure for closing node? How it can be done automatically?

Thanks.

---

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [February 19, 2023, 2:14pm UTC](https://discuss.elastic.co/t/closing-node/325913/2 "2023-02-19T14:14:09Z")

</div>

If you mean that you want to remove a node from a cluster. All that should need to be done is:

1. Ensure you have another node in the cluster that can take over the load of the current cluster
2. Ensure that any data on the node you're removing has at least 1 replica on a different node
3. Shutdown the node you want to remove from the cluster

Elasticsearch should automatically handle re-distributing data across the remaining nodes in the cluster.

(The above assumes you're on an [actively supported](https://www.elastic.co/support/eol) version of Elasticsearch, as this might not be true for older versions)

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [February 19, 2023, 2:20pm UTC](https://discuss.elastic.co/t/closing-node/325913/3 "2023-02-19T14:20:19Z")

</div>

You need to exclude the node from shard allocation so the shards allocated on this node will move to other nodes.

To do that you need to have enough space in other nodes to store the shards currently on the nodes you want to exclude.

This is the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-cluster.html#cluster-shard-allocation-filtering) about cluster allocation.

You basically need to run this request and wait for the shards to be moved out from the node:

```auto
PUT _cluster/settings
{
  "persistent" : {
    "cluster.routing.allocation.exclude._ip" : "node-ip-address"
  }
}

```

---

<div class="post-metadata">

**Author:** ![avnere](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@avnere](https://discuss.elastic.co/u/avnere)\
**Post date:** [February 19, 2023, 2:21pm UTC](https://discuss.elastic.co/t/closing-node/325913/4 "2023-02-19T14:21:44Z")

</div>

I am not using replicas.  
I am closing the node by pkill -F pid.  
After doing it I am getting RED health with unassigned shards. I want to avoid it.

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [February 19, 2023, 2:23pm UTC](https://discuss.elastic.co/t/closing-node/325913/5 "2023-02-19T14:23:36Z")

</div>

> [@avnere](#):
>
> I am not using replicas.  
> I am closing the node by pkill -F pid.  
> After doing it I am getting RED health with unassigned shards. I want to avoid it.

Check my previous answer, you need to remove the node from shard allocation, after the node has no more shards you can shutdown it.

---

<div class="post-metadata">

**Author:** ![avnere](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@avnere](https://discuss.elastic.co/u/avnere)\
**Post date:** [February 19, 2023, 2:25pm UTC](https://discuss.elastic.co/t/closing-node/325913/6 "2023-02-19T14:25:03Z")

</div>

> [@leandrojmp](#):
>
> remove the node from shard allocation

How can I do it?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [February 19, 2023, 2:26pm UTC](https://discuss.elastic.co/t/closing-node/325913/7 "2023-02-19T14:26:49Z")

</div>

> [@avnere](#):
>
> How can I do it?

Please, read the previous answer and check the linked documentation, the answer is there.

---

<div class="post-metadata">

**Author:** ![avnere](https://avatars.discourse-cdn.com/v4/letter/a/ba8739/32.png) [@avnere](https://discuss.elastic.co/u/avnere)\
**Post date:** [February 19, 2023, 3:53pm UTC](https://discuss.elastic.co/t/closing-node/325913/8 "2023-02-19T15:53:31Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 19, 2023, 3:53pm UTC](https://discuss.elastic.co/t/closing-node/325913/9 "2023-03-19T15:53:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
