Skip to content

Commit a09c826

Browse files
Node repurpose tool docs
Improved documentation for node repurpose tool.
1 parent 02dd1d3 commit a09c826

File tree

3 files changed

+123
-110
lines changed

3 files changed

+123
-110
lines changed

docs/reference/commands/node-tool.asciidoc

Lines changed: 113 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,85 @@
11
[[node-tool]]
22
== elasticsearch-node
33

4-
The `elasticsearch-node` command enables you to perform unsafe operations that
5-
risk data loss but which may help to recover some data in a disaster and
6-
repurpose nodes into new roles.
4+
The `elasticsearch-node` command enables you to perform certain unsafe
5+
operations on a node that are only possible while it is shut down. This command
6+
allows you to adjust the <<modules-node,role>> of a node and may be able to
7+
recover some data after a disaster.
78

89
[float]
910
=== Synopsis
1011

1112
[source,shell]
1213
--------------------------------------------------
13-
bin/elasticsearch-node unsafe-bootstrap|detach-cluster|repurpose
14+
bin/elasticsearch-node repurpose|unsafe-bootstrap|detach-cluster
1415
[--ordinal <Integer>] [-E <KeyValuePair>]
1516
[-h, --help] ([-s, --silent] | [-v, --verbose])
1617
--------------------------------------------------
1718

1819
[float]
1920
=== Description
2021

22+
This tool has three modes, described in the following sections:
23+
24+
* `elasticsearch-node repurpose` reports on and performs necessary index meta-data
25+
and shard data cleanup when a node is repurposed to no longer hold <<data-node,data>> or be
26+
<<master-node,master-eligible>>.
27+
28+
* `elasticsearch-node unsafe-bootstrap` can be used to perform _unsafe cluster bootstrapping_.
29+
It forces one of the nodes to form a brand-new cluster on its own, using its local copy of
30+
the cluster metadata.
31+
32+
* `elasticsearch-node detach-cluster` enables you to move nodes from one cluster to another.
33+
This can be used to move nodes into a new cluster created with the `elasticsearch-node unsafe-bootstap`
34+
command. If unsafe cluster bootstrapping was not possible, it also enables you to move nodes
35+
into a brand-new cluster.
36+
37+
[[node-tool-repurpose]]
38+
[float]
39+
==== Changing the role of a node
40+
41+
Changing the role of a node can lead to excess on-disk data that will prevent a node from starting. The
42+
`elasticsearch-node` tool should be used to cleanup excess data after certain role changes, detailed in the following.
43+
44+
Two types of on-disk index data can need cleanup:
45+
46+
* Index metadata: information about indices like name, mapping and more.
47+
* Shard data: primary or replica shards allocated to this node.
48+
49+
Repurposing an existing node by changing node.master or node.data to false can leave lingering on-disk metadata and
50+
shard data around, which will not be accessible by the node's new role. Beside storing non-accessible data, this could lead
51+
to situations where <<modules-gateway-dangling-indices,dangling indices>> are imported even though the node might not
52+
be able to host any shards, leading to a red cluster health. To avoid this,
53+
54+
* nodes with on-disk shard data and `node.data` set to false will refuse to start
55+
* nodes with on-disk index/shard data and both `node.master` and `node.data set` to false will refuse to start
56+
57+
The `elasticsearch-node repurpose` tool allows cleaning up such excess data, enabling nodes to start
58+
after being repurposed. The cleanup that will be done are:
59+
60+
* `node.data=false` and `node.master=false`: both index metadata and shard data will be cleaned up.
61+
* `node.data=false` and `node.master=true` : only shard data will be cleaned up.
62+
* Any other combinations: no cleanup necessary (will be reported by the tool).
63+
64+
[WARNING]
65+
Running this command can lead to data loss for the indices mentioned if the data
66+
contained is not available on other nodes in the cluster. Only run this tool if you
67+
understand and accept the possible consequences.
68+
69+
The intended use is:
70+
71+
. Stop the node
72+
. Update node settings (node.master/node.data) to desired new role
73+
. Run `elasticsearch-node repurpose` on the node
74+
. Start the node
75+
76+
The tool provides a summary of the the cleanup necessary and asks for confirmation before
77+
making any changes. Use the verbose (-v) option to get detailed information on indices and
78+
shards affected.
79+
80+
[float]
81+
==== Recovering data after a disaster
82+
2183
Sometimes {es} nodes are temporarily stopped, perhaps because of the need to
2284
perform some maintenance activity or perhaps because of a hardware failure.
2385
After you resolve the temporary condition and restart the node,
@@ -54,31 +116,10 @@ way forward that does not risk data loss, but it may be possible to use the
54116
`elasticsearch-node` tool to construct a new cluster that contains some of the
55117
data from the failed cluster.
56118

