Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add elasticsearch-node tool docs #37812

Merged
merged 31 commits into from
Mar 12, 2019
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2c61bdf
node-tool docs
Jan 24, 2019
769c93d
Rework docs
DaveCTurner Jan 24, 2019
0d3bae3
Add (term, version) instructions and example run
Jan 24, 2019
d72d1b6
Expand section on how to choose the freshest node
DaveCTurner Jan 24, 2019
af8d49f
Talk about _cluster_ bootstrapping and avoid talking about bootstrapp…
DaveCTurner Jan 25, 2019
23b3c9b
Rewording
DaveCTurner Jan 25, 2019
b76a132
Merge branch 'master' into zen2_node_tool_docs
Feb 1, 2019
f8f3bf8
Adjust messages and delimiter to 72 chars
Feb 1, 2019
ca5d84e
Update sample output of unsafe-bootstrap and add detach-cluster
Feb 1, 2019
0311381
Merge branch 'zen2_node_tool_docs' into zen2_node_tool_docs
Feb 1, 2019
6824146
Add prose around detach-cluster
DaveCTurner Mar 7, 2019
8c16ce8
Merge branch 'master' into zen2_node_tool_docs
DaveCTurner Mar 8, 2019
4446ab3
Adjust tool output to match #39811
DaveCTurner Mar 8, 2019
c147029
More docs work
DaveCTurner Mar 8, 2019
8e89ecc
Add synopsis and Parameters sections
DaveCTurner Mar 8, 2019
548ffc3
Separate examples
DaveCTurner Mar 8, 2019
4f46915
[DOCS] Sorts command reference pages
lcawl Mar 9, 2019
90662e4
Merge branch 'master' into zen2_node_tool_docs
DaveCTurner Mar 11, 2019
8e46c7d
Emphasize thjat it's a _new_ cluster formed by unsafe bootstrapping
DaveCTurner Mar 11, 2019
2f16be6
Merge branch 'zen2_node_tool_docs' of github.com:andrershov/elasticse…
DaveCTurner Mar 11, 2019
9b4dc3c
Update docs/reference/commands/node-tool.asciidoc
lcawl Mar 12, 2019
0aab27b
Update docs/reference/commands/node-tool.asciidoc
lcawl Mar 12, 2019
fc2ee02
Update docs/reference/commands/node-tool.asciidoc
lcawl Mar 12, 2019
1d0afb2
Update docs/reference/commands/node-tool.asciidoc
lcawl Mar 12, 2019
9310c3c
Update docs/reference/commands/node-tool.asciidoc
lcawl Mar 12, 2019
9042659
Update docs/reference/commands/node-tool.asciidoc
lcawl Mar 12, 2019
3de2885
Update docs/reference/commands/node-tool.asciidoc
lcawl Mar 12, 2019
020dcd5
Update docs/reference/commands/node-tool.asciidoc
lcawl Mar 12, 2019
5256211
Update docs/reference/commands/node-tool.asciidoc
lcawl Mar 12, 2019
a1f1409
Apply suggestions from code review
lcawl Mar 12, 2019
f729459
More fixes
Mar 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 86 additions & 74 deletions docs/reference/commands/node-tool.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,81 +3,90 @@
[float]
=== Background

Elasticsearch ≤ 6 leniently allows the following unsafe operations:

* Recovery from loss of a majority of master-eligible nodes.

Simply start up enough fresh master-eligible nodes to satisfy
minimum_master_nodes and the cluster will re-form. This is unsafe because there
could have been a cluster-state update that was committed without being accepted
on the surviving nodes.

* Nodes migrating from one cluster to another.

If a node is disconnected from cluster A and then discovers a distinct cluster B
then it will join cluster B. Any indices having shards on the migrating node
will be imported as dangling indices into cluster B, and these shards will be
treated as in-sync even if they were not in-sync in cluster A,
which may confusingly expose an arbitrarily stale shard to searches.

