recovery.asciidoc 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. [[indices-recovery]]
  2. === Indices Recovery
  3. The indices recovery API provides insight into on-going index shard recoveries.
  4. Recovery status may be reported for specific indices, or cluster-wide.
  5. For example, the following command would show recovery information for the indices "index1" and "index2".
  6. [source,js]
  7. --------------------------------------------------
  8. GET index1,index2/_recovery?human
  9. --------------------------------------------------
  10. // CONSOLE
  11. // TEST[s/^/PUT index1\nPUT index2\n/]
  12. To see cluster-wide recovery status simply leave out the index names.
  13. //////////////////////////
  14. Here we create a repository and snapshot index1 in
  15. order to restore it right after and prints out the
  16. indices recovery result.
  17. [source,js]
  18. --------------------------------------------------
  19. # create the index
  20. PUT index1
  21. {"settings": {"index.number_of_shards": 1}}
  22. # create the repository
  23. PUT /_snapshot/my_repository
  24. {"type": "fs","settings": {"location": "recovery_asciidoc" }}
  25. # snapshot the index
  26. PUT /_snapshot/my_repository/snap_1?wait_for_completion=true
  27. # delete the index
  28. DELETE index1
  29. # and restore the snapshot
  30. POST /_snapshot/my_repository/snap_1/_restore?wait_for_completion=true
  31. --------------------------------------------------
  32. // CONSOLE
  33. [source,js]
  34. --------------------------------------------------
  35. {
  36. "snapshot": {
  37. "snapshot": "snap_1",
  38. "indices": [
  39. "index1"
  40. ],
  41. "shards": {
  42. "total": 1,
  43. "failed": 0,
  44. "successful": 1
  45. }
  46. }
  47. }
  48. --------------------------------------------------
  49. // TESTRESPONSE
  50. //////////////////////////
  51. [source,js]
  52. --------------------------------------------------
  53. GET /_recovery?human
  54. --------------------------------------------------
  55. // CONSOLE
  56. // TEST[continued]
  57. Response:
  58. [source,js]
  59. --------------------------------------------------
  60. {
  61. "index1" : {
  62. "shards" : [ {
  63. "id" : 0,
  64. "type" : "SNAPSHOT",
  65. "stage" : "INDEX",
  66. "primary" : true,
  67. "start_time" : "2014-02-24T12:15:59.716",
  68. "start_time_in_millis": 1393244159716,
  69. "stop_time" : "0s",
  70. "stop_time_in_millis" : 0,
  71. "total_time" : "2.9m",
  72. "total_time_in_millis" : 175576,
  73. "source" : {
  74. "repository" : "my_repository",
  75. "snapshot" : "my_snapshot",
  76. "index" : "index1",
  77. "version" : "{version}",
  78. "restoreUUID": "PDh1ZAOaRbiGIVtCvZOMww"
  79. },
  80. "target" : {
  81. "id" : "ryqJ5lO5S4-lSFbGntkEkg",
  82. "host" : "my.fqdn",
  83. "transport_address" : "my.fqdn",
  84. "ip" : "10.0.1.7",
  85. "name" : "my_es_node"
  86. },
  87. "index" : {
  88. "size" : {
  89. "total" : "75.4mb",
  90. "total_in_bytes" : 79063092,
  91. "reused" : "0b",
  92. "reused_in_bytes" : 0,
  93. "recovered" : "65.7mb",
  94. "recovered_in_bytes" : 68891939,
  95. "percent" : "87.1%"
  96. },
  97. "files" : {
  98. "total" : 73,
  99. "reused" : 0,
  100. "recovered" : 69,
  101. "percent" : "94.5%"
  102. },
  103. "total_time" : "0s",
  104. "total_time_in_millis" : 0,
  105. "source_throttle_time" : "0s",
  106. "source_throttle_time_in_millis" : 0,
  107. "target_throttle_time" : "0s",
  108. "target_throttle_time_in_millis" : 0
  109. },
  110. "translog" : {
  111. "recovered" : 0,
  112. "total" : 0,
  113. "percent" : "100.0%",
  114. "total_on_start" : 0,
  115. "total_time" : "0s",
  116. "total_time_in_millis" : 0,
  117. },
  118. "verify_index" : {
  119. "check_index_time" : "0s",
  120. "check_index_time_in_millis" : 0,
  121. "total_time" : "0s",
  122. "total_time_in_millis" : 0
  123. }
  124. } ]
  125. }
  126. }
  127. --------------------------------------------------
  128. // TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
  129. // TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
  130. ////
  131. The TESTRESPONSE above replace all the fields values by the expected ones in the test,
  132. because we don't really care about the field values but we want to check the fields names.
  133. ////
  134. The above response shows a single index recovering a single shard. In this case, the source of the recovery is a snapshot repository
  135. and the target of the recovery is the node with name "my_es_node".
  136. Additionally, the output shows the number and percent of files recovered, as well as the number and percent of bytes recovered.
  137. In some cases a higher level of detail may be preferable. Setting "detailed=true" will present a list of physical files in recovery.
  138. [source,js]
  139. --------------------------------------------------
  140. GET _recovery?human&detailed=true
  141. --------------------------------------------------
  142. // CONSOLE
  143. // TEST[s/^/PUT index1\n{"settings": {"index.number_of_shards": 1}}\n/]
  144. Response:
  145. [source,js]
  146. --------------------------------------------------
  147. {
  148. "index1" : {
  149. "shards" : [ {
  150. "id" : 0,
  151. "type" : "STORE",
  152. "stage" : "DONE",
  153. "primary" : true,
  154. "start_time" : "2014-02-24T12:38:06.349",
  155. "start_time_in_millis" : "1393245486349",
  156. "stop_time" : "2014-02-24T12:38:08.464",
  157. "stop_time_in_millis" : "1393245488464",
  158. "total_time" : "2.1s",
  159. "total_time_in_millis" : 2115,
  160. "source" : {
  161. "id" : "RGMdRc-yQWWKIBM4DGvwqQ",
  162. "host" : "my.fqdn",
  163. "transport_address" : "my.fqdn",
  164. "ip" : "10.0.1.7",
  165. "name" : "my_es_node"
  166. },
  167. "target" : {
  168. "id" : "RGMdRc-yQWWKIBM4DGvwqQ",
  169. "host" : "my.fqdn",
  170. "transport_address" : "my.fqdn",
  171. "ip" : "10.0.1.7",
  172. "name" : "my_es_node"
  173. },
  174. "index" : {
  175. "size" : {
  176. "total" : "24.7mb",
  177. "total_in_bytes" : 26001617,
  178. "reused" : "24.7mb",
  179. "reused_in_bytes" : 26001617,
  180. "recovered" : "0b",
  181. "recovered_in_bytes" : 0,
  182. "percent" : "100.0%"
  183. },
  184. "files" : {
  185. "total" : 26,
  186. "reused" : 26,
  187. "recovered" : 0,
  188. "percent" : "100.0%",
  189. "details" : [ {
  190. "name" : "segments.gen",
  191. "length" : 20,
  192. "recovered" : 20
  193. }, {
  194. "name" : "_0.cfs",
  195. "length" : 135306,
  196. "recovered" : 135306
  197. }, {
  198. "name" : "segments_2",
  199. "length" : 251,
  200. "recovered" : 251
  201. }
  202. ]
  203. },
  204. "total_time" : "2ms",
  205. "total_time_in_millis" : 2,
  206. "source_throttle_time" : "0s",
  207. "source_throttle_time_in_millis" : 0,
  208. "target_throttle_time" : "0s",
  209. "target_throttle_time_in_millis" : 0
  210. },
  211. "translog" : {
  212. "recovered" : 71,
  213. "total" : 0,
  214. "percent" : "100.0%",
  215. "total_on_start" : 0,
  216. "total_time" : "2.0s",
  217. "total_time_in_millis" : 2025
  218. },
  219. "verify_index" : {
  220. "check_index_time" : 0,
  221. "check_index_time_in_millis" : 0,
  222. "total_time" : "88ms",
  223. "total_time_in_millis" : 88
  224. }
  225. } ]
  226. }
  227. }
  228. --------------------------------------------------
  229. // TESTRESPONSE[s/"source" : \{[^}]*\}/"source" : $body.$_path/]
  230. // TESTRESPONSE[s/"details" : \[[^\]]*\]/"details" : $body.$_path/]
  231. // TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
  232. // TESTRESPONSE[s/: "[^"]*"/: $body.$_path/]
  233. ////
  234. The TESTRESPONSE above replace all the fields values by the expected ones in the test,
  235. because we don't really care about the field values but we want to check the fields names.
  236. It also removes the "details" part which is important in this doc but really hard to test.
  237. ////
  238. This response shows a detailed listing (truncated for brevity) of the actual files recovered and their sizes.
  239. Also shown are the timings in milliseconds of the various stages of recovery: index retrieval, translog replay, and index start time.
  240. Note that the above listing indicates that the recovery is in stage "done". All recoveries, whether on-going or complete, are kept in
  241. cluster state and may be reported on at any time. Setting "active_only=true" will cause only on-going recoveries to be reported.
  242. Here is a complete list of options:
  243. [horizontal]
  244. `detailed`:: Display a detailed view. This is primarily useful for viewing the recovery of physical index files. Default: false.
  245. `active_only`:: Display only those recoveries that are currently on-going. Default: false.
  246. Description of output fields:
  247. [horizontal]
  248. `id`:: Shard ID
  249. `type`:: Recovery type:
  250. * store
  251. * snapshot
  252. * replica
  253. * relocating
  254. `stage`:: Recovery stage:
  255. * init: Recovery has not started
  256. * index: Reading index meta-data and copying bytes from source to destination
  257. * start: Starting the engine; opening the index for use
  258. * translog: Replaying transaction log
  259. * finalize: Cleanup
  260. * done: Complete
  261. `primary`:: True if shard is primary, false otherwise
  262. `start_time`:: Timestamp of recovery start
  263. `stop_time`:: Timestamp of recovery finish
  264. `total_time_in_millis`:: Total time to recover shard in milliseconds
  265. `source`:: Recovery source:
  266. * repository description if recovery is from a snapshot
  267. * description of source node otherwise
  268. `target`:: Destination node
  269. `index`:: Statistics about physical index recovery
  270. `translog`:: Statistics about translog recovery
  271. `start`:: Statistics about time to open and start the index