57-
If a node that previously held data or were master-eligible is repurposed into
58-
being an either no-master or no-data node, cleanup of data (e.g. shard data) that
59-
is no longer needed on the node is necessary to avoid future problems. The
60-
`elasticsearch-node` tool should be used to do such cleanup.
61-
62-
This tool has three modes:
63-
64-
* `elasticsearch-node unsafe-bootstap` can be used if there is at least one
65-
remaining master-eligible node. It forces one of the remaining nodes to form
66-
a brand-new cluster on its own, using its local copy of the cluster metadata.
67-
This is known as _unsafe cluster bootstrapping_.
68-
69-
* `elasticsearch-node detach-cluster` enables you to move nodes from one cluster
70-
to another. This can be used to move nodes into the new cluster created with
71-
the `elastisearch-node unsafe-bootstap` command. If unsafe cluster bootstrapping was not
72-
possible, it also enables you to
73-
move nodes into a brand-new cluster.
74-
75-
* `elasticsearch-node repurpose` reports on and performs necessary index meta-data
76-
and shard data cleanup when a node is repurposed to not hold data or be
77-
master-eligible.
78119

79120
[[node-tool-unsafe-bootstrap]]
80121
[float]
81-
==== Unsafe cluster bootstrapping
122+
===== Unsafe cluster bootstrapping
82123

83124
If there is at least one remaining master-eligible node, but it is not possible
84125
to restart a majority of them, then the `elasticsearch-node unsafe-bootstrap`
@@ -153,7 +194,7 @@ job.
153194

154195
[[node-tool-detach-cluster]]
155196
[float]
156-
==== Detaching nodes from their cluster
197+
===== Detaching nodes from their cluster
157198

158199
It is unsafe for nodes to move between clusters, because different clusters
159200
have completely different cluster metadata. There is no way to safely merge the
@@ -217,54 +258,17 @@ that there has been no data loss, it just means that tool was able to complete
217258
its job.
218259

219260

220-
[[node-tool-repurpose]]
221-
[float]
222-
==== Repurposing nodes
223-
224-
A master-eligible and data carrying node holds on-disk index data:
225-
226-
* Index metadata: information about indices like name, mapping and more.
227-
* Shard data: primary or replica shards allocated to this node.
228-
229-
Repurposing an existing node by changing node.master or node.data to false can leave lingering on-disk metadata and
230-
data around, which will not be accessible by the node's new role. Beside storing non-accessible data, this could lead
231-
to situations where <<modules-gateway-dangling-indices,dangling indices>> are imported even though the node might not
232-
be able to host any shards, leading to a red cluster health. To avoid this,
233-
234-
* nodes with on-disk shard data and node.data set to false will refuse to start
235-
* nodes with on-disk index/shard data and both node.master and node.data set to false will refuse to start
236-
237-
The `elasticsearch-node repurpose` tool allows cleaning up such excess data, enabling nodes to start
238-
after being repurposed.
239-
240-
[WARNING]
241-
Running this command can lead to data loss for the indices mentioned if the data
242-
contained is not available on other nodes in the cluster. Only run this tool if you
243-
understand and accept the possible consequences.
244-
245-
The intended use is:
246-
247-
. Stop the node
248-
. Update node settings (node.master/node.data) to desired new role
249-
. Run `elasticsearch-node repurpose` on the node
250-
. Start the node
251-
252-
The tool provides a summary of the the cleanup necessary and asks for confirmation before
253-
making any changes. Use the verbose (-v) option to get detailed information on indices and
254-
shards affected.
255-
256-
257261
[float]
258262
=== Parameters
259263

264+
`repurpose`:: Report on and cleanup excess persisted data.
265+
260266
`unsafe-bootstrap`:: Specifies to unsafely bootstrap this node as a new
261267
one-node cluster.
262268

263269
`detach-cluster`:: Specifies to unsafely detach this node from its cluster so
264270
it can join a different cluster.
265271

266-
`repurpose`:: Report on and cleanup excess persisted data.
267-
268272
`--ordinal <Integer>`:: If there is <<max-local-storage-nodes,more than one
269273
node sharing a data path>> then this specifies which node to target. Defaults
270274
to `0`, meaning to use the first node in the data path.
@@ -280,6 +284,49 @@ to `0`, meaning to use the first node in the data path.
280284
[float]
281285
=== Examples
282286

