node-tool.asciidoc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. [[node-tool]]
  2. == elasticsearch-node
  3. The `elasticsearch-node` command enables you to perform unsafe operations that
  4. risk data loss but which may help to recover some data in a disaster.
  5. [float]
  6. === Synopsis
  7. [source,shell]
  8. --------------------------------------------------
  9. bin/elasticsearch-node unsafe-bootstrap|detach-cluster
  10. [--ordinal <Integer>] [-E <KeyValuePair>]
  11. [-h, --help] ([-s, --silent] | [-v, --verbose])
  12. --------------------------------------------------
  13. [float]
  14. === Description
  15. Sometimes {es} nodes are temporarily stopped, perhaps because of the need to
  16. perform some maintenance activity or perhaps because of a hardware failure.
  17. After you resolve the temporary condition and restart the node,
  18. it will rejoin the cluster and continue normally. Depending on your
  19. configuration, your cluster may be able to remain completely available even
  20. while one or more of its nodes are stopped.
  21. Sometimes it might not be possible to restart a node after it has stopped. For
  22. example, the node's host may suffer from a hardware problem that cannot be
  23. repaired. If the cluster is still available then you can start up a fresh node
  24. on another host and {es} will bring this node into the cluster in place of the
  25. failed node.
  26. Each node stores its data in the data directories defined by the
  27. <<path-settings,`path.data` setting>>. This means that in a disaster you can
  28. also restart a node by moving its data directories to another host, presuming
  29. that those data directories can be recovered from the faulty host.
  30. {es} <<modules-discovery-quorums,requires a response from a majority of the
  31. master-eligible nodes>> in order to elect a master and to update the cluster
  32. state. This means that if you have three master-eligible nodes then the cluster
  33. will remain available even if one of them has failed. However if two of the
  34. three master-eligible nodes fail then the cluster will be unavailable until at
  35. least one of them is restarted.
  36. In very rare circumstances it may not be possible to restart enough nodes to
  37. restore the cluster's availability. If such a disaster occurs, you should
  38. build a new cluster from a recent snapshot and re-import any data that was
  39. ingested since that snapshot was taken.
  40. However, if the disaster is serious enough then it may not be possible to
  41. recover from a recent snapshot either. Unfortunately in this case there is no
  42. way forward that does not risk data loss, but it may be possible to use the
  43. `elasticsearch-node` tool to construct a new cluster that contains some of the
  44. data from the failed cluster.
  45. This tool has two modes:
  46. * `elastisearch-node unsafe-bootstap` can be used if there is at least one
  47. remaining master-eligible node. It forces one of the remaining nodes to form
  48. a brand-new cluster on its own, using its local copy of the cluster metadata.
  49. This is known as _unsafe cluster bootstrapping_.
  50. * `elastisearch-node detach-cluster` enables you to move nodes from one cluster
  51. to another. This can be used to move nodes into the new cluster created with
  52. the `elastisearch-node unsafe-bootstap` command. If unsafe cluster bootstrapping was not
  53. possible, it also enables you to
  54. move nodes into a brand-new cluster.
  55. [[node-tool-unsafe-bootstrap]]
  56. [float]
  57. ==== Unsafe cluster bootstrapping
  58. If there is at least one remaining master-eligible node, but it is not possible
  59. to restart a majority of them, then the `elasticsearch-node unsafe-bootstrap`
  60. command will unsafely override the cluster's <<modules-discovery-voting,voting
  61. configuration>> as if performing another
  62. <<modules-discovery-bootstrap-cluster,cluster bootstrapping process>>.
  63. The target node can then form a new cluster on its own by using
  64. the cluster metadata held locally on the target node.
  65. [WARNING]
  66. These steps can lead to arbitrary data loss since the target node may not hold the latest cluster
  67. metadata, and this out-of-date metadata may make it impossible to use some or
  68. all of the indices in the cluster.
  69. Since unsafe bootstrapping forms a new cluster containing a single node, once
  70. you have run it you must use the <<node-tool-detach-cluster,`elasticsearch-node
  71. detach-cluster` tool>> to migrate any other surviving nodes from the failed
  72. cluster into this new cluster.
  73. When you run the `elasticsearch-node unsafe-bootstrap` tool it will analyse the
  74. state of the node and ask for confirmation before taking any action. Before
  75. asking for confirmation it reports the term and version of the cluster state on
  76. the node on which it runs as follows:
  77. [source,txt]
  78. ----
  79. Current node cluster state (term, version) pair is (4, 12)
  80. ----
  81. If you have a choice of nodes on which to run this tool then you should choose
  82. one with a term that is as large as possible. If there is more than one
  83. node with the same term, pick the one with the largest version.
  84. This information identifies the node with the freshest cluster state, which minimizes the
  85. quantity of data that might be lost. For example, if the first node reports
  86. `(4, 12)` and a second node reports `(5, 3)`, then the second node is preferred
  87. since its term is larger. However if the second node reports `(3, 17)` then
  88. the first node is preferred since its term is larger. If the second node
  89. reports `(4, 10)` then it has the same term as the first node, but has a
  90. smaller version, so the first node is preferred.
  91. [WARNING]
  92. Running this command can lead to arbitrary data loss. Only run this tool if you
  93. understand and accept the possible consequences and have exhausted all other
  94. possibilities for recovery of your cluster.
  95. The sequence of operations for using this tool are as follows:
  96. 1. Make sure you have really lost access to at least half of the
  97. master-eligible nodes in the cluster, and they cannot be repaired or recovered
  98. by moving their data paths to healthy hardware.
  99. 2. Stop **all** remaining nodes.
  100. 3. Choose one of the remaining master-eligible nodes to become the new elected
  101. master as described above.
  102. 4. On this node, run the `elasticsearch-node unsafe-bootstrap` command as shown
  103. below. Verify that the tool reported `Master node was successfully
  104. bootstrapped`.
  105. 5. Start this node and verify that it is elected as the master node.
  106. 6. Run the <<node-tool-detach-cluster,`elasticsearch-node detach-cluster`
  107. tool>>, described below, on every other node in the cluster.
  108. 7. Start all other nodes and verify that each one joins the cluster.
  109. 8. Investigate the data in the cluster to discover if any was lost during this
  110. process.
  111. When you run the tool it will make sure that the node that is being used to
  112. bootstrap the cluster is not running. It is important that all other
  113. master-eligible nodes are also stopped while this tool is running, but the tool
  114. does not check this.
  115. The message `Master node was successfully bootstrapped` does not mean that
  116. there has been no data loss, it just means that tool was able to complete its
  117. job.
  118. [[node-tool-detach-cluster]]
  119. [float]
  120. ==== Detaching nodes from their cluster
  121. It is unsafe for nodes to move between clusters, because different clusters
  122. have completely different cluster metadata. There is no way to safely merge the
  123. metadata from two clusters together.
  124. To protect against inadvertently joining the wrong cluster, each cluster
  125. creates a unique identifier, known as the _cluster UUID_, when it first starts
  126. up. Every node records the UUID of its cluster and refuses to join a
  127. cluster with a different UUID.
  128. However, if a node's cluster has permanently failed then it may be desirable to
  129. try and move it into a new cluster. The `elasticsearch-node detach-cluster`
  130. command lets you detach a node from its cluster by resetting its cluster UUID.
  131. It can then join another cluster with a different UUID.
  132. For example, after unsafe cluster bootstrapping you will need to detach all the
  133. other surviving nodes from their old cluster so they can join the new,
  134. unsafely-bootstrapped cluster.
  135. Unsafe cluster bootstrapping is only possible if there is at least one
  136. surviving master-eligible node. If there are no remaining master-eligible nodes
  137. then the cluster metadata is completely lost. However, the individual data
  138. nodes also contain a copy of the index metadata corresponding with their
  139. shards. This sometimes allows a new cluster to import these shards as
  140. <<modules-gateway-dangling-indices,dangling indices>>. You can sometimes
  141. recover some indices after the loss of all master-eligible nodes in a cluster
  142. by creating a new cluster and then using the `elasticsearch-node
  143. detach-cluster` command to move any surviving nodes into this new cluster.
  144. There is a risk of data loss when importing a dangling index because data nodes
  145. may not have the most recent copy of the index metadata and do not have any
  146. information about <<docs-replication,which shard copies are in-sync>>. This
  147. means that a stale shard copy may be selected to be the primary, and some of
  148. the shards may be incompatible with the imported mapping.
  149. [WARNING]
  150. Execution of this command can lead to arbitrary data loss. Only run this tool
  151. if you understand and accept the possible consequences and have exhausted all
  152. other possibilities for recovery of your cluster.
  153. The sequence of operations for using this tool are as follows:
  154. 1. Make sure you have really lost access to every one of the master-eligible
  155. nodes in the cluster, and they cannot be repaired or recovered by moving their
  156. data paths to healthy hardware.
  157. 2. Start a new cluster and verify that it is healthy. This cluster may comprise
  158. one or more brand-new master-eligible nodes, or may be an unsafely-bootstrapped
  159. cluster formed as described above.
  160. 3. Stop **all** remaining data nodes.
  161. 4. On each data node, run the `elasticsearch-node detach-cluster` tool as shown
  162. below. Verify that the tool reported `Node was successfully detached from the
  163. cluster`.
  164. 5. If necessary, configure each data node to
  165. <<modules-discovery-hosts-providers,discover the new cluster>>.
  166. 6. Start each data node and verify that it has joined the new cluster.
  167. 7. Wait for all recoveries to have completed, and investigate the data in the
  168. cluster to discover if any was lost during this process.
  169. The message `Node was successfully detached from the cluster` does not mean
  170. that there has been no data loss, it just means that tool was able to complete
  171. its job.
  172. [float]
  173. === Parameters
  174. `unsafe-bootstrap`:: Specifies to unsafely bootstrap this node as a new
  175. one-node cluster.
  176. `detach-cluster`:: Specifies to unsafely detach this node from its cluster so
  177. it can join a different cluster.
  178. `--ordinal <Integer>`:: If there is <<max-local-storage-nodes,more than one
  179. node sharing a data path>> then this specifies which node to target. Defaults
  180. to `0`, meaning to use the first node in the data path.
  181. `-E <KeyValuePair>`:: Configures a setting.
  182. `-h, --help`:: Returns all of the command parameters.
  183. `-s, --silent`:: Shows minimal output.
  184. `-v, --verbose`:: Shows verbose output.
  185. [float]
  186. === Examples
  187. [float]
  188. ==== Unsafe cluster bootstrapping
  189. Suppose your cluster had five master-eligible nodes and you have permanently
  190. lost three of them, leaving two nodes remaining.
  191. * Run the tool on the first remaining node, but answer `n` at the confirmation
  192. step.
  193. [source,txt]
  194. ----
  195. node_1$ ./bin/elasticsearch-node unsafe-bootstrap
  196. WARNING: Elasticsearch MUST be stopped before running this tool.
  197. Current node cluster state (term, version) pair is (4, 12)
  198. You should only run this tool if you have permanently lost half or more
  199. of the master-eligible nodes in this cluster, and you cannot restore the
  200. cluster from a snapshot. This tool can cause arbitrary data loss and its
  201. use should be your last resort. If you have multiple surviving master
  202. eligible nodes, you should run this tool on the node with the highest
  203. cluster state (term, version) pair.
  204. Do you want to proceed?
  205. Confirm [y/N] n
  206. ----
  207. * Run the tool on the second remaining node, and again answer `n` at the
  208. confirmation step.
  209. [source,txt]
  210. ----
  211. node_2$ ./bin/elasticsearch-node unsafe-bootstrap
  212. WARNING: Elasticsearch MUST be stopped before running this tool.
  213. Current node cluster state (term, version) pair is (5, 3)
  214. You should only run this tool if you have permanently lost half or more
  215. of the master-eligible nodes in this cluster, and you cannot restore the
  216. cluster from a snapshot. This tool can cause arbitrary data loss and its
  217. use should be your last resort. If you have multiple surviving master
  218. eligible nodes, you should run this tool on the node with the highest
  219. cluster state (term, version) pair.
  220. Do you want to proceed?
  221. Confirm [y/N] n
  222. ----
  223. * Since the second node has a greater term it has a fresher cluster state, so
  224. it is better to unsafely bootstrap the cluster using this node:
  225. [source,txt]
  226. ----
  227. node_2$ ./bin/elasticsearch-node unsafe-bootstrap
  228. WARNING: Elasticsearch MUST be stopped before running this tool.
  229. Current node cluster state (term, version) pair is (5, 3)
  230. You should only run this tool if you have permanently lost half or more
  231. of the master-eligible nodes in this cluster, and you cannot restore the
  232. cluster from a snapshot. This tool can cause arbitrary data loss and its
  233. use should be your last resort. If you have multiple surviving master
  234. eligible nodes, you should run this tool on the node with the highest
  235. cluster state (term, version) pair.
  236. Do you want to proceed?
  237. Confirm [y/N] y
  238. Master node was successfully bootstrapped
  239. ----
  240. [float]
  241. ==== Detaching nodes from their cluster
  242. After unsafely bootstrapping a new cluster, run the `elasticsearch-node
  243. detach-cluster` command to detach all remaining nodes from the failed cluster
  244. so they can join the new cluster:
  245. [source, txt]
  246. ----
  247. node_3$ ./bin/elasticsearch-node detach-cluster
  248. WARNING: Elasticsearch MUST be stopped before running this tool.
  249. You should only run this tool if you have permanently lost all of the
  250. master-eligible nodes in this cluster and you cannot restore the cluster
  251. from a snapshot, or you have already unsafely bootstrapped a new cluster
  252. by running `elasticsearch-node unsafe-bootstrap` on a master-eligible
  253. node that belonged to the same cluster as this node. This tool can cause
  254. arbitrary data loss and its use should be your last resort.
  255. Do you want to proceed?
  256. Confirm [y/N] y
  257. Node was successfully detached from the cluster
  258. ----