1
0

restart-cluster.asciidoc 7.0 KB

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