# Stop elasticsearch cluster safely

**URL:** <https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [February 16, 2022, 6:26am UTC](https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327 "2022-02-16T06:26:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikia.4293ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikia.4293ok/32/100119_2.png) [@vikia.4293ok](https://discuss.elastic.co/u/vikia.4293ok)\
**Post date:** [February 16, 2022, 6:26am UTC](https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327/1 "2022-02-16T06:26:48Z")

</div>

Hello, there.

If anyone has faced a similar problem, I would really appreciate your advice.

We stop/start Elasticsearch cluster in develop envrionment everyday to reduce costs.

But, sometimes, we find that some index`status is red after starting cluster.  
Primary and secondary shards is lost.

We think there is a problem with the way we stop/start and are looking for a better way.

Our environment confgiuretion is here.

================================  
Elasticserch version is 7.8.1.  
Our cluster have 3 nodes and those are default role (It's a master, it's a datanode, it`s other.).  
We run Elasticsearch in docker container and these container is running in AWS EC2.  
To stop cluster, we stop AWS EC2 Instances simply.

---

<div class="post-metadata">

**Author:** ![amitmbm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amitmbm/32/102111_2.png) [@amitmbm](https://discuss.elastic.co/u/amitmbm)\
**Post date:** [February 16, 2022, 6:37am UTC](https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327/2 "2022-02-16T06:37:16Z")

</div>

Can you share your docker configuration file? Also cluster status is recovered automatically or it remains in the RED status?

---

<div class="post-metadata">

**Author:** ![vikia.4293ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikia.4293ok/32/100119_2.png) [@vikia.4293ok](https://discuss.elastic.co/u/vikia.4293ok)\
**Post date:** [February 16, 2022, 6:57am UTC](https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327/3 "2022-02-16T06:57:15Z")

</div>

Thanks for you reply!

Our docker configuration is bellow.We don't use AWS ECS.  
※To use on ec2, we install dicovery-ec2 plugin.  
※In EFS(like a NFS), we set dictionary (don't set shards.)

```auto
docker run \
--log-driver=awslogs \
--log-opt awslogs-region=${region} \
--log-opt awslogs-group=${LogGroup} \
--log-opt awslogs-stream=${instanceid} \
--ulimit nofile=102400:102400 \
-d --restart=always \
--net host -e "ES_JAVA_OPTS=-Xms${EsJavaXmsValue} -Xmx${EsJavaXmxValue} -Dlog4j2.formatMsgNoLookups=true" \
-e cluster.name=${name} \
-e TAKE_FILE_OWNERSHIP=true \
-e cluster.initial_master_nodes=$nodenames \
-e discovery.seed_hosts=$nodenames \
-e discovery.ec2.any_group=true \
-e discovery.ec2.host_type=private_ip \
-e discovery.seed_providers=ec2 \
-e cloud.node.auto_attributes=true \
-e cluster.routing.allocation.awareness.attributes=aws_availability_zone \
-e discovery.ec2.groups=${name}\ 
discovery.ec2.availability_zones=${AvailabilityZone1},${AvailabilityZone2} \
-v /usr/share/elasticsearch/data:/usr/share/elasticsearch/data \
-v /mnt/efs:/mnt/efs

```

We use official image by elastic.([docker.elastic.co/elasticsearch/elasticsearch:7.8.1](http://docker.elastic.co/elasticsearch/elasticsearch:7.8.1))  
Our docker file install plugins and place dictionary file simply.

> Also cluster status is recovered automatically or it remains in the RED status?

Yes.  
A day goes by, and the Index never recovers...  
We re-index to recover it.

---

<div class="post-metadata">

**Author:** ![amitmbm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amitmbm/32/102111_2.png) [@amitmbm](https://discuss.elastic.co/u/amitmbm)\
**Post date:** [February 16, 2022, 8:03am UTC](https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327/4 "2022-02-16T08:03:40Z")

</div>

Do you loose all your data ie all your indices and shards when you stop and start or only few of them?

---

<div class="post-metadata">

**Author:** ![vikia.4293ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikia.4293ok/32/100119_2.png) [@vikia.4293ok](https://discuss.elastic.co/u/vikia.4293ok)\
**Post date:** [February 16, 2022, 8:25am UTC](https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327/5 "2022-02-16T08:25:56Z")

</div>

> [@amitmbm](#):
>
> Do you loose all your data ie all your indices and shards when you stop and start or only few of them?

Only few of them.  
We hava indexes of some types, but, there is no regularity in the index type of loss...

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 16, 2022, 8:35am UTC](https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327/6 "2022-02-16T08:35:44Z")

</div>

What type of instance are you using? What type of storage?

---

<div class="post-metadata">

**Author:** ![vikia.4293ok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikia.4293ok/32/100119_2.png) [@vikia.4293ok](https://discuss.elastic.co/u/vikia.4293ok)\
**Post date:** [February 16, 2022, 8:42am UTC](https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327/7 "2022-02-16T08:42:34Z")

</div>

@Christian_Dahlqvist  
Hi, thanks for replying.

> What type of instance are you using? What type of storage?

We use t3.medium for develop environment.  
EBS type is gp3.  
IOPS is 3000, throughput is 125.

---

<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 16, 2022, 8:43am UTC](https://discuss.elastic.co/t/stop-elasticsearch-cluster-safely/297327/8 "2022-03-16T08:43:28Z")

</div>

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