11[[shard-tool]]
22== elasticsearch-shard
33
4- In some cases the Lucene index or translog of a shard copy can become
5- corrupted. The `elasticsearch-shard` command enables you to remove corrupted
6- parts of the shard if a good copy of the shard cannot be recovered
7- automatically or restored from backup.
4+ In some cases the Lucene index or translog of a shard copy can become corrupted.
5+ The `elasticsearch-shard` command enables you to remove corrupted parts of the
6+ shard if a good copy of the shard cannot be recovered automatically or restored
7+ from backup.
88
99[WARNING]
1010You will lose the corrupted data when you run `elasticsearch-shard`. This tool
1111should only be used as a last resort if there is no way to recover from another
1212copy of the shard or restore a snapshot.
1313
14- When Elasticsearch detects that a shard's data is corrupted, it fails that
15- shard copy and refuses to use it. Under normal conditions, the shard is
16- automatically recovered from another copy. If no good copy of the shard is
17- available and you cannot restore from backup, you can use `elasticsearch-shard`
18- to remove the corrupted data and restore access to any remaining data in
19- unaffected segments.
14+ [float]
15+ === Synopsis
16+
17+ [source,shell]
18+ --------------------------------------------------
19+ bin/elasticsearch-shard remove-corrupted-data
20+ ([--index <Index>] [--shard-id <ShardId>] | [--dir <IndexPath>])
21+ [--truncate-clean-translog]
22+ [-E <KeyValuePair>]
23+ [-h, --help] ([-s, --silent] | [-v, --verbose])
24+ --------------------------------------------------
25+
26+ [float]
27+ === Description
28+
29+ When {es} detects that a shard's data is corrupted, it fails that shard copy and
30+ refuses to use it. Under normal conditions, the shard is automatically recovered
31+ from another copy. If no good copy of the shard is available and you cannot
32+ restore one from a snapshot, you can use `elasticsearch-shard` to remove the
33+ corrupted data and restore access to any remaining data in unaffected segments.
2034
2135[WARNING]
2236Stop Elasticsearch before running `elasticsearch-shard`.
@@ -31,7 +45,7 @@ There are two ways to specify the path:
3145 translog files.
3246
3347[float]
34- === Removing corrupted data
48+ ==== Removing corrupted data
3549
3650`elasticsearch-shard` analyses the shard copy and provides an overview of the
3751corruption found. To proceed you must then confirm that you want to remove the
@@ -91,17 +105,19 @@ POST /_cluster/reroute
91105 ]
92106}
93107
94- You must accept the possibility of data loss by changing parameter `accept_data_loss` to `true`.
108+ You must accept the possibility of data loss by changing the `accept_data_loss` parameter to `true`.
95109
96110Deleted corrupt marker corrupted_FzTSBSuxT7i3Tls_TgwEag from /var/lib/elasticsearchdata/indices/P45vf_YQRhqjfwLMUvSqDw/0/index/
97111
98112--------------------------------------------------
99113
100114When you use `elasticsearch-shard` to drop the corrupted data, the shard's
101115allocation ID changes. After restarting the node, you must use the
102- <<cluster-reroute,cluster reroute API>> to tell Elasticsearch to use the new
103- ID. The `elasticsearch-shard` command shows the request that
104- you need to submit.
116+ <<cluster-reroute,cluster reroute API>> to tell Elasticsearch to use the new ID.
117+ The `elasticsearch-shard` command shows the request that you need to submit.
105118
106119You can also use the `-h` option to get a list of all options and parameters
107120that the `elasticsearch-shard` tool supports.
121+
122+ Finally, you can use the `--truncate-clean-translog` option to truncate the
123+ shard's translog even if it does not appear to be corrupt.
0 commit comments