287+
[float]
288+
==== Repurposing node as master, no-data
289+
290+
In this example, a node that previously held data is repurposed as master, no-data.
291+
First update the node settings to `node.master=true` and `node.data=false`. Then run the
292+
`elasticsearch-node repurpose` command to check for and remove excess shard data:
293+
294+
[source,txt]
295+
----
296+
node$ ./bin/elasticsearch-node repurpose
297+
298+
WARNING: Elasticsearch MUST be stopped before running this tool.
299+
300+
Found 2 shards in 2 indices to clean up
301+
Use -v to see list of paths and indices affected
302+
Node is being re-purposed as master and no-data. Clean-up of shard data will be performed.
303+
Do you want to proceed?
304+
Confirm [y/N] y
305+
Node successfully repurposed to master and no-data.
306+
----
307+
308+
[float]
309+
==== Repurposing node as no-master, no-data
310+
311+
In this example, a node that previously held data is repurposed as no-master, no-data.
312+
First update the node settings to `node.master=true` and `node.data=false`. Then run the
313+
`elasticsearch-node repurpose` command to check for and remove excess index meta-data and
314+
shard data:
315+
316+
[source,txt]
317+
----
318+
node$./bin/elasticsearch-node repurpose
319+
320+
WARNING: Elasticsearch MUST be stopped before running this tool.
321+
322+
Found 2 indices (2 shards and 2 index meta data) to clean up
323+
Use -v to see list of paths and indices affected
324+
Node is being re-purposed as no-master and no-data. Clean-up of index data will be performed.
325+
Do you want to proceed?
326+
Confirm [y/N] y
327+
Node successfully repurposed to no-master and no-data.
328+
----
329+
283330
[float]
284331
==== Unsafe cluster bootstrapping
285332

@@ -381,46 +428,3 @@ Do you want to proceed?
381428
Confirm [y/N] y
382429
Node was successfully detached from the cluster
383430
----
384-
385-
[float]
386-
==== Repurposing node as master, no-data
387-
388-
In this example, a node that previously held data is repurposed as master, no-data.
389-
First update the node settings to `node.master=true` and `node.data=false`. Then run the
390-
`elasticsearch-node repurpose` command to check for and remove excess shard data:
391-
392-
[source,txt]
393-
----
394-
node$ ./bin/elasticsearch-node repurpose
395-
396-
WARNING: Elasticsearch MUST be stopped before running this tool.
397-
398-
Found 2 shards in 2 indices to clean up
399-
Use -v to see list of paths and indices affected
400-
Node is being re-purposed as master and no-data. Clean-up of shard data will be performed.
401-
Do you want to proceed?
402-
Confirm [y/N] y
403-
Node successfully repurposed to master and no-data.
404-
----
405-
406-
[float]
407-
==== Repurposing node as no-master, no-data
408-
409-
In this example, a node that previously held data is repurposed as no-master, no-data.
410-
First update the node settings to `node.master=true` and `node.data=false`. Then run the
411-
`elasticsearch-node repurpose` command to check for and remove excess index meta-data and
412-
shard data:
413-
414-
[source,txt]
415-
----
416-
node$./bin/elasticsearch-node repurpose
417-
418-
WARNING: Elasticsearch MUST be stopped before running this tool.
419-
420-
Found 2 indices (2 shards and 2 index meta data) to clean up
421-
Use -v to see list of paths and indices affected
422-
Node is being re-purposed as no-master and no-data. Clean-up of index data will be performed.
423-
Do you want to proceed?
424-
Confirm [y/N] y
425-
Node successfully repurposed to no-master and no-data.
426-
----

docs/reference/modules/node.asciidoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,15 @@ NOTE: These settings apply only when {xpack} is not installed. To create a
204204
dedicated coordinating node when {xpack} is installed, see <<modules-node-xpack,{xpack} node settings>>.
205205
endif::include-xpack[]
206206

207+
[float]
208+
[[change-node-role]]
209+
=== Changing the role of a node
210+
211+
Changing the role of a node will in some cases require cleanup of on disk data. A node will refuse to start if it has
212+
excess shard data or index metadata. The <<node-tool-repurpose,`elasticsearch-node repurpose`>> tool
213+
should be used to perform the necessary cleanup. For more details on the cleanups necessary and how to use the tool, see
214+
<<node-tool-repurpose,`elasticsearch-node repurpose`>>.
215+
207216
[float]
208217
== Node data path settings
209218

server/src/main/java/org/elasticsearch/cluster/coordination/NodeToolCli.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ public NodeToolCli() {
3636
super("A CLI tool to do unsafe cluster and index manipulations on current node",
3737
()->{});
3838
CommandLoggingConfigurator.configureLoggingWithoutConfig();
39+
subcommands.put("repurpose", new NodeRepurposeCommand());
3940
subcommands.put("unsafe-bootstrap", new UnsafeBootstrapMasterCommand());
4041
subcommands.put("detach-cluster", new DetachClusterCommand());
41-
subcommands.put("repurpose", new NodeRepurposeCommand());
4242
}
4343

4444
public static void main(String[] args) throws Exception {

0 commit comments

Comments
 (0)