| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 | [[restart-cluster]]== Full-cluster restart and rolling restartThere may be {ref}/configuring-tls.html#tls-transport[situations where you wantto perform a full-cluster restart] or a rolling restart. In the case of<<restart-cluster-full,full-cluster restart>>, you shut down and restart all thenodes in the cluster while in the case of<<restart-cluster-rolling,rolling restart>>, you shut down only one node at atime, so the service remains uninterrupted.[discrete][[restart-cluster-full]]=== Full-cluster restart// tag::disable_shard_alloc[]. *Disable shard allocation.*+--include::{es-repo-dir}/upgrade/disable-shard-alloc.asciidoc[]--// end::disable_shard_alloc[]// tag::stop_indexing[]. *Stop indexing and perform a flush.*+--Performing a <<indices-flush, flush>> speeds up shard recovery.[source,console]--------------------------------------------------POST /_flush----------------------------------------------------// end::stop_indexing[]//tag::stop_ml[]. *Temporarily stop the tasks associated with active {ml} jobs and {dfeeds}.* (Optional)+--{ml-cap} features require specific {subscriptions}[subscriptions].You have two options to handle {ml} jobs and {dfeeds} when you shut down acluster:* Temporarily halt the tasks associated with your {ml} jobs and {dfeeds} andprevent new jobs from opening by using the<<ml-set-upgrade-mode,set upgrade mode API>>:+[source,console]--------------------------------------------------POST _ml/set_upgrade_mode?enabled=true--------------------------------------------------// TEST+When you disable upgrade mode, the jobs resume using the last model state thatwas automatically saved. This option avoids the overhead of managing active jobsduring the shutdown and is faster than explicitly stopping {dfeeds} and closingjobs.* {ml-docs}/stopping-ml.html[Stop all {dfeeds} and close all jobs]. This optionsaves the model state at the time of closure. When you reopen the jobs after thecluster restart, they use the exact same model. However, saving the latest modelstate takes longer than using upgrade mode, especially if you have a lot of jobsor jobs with large model states.--// end::stop_ml[]. *Shut down all nodes.*+--include::{es-repo-dir}/upgrade/shut-down-node.asciidoc[]--. *Perform any needed changes.*. *Restart nodes.*+--If you have dedicated master nodes, start them first and wait for them toform a cluster and elect a master before proceeding with your data nodes.You can check progress by looking at the logs.As soon as enough master-eligible nodes have discovered each other, they form acluster and elect a master. At that point, you can usethe <<cat-health, cat health>> and <<cat-nodes,cat nodes>> APIs to monitor nodesjoining the cluster:[source,console]--------------------------------------------------GET _cat/healthGET _cat/nodes--------------------------------------------------// TEST[continued]The `status` column returned by `_cat/health` shows the health of each nodein the cluster: `red`, `yellow`, or `green`.--. *Wait for all nodes to join the cluster and report a status of yellow.*+--When a node joins the cluster, it begins to recover any primary shards thatare stored locally. The <<cat-health,`_cat/health`>> API initially reportsa `status` of `red`, indicating that not all primary shards have been allocated.Once a node recovers its local shards, the cluster `status` switches to`yellow`, indicating that all primary shards have been recovered, but not allreplica shards are allocated. This is to be expected because you have not yetre-enabled allocation. Delaying the allocation of replicas until all nodesare `yellow` allows the master to allocate replicas to nodes thatalready have local shard copies.--. *Re-enable allocation.*+--When all nodes have joined the cluster and recovered their primary shards,re-enable allocation by restoring `cluster.routing.allocation.enable` to itsdefault:[source,console]------------------------------------------------------PUT _cluster/settings{  "persistent": {    "cluster.routing.allocation.enable": null  }}------------------------------------------------------// TEST[continued]Once allocation is re-enabled, the cluster starts allocating replica shards tothe data nodes. At this point it is safe to resume indexing and searching,but your cluster will recover more quickly if you can wait until all primaryand replica shards have been successfully allocated and the status of all nodesis `green`.You can monitor progress with the <<cat-health,`_cat/health`>> and<<cat-recovery,`_cat/recovery`>> APIs:[source,console]--------------------------------------------------GET _cat/healthGET _cat/recovery--------------------------------------------------// TEST[continued]--// tag::restart_ml[]. *Restart machine learning jobs.* (Optional)+--If you temporarily halted the tasks associated with your {ml} jobs, use the<<ml-set-upgrade-mode,set upgrade mode API>> to return them to active states:[source,console]--------------------------------------------------POST _ml/set_upgrade_mode?enabled=false--------------------------------------------------// TEST[continued]If you closed all {ml} jobs before stopping the nodes, open the jobs and startthe datafeeds from {kib} or with the <<ml-open-job,open jobs>> and<<ml-start-datafeed,start datafeed>> APIs.--// end::restart_ml[][discrete][[restart-cluster-rolling]]=== Rolling restartinclude::{es-repo-dir}/setup/restart-cluster.asciidoc[tag=disable_shard_alloc]include::{es-repo-dir}/setup/restart-cluster.asciidoc[tag=stop_indexing]include::{es-repo-dir}/setup/restart-cluster.asciidoc[tag=stop_ml]+--* If you perform a rolling restart, you can also leave your machine learningjobs running. When you shut down a machine learning node, its jobs automaticallymove to another node and restore the model states. This option enables your jobsto continue running during the shutdown but it puts increased load on thecluster.--. *Shut down a single node in case of rolling restart.*+--include::{es-repo-dir}/upgrade/shut-down-node.asciidoc[]--. *Perform any needed changes.*. *Restart the node you changed.*+--Start the node and confirm that it joins the cluster by checking the log file orby submitting a `_cat/nodes` request:[source,console]--------------------------------------------------GET _cat/nodes--------------------------------------------------// TEST[continued]--. *Reenable shard allocation.*+--Once the node has joined the cluster, remove the`cluster.routing.allocation.enable` setting to enable shard allocation and startusing the node:[source,console]--------------------------------------------------PUT _cluster/settings{  "persistent": {    "cluster.routing.allocation.enable": null  }}--------------------------------------------------// TEST[continued]--. *Repeat in case of rolling restart.*+--When the node has recovered and the cluster is stable, repeat these stepsfor each node that needs to be changed.--include::{es-repo-dir}/setup/restart-cluster.asciidoc[tag=restart_ml]
 |