restart-cluster.asciidoc 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. [[restart-cluster]]
  2. == Full-cluster restart and rolling restart
  3. There may be <<security-basic-setup,situations where you want
  4. to perform a full-cluster restart>> or a rolling restart. In the case of
  5. <<restart-cluster-full,full-cluster restart>>, you shut down and restart all the
  6. nodes in the cluster while in the case of
  7. <<restart-cluster-rolling,rolling restart>>, you shut down only one node at a
  8. time, so the service remains uninterrupted.
  9. [WARNING]
  10. ====
  11. Nodes exceeding the low watermark threshold will be slow to restart. Reduce the disk
  12. usage below the <<cluster-routing-watermark-low,low watermark>> before to restarting nodes.
  13. ====
  14. [discrete]
  15. [[restart-cluster-full]]
  16. === Full-cluster restart
  17. // tag::disable_shard_alloc[]
  18. . *Disable shard allocation.*
  19. +
  20. --
  21. include::{es-repo-dir}/upgrade/disable-shard-alloc.asciidoc[]
  22. --
  23. // end::disable_shard_alloc[]
  24. . *Stop indexing and perform a flush.*
  25. +
  26. --
  27. Performing a <<indices-flush, flush>> speeds up shard recovery.
  28. [source,console]
  29. --------------------------------------------------
  30. POST /_flush
  31. --------------------------------------------------
  32. --
  33. //tag::stop_ml[]
  34. . *Temporarily stop the tasks associated with active {ml} jobs and {dfeeds}.* (Optional)
  35. +
  36. --
  37. {ml-cap} features require specific {subscriptions}[subscriptions].
  38. You have two options to handle {ml} jobs and {dfeeds} when you shut down a
  39. cluster:
  40. * Temporarily halt the tasks associated with your {ml} jobs and {dfeeds} and
  41. prevent new jobs from opening by using the
  42. <<ml-set-upgrade-mode,set upgrade mode API>>:
  43. +
  44. [source,console]
  45. --------------------------------------------------
  46. POST _ml/set_upgrade_mode?enabled=true
  47. --------------------------------------------------
  48. // TEST
  49. +
  50. When you disable upgrade mode, the jobs resume using the last model state that
  51. was automatically saved. This option avoids the overhead of managing active jobs
  52. during the shutdown and is faster than explicitly stopping {dfeeds} and closing
  53. jobs.
  54. * {ml-docs}/stopping-ml.html[Stop all {dfeeds} and close all jobs]. This option
  55. saves the model state at the time of closure. When you reopen the jobs after the
  56. cluster restart, they use the exact same model. However, saving the latest model
  57. state takes longer than using upgrade mode, especially if you have a lot of jobs
  58. or jobs with large model states.
  59. --
  60. // end::stop_ml[]
  61. . *Shut down all nodes.*
  62. +
  63. --
  64. include::{es-repo-dir}/upgrade/shut-down-node.asciidoc[]
  65. --
  66. . *Perform any needed changes.*
  67. . *Restart nodes.*
  68. +
  69. --
  70. If you have dedicated master nodes, start them first and wait for them to
  71. form a cluster and elect a master before proceeding with your data nodes.
  72. You can check progress by looking at the logs.
  73. As soon as enough master-eligible nodes have discovered each other, they form a
  74. cluster and elect a master. At that point, you can use
  75. the <<cat-health, cat health>> and <<cat-nodes,cat nodes>> APIs to monitor nodes
  76. joining the cluster:
  77. [source,console]
  78. --------------------------------------------------
  79. GET _cat/health
  80. GET _cat/nodes
  81. --------------------------------------------------
  82. // TEST[continued]
  83. The `status` column returned by `_cat/health` shows the health of each node
  84. in the cluster: `red`, `yellow`, or `green`.
  85. --
  86. . *Wait for all nodes to join the cluster and report a status of yellow.*
  87. +
  88. --
  89. When a node joins the cluster, it begins to recover any primary shards that
  90. are stored locally. The <<cat-health,`_cat/health`>> API initially reports
  91. a `status` of `red`, indicating that not all primary shards have been allocated.
  92. Once a node recovers its local shards, the cluster `status` switches to
  93. `yellow`, indicating that all primary shards have been recovered, but not all
  94. replica shards are allocated. This is to be expected because you have not yet
  95. re-enabled allocation. Delaying the allocation of replicas until all nodes
  96. are `yellow` allows the master to allocate replicas to nodes that
  97. already have local shard copies.
  98. --
  99. . *Re-enable allocation.*
  100. +
  101. --
  102. When all nodes have joined the cluster and recovered their primary shards,
  103. re-enable allocation by restoring `cluster.routing.allocation.enable` to its
  104. default:
  105. [source,console]
  106. ------------------------------------------------------
  107. PUT _cluster/settings
  108. {
  109. "persistent": {
  110. "cluster.routing.allocation.enable": null
  111. }
  112. }
  113. ------------------------------------------------------
  114. // TEST[continued]
  115. Once allocation is re-enabled, the cluster starts allocating replica shards to
  116. the data nodes. At this point it is safe to resume indexing and searching,
  117. but your cluster will recover more quickly if you can wait until all primary
  118. and replica shards have been successfully allocated and the status of all nodes
  119. is `green`.
  120. You can monitor progress with the <<cat-health,`_cat/health`>> and
  121. <<cat-recovery,`_cat/recovery`>> APIs:
  122. [source,console]
  123. --------------------------------------------------
  124. GET _cat/health
  125. GET _cat/recovery
  126. --------------------------------------------------
  127. // TEST[continued]
  128. --
  129. // tag::restart_ml[]
  130. . *Restart machine learning jobs.* (Optional)
  131. +
  132. --
  133. If you temporarily halted the tasks associated with your {ml} jobs, use the
  134. <<ml-set-upgrade-mode,set upgrade mode API>> to return them to active states:
  135. [source,console]
  136. --------------------------------------------------
  137. POST _ml/set_upgrade_mode?enabled=false
  138. --------------------------------------------------
  139. // TEST[continued]
  140. If you closed all {ml} jobs before stopping the nodes, open the jobs and start
  141. the datafeeds from {kib} or with the <<ml-open-job,open jobs>> and
  142. <<ml-start-datafeed,start datafeed>> APIs.
  143. --
  144. // end::restart_ml[]
  145. [discrete]
  146. [[restart-cluster-rolling]]
  147. === Rolling restart
  148. include::{es-repo-dir}/setup/restart-cluster.asciidoc[tag=disable_shard_alloc]
  149. . *Stop non-essential indexing and perform a flush.* (Optional)
  150. +
  151. --
  152. While you can continue indexing during the rolling restart, shard recovery
  153. can be faster if you temporarily stop non-essential indexing and perform a
  154. <<indices-flush, flush>>.
  155. [source,console]
  156. --------------------------------------------------
  157. POST /_flush
  158. --------------------------------------------------
  159. --
  160. include::{es-repo-dir}/setup/restart-cluster.asciidoc[tag=stop_ml]
  161. +
  162. --
  163. * If you perform a rolling restart, you can also leave your machine learning
  164. jobs running. When you shut down a machine learning node, its jobs automatically
  165. move to another node and restore the model states. This option enables your jobs
  166. to continue running during the shutdown but it puts increased load on the
  167. cluster.
  168. --
  169. . *Shut down a single node in case of rolling restart.*
  170. +
  171. --
  172. include::{es-repo-dir}/upgrade/shut-down-node.asciidoc[]
  173. --
  174. . *Perform any needed changes.*
  175. . *Restart the node you changed.*
  176. +
  177. --
  178. Start the node and confirm that it joins the cluster by checking the log file or
  179. by submitting a `_cat/nodes` request:
  180. [source,console]
  181. --------------------------------------------------
  182. GET _cat/nodes
  183. --------------------------------------------------
  184. // TEST[continued]
  185. --
  186. . *Reenable shard allocation.*
  187. +
  188. --
  189. For data nodes, once the node has joined the cluster, remove the
  190. `cluster.routing.allocation.enable` setting to enable shard allocation and start
  191. using the node:
  192. [source,console]
  193. --------------------------------------------------
  194. PUT _cluster/settings
  195. {
  196. "persistent": {
  197. "cluster.routing.allocation.enable": null
  198. }
  199. }
  200. --------------------------------------------------
  201. // TEST[continued]
  202. --
  203. . *Repeat in case of rolling restart.*
  204. +
  205. --
  206. When the node has recovered and the cluster is stable, repeat these steps
  207. for each node that needs to be changed.
  208. --
  209. include::{es-repo-dir}/setup/restart-cluster.asciidoc[tag=restart_ml]