[NOTE]
When we're talking about the loss of nodes, we mean loss of storage for these
nodes. If you still have access to the nodes storage, you should copy
previous nodes data to other nodes and start Elasticsearch.

Starting with Elasticsearch 7 cluster does not really support these operations:

* A cluster that loses a majority of its master-eligible nodes will not
proceed until it finds a majority of precisely those nodes again, using the
persistent node ID for identification. New nodes will have new persistent node
IDs so will not count towards a majority.

* When node tries to join different cluster, cluster UUID comparison will fail.

There is value in supporting these operations for severe disasters,
but this is never done automatically and requires manual user intervention and
acceptance of the risk of data loss.

[float]
=== Strongly prefer restoring from the snapshot
If there is a recent snapshot available, you should use snapshot restore
instead of this tool. Snapshot restore gives you a *consistent* data back
in time. This tool usage gives you *inconsistent* data back in time.


[float]
=== Command line tool
`elasticsearch-node` tool has two modes:

* `elastisearch-node unsafe-bootstap` could be used to bootstrap master-eligible
node in the cluster, where the majority of master eligible nodes is lost, but
there is at least one master-eligible node available.
* `elastisearch-node detach-cluster` could be used to detach data nodes from
the cluster when the all master eligible nodes are lost in the cluster.
Sometimes {es} nodes are temporarily stopped, perhaps because of the need to
perform some maintenance activity or perhaps because of a hardware failure.
Once the temporary condition has been resolved you should restart the node and
andrershov marked this conversation as resolved.
Show resolved Hide resolved
it will rejoin the cluster and continue normally. Depending on your
configuration, your cluster may be able to remain completely available even
while one or more of its nodes are stopped.

Sometimes it might not be possible to restart a node after it has stopped. For
example, the node's host may suffer from a hardware problem that cannot be
repaired. If the cluster is still available then you can start up
a fresh node on another host and {es} will bring this node into the cluster in place
of the failed node.

Each node stores its data in the data directories defined by the
<<path-settings,`path.data` setting>>. This means that in a disaster you can
also restart a node by moving its data directories to another host, presuming
that those data directories can be recovered from the faulty host. Note that it
is not possible to restore the data directory from a backup because this will
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaveCTurner Not sure what you mean by "is not possible to restore the data directory from a backup".
If you copy full data folder to another node, this node will be indistinguishable from the previous node.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying the literal data directory of the dead node somewhere else, post-mortem, is ok, but restoring from a backup (which could be who-knows-how stale) is decidedly not. We occasionally see people taking backups of their data directories and causing hassle when they discover that they can't restore from such things, and I saw a risk that this paragraph might be interpreted wrongly by those kinds of people.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaveCTurner Now I see what you mean, can we re-phrase it like "Note that if you have previously taken a backup of the data folder of the stopped node, you can not restore from it, you need a data folder state at the moment this node was stopped"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trouble with the phrase "if you have previously taken a backup of the data folder" is that it suggests this is a thing you might try and do, and I think we should avoid making that suggestion. Technically you can't take a backup of the data folder: a backup from which you cannot ever safely restore isn't really a backup at all 🤔.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DaveCTurner I agree. In this case, probably it makes sense to remove this sentence at all because it's confusing?
Also, the better place for explaining that there is no reason to copy data folders because it's not possible to restore from them is on the snapshot page.

lead to data corruption. Backups of an {es} cluster can only be taken using
<<modules-snapshots>>.

Elasticsearch <<modules-discovery-quorums,requires a response from a majority
of the master-eligible nodes>> in order to elect a master and to update the
cluster state. This means that if you have three master-eligible nodes then the
cluster will remain available even if one of them has failed. However if two of
the three master-eligible nodes fail then the cluster will be unavailable until
at least one of them is restarted.

In very rare circumstances it may not be possible to restart enough nodes to
restore the cluster's availability. If such a disaster occurs then you should
andrershov marked this conversation as resolved.
Show resolved Hide resolved
build a new cluster from a recent snapshot, and re-import any data that was
andrershov marked this conversation as resolved.
Show resolved Hide resolved
ingested since that snapshot was taken.

However, if the disaster is serious enough then it may not be possible to
recover from a recent snapshot either. Unfortunately in this case there is no
way forward that does not risk data loss, but it may be possible to use the
`elasticsearch-node` tool to unsafely bring the cluster back online.

This tool has two modes, depending on whether there are any master-eligible
nodes remaining or not:

* `elastisearch-node unsafe-bootstap` can be used if there is at least one
remaining master-eligible node. It allows a remaining node to become the
elected master node without needing a response from any other nodes.

* `elastisearch-node detach-cluster` can be used if there are no remaining
master-eligible nodes. It allows you to detach any remaining data nodes from
the old, failed, cluster so they can join a new cluster.

[float]
=== Unsafe bootstrap
If you have lost the majority of master eligible nodes, you can still try to
recover the cluster using `elasticsearch-node unsafe-bootstrap`.

If there is at least one remaining master-eligible node, but it is not possible
to restart a majority of them, then the `elasticsearch-node unsafe-bootstrap`
command will allow one of the remaining nodes to become the elected master
without needing a response from any other nodes. This can lead to arbitrary
data loss since the node in question may not hold the latest cluster metadata,
and this out-of-date metadata may make it impossible to use some or all of the
indices in the cluster.

[WARNING]
andrershov marked this conversation as resolved.
Show resolved Hide resolved
Execution of this command can lead to arbitrary data loss. Only run this tool
if you understand what you're doing.

The sequence of bootstrapping your cluster would be the following:

1. Make sure you really lost storage of the majority master eligible nodes in
the cluster.
2. Make sure to stop all *all* master eligible nodes. This
step is *important* to prevent split-brain in the future.
3. From the survived master eligible nodes, pick one.
4. Run `elasticsearch-node unsafe-bootstrap` command as shown below.
5. If you see `Master node was successfully bootstrapped` message, it means
that the tool was able to bootstrap master eligible node.
6. Start bootstrapped master eligible node.
7. Data only nodes should be able to automatically join this node, restart
them if you previously stopped them.
8. Start more master eligible nodes to get desired level of fault-tolerance.
if you understand and accept the possible consequences and have exhausted all
other possibilities for recovery of your cluster.

The sequence of operations for using this tool are as follows:

1. Make sure you have really lost access to at least half of the
master-eligible nodes in the cluster, and they cannot be repaired or recovered
by moving their data paths to healthy hardware.
2. Stop **all** remaining master-eligible nodes.
3. Select one of the remaining master-eligible nodes to become the new elected
master.
4. On this node, run the `elasticsearch-node unsafe-bootstrap` command as shown
below. Verify that the tool reported `Master node was successfully
bootstrapped`.
5. Start this node and verify that it is elected as the master node.
6. Start all other master-eligible nodes and verify that each one joins the
cluster.
7. Any running master-ineligible nodes will automatically join the
newly-elected master. Restart any previously-stopped nodes and verify that the
cluster is now fully-formed.
8. Investigate the data in the cluster to discover if any was lost during this
andrershov marked this conversation as resolved.
Show resolved Hide resolved
process.

[source,txt]
----
Expand Down Expand Up @@ -106,14 +115,17 @@ Master node was successfully bootstrapped
----

[WARNING]
When you run the tool it will make sure that the node being bootstrapped is
stopped. There is no way for this tool to understand if other master eligible
nodes are stopped, please make sure you shut them down.
When you run the tool it will make sure that the node being bootstrapped is not
running. It is important that all other master-eligible nodes are also stopped
while this tool is running, but the tool does not check this.

[NOTE]
`Master node was successfully bootstrapped` does not mean that there would be
no data loss, it just means that tool was able to complete its job.
The message `Master node was successfully bootstrapped` does not mean that
there has been no data loss, it just means that tool was able to complete its
job.

[float]
=== Detach cluster
To be described