reindex_upgrade.asciidoc 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. [[reindex-upgrade]]
  2. == Reindex before upgrading
  3. Elasticsearch can read indices created in the *previous major version*.
  4. Older indices must be reindexed or deleted. Elasticsearch 6.x
  5. can use indices created in Elasticsearch 5.x, but not those created in
  6. Elasticsearch 2.x or before. Elasticsearch 5.x can use indices created in
  7. Elasticsearch 2.x, but not those created in 1.x or before.
  8. Elasticsearch nodes will fail to start if incompatible indices are present.
  9. To upgrade an Elasticsearch 5.x cluster that contains indices created in 2.x,
  10. you must reindex or delete them before upgrading to 6.x.
  11. For more information, see <<reindex-upgrade-inplace, Reindex in place>>.
  12. To upgrade an Elasticsearch cluster running 2.x, you have two options:
  13. * Perform a <<restart-upgrade, full cluster restart upgrade>> to 5.6,
  14. <<reindex-upgrade-inplace, reindex>> the 2.x indices, then perform a
  15. <<rolling-upgrades, rolling upgrade>> to 6.x. If your Elasticsearch 2.x
  16. cluster contains indices that were created before 2.x, you must either
  17. delete or reindex them before upgrading to 5.6. For more information about
  18. upgrading from 2.x to 5.6, see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/setup-upgrade.html[
  19. Upgrading Elasticsearch] in the Elasticsearch 5.6 Reference.
  20. * Create a new 6.x cluster and <<reindex-upgrade-remote, reindex from
  21. remote>> to import indices directly from the 2.x cluster.
  22. To upgrade an Elasticsearch 1.x cluster, you have two options:
  23. * Perform a <<restart-upgrade, full cluster restart upgrade>> to Elasticsearch
  24. 2.4.x and <<reindex-upgrade-inplace, reindex>> or delete the 1.x indices.
  25. Then, perform a full cluster restart upgrade to 5.6 and reindex or delete
  26. the 2.x indices. Finally, perform a <<rolling-upgrades, rolling upgrade>>
  27. to 6.x. For more information about upgrading from 1.x to 2.4, see https://www.elastic.co/guide/en/elasticsearch/reference/2.4/setup-upgrade.html[
  28. Upgrading Elasticsearch] in the Elasticsearch 2.4 Reference.
  29. For more information about upgrading from 2.4 to 5.6, see https://www.elastic.co/guide/en/elasticsearch/reference/5.6/setup-upgrade.html[
  30. Upgrading Elasticsearch] in the Elasticsearch 5.6 Reference.
  31. * Create a new 6.x cluster and <<reindex-upgrade-remote, reindex from
  32. remote>> to import indices directly from the 1.x cluster.
  33. .Upgrading time-based indices
  34. *******************************************
  35. If you use time-based indices, you likely won't need to carry
  36. pre-5.x indices forward to 6.x. Data in time-based indices
  37. generally becomes less useful as time passes and are
  38. deleted as they age past your retention period.
  39. Unless you have an unusally long retention period, you can just
  40. wait to upgrade to 6.x until all of your pre-5.x indices have
  41. been deleted.
  42. *******************************************
  43. [[reindex-upgrade-inplace]]
  44. === Reindex in place
  45. To manually reindex your old indices with the <<docs-reindex,`reindex` API>>:
  46. . Create a new index and copy the mappings and settings from the old index.
  47. . Set the `refresh_interval` to `-1` and the `number_of_replicas` to `0` for
  48. efficient reindexing.
  49. . Reindex all documents from the old index into the new index using the
  50. <<docs-reindex,reindex API>>.
  51. . Reset the `refresh_interval` and `number_of_replicas` to the values
  52. used in the old index.
  53. . Wait for the index status to change to `green`.
  54. . In a single <<indices-aliases,update aliases>> request:
  55. .. Delete the old index.
  56. .. Add an alias with the old index name to the new index.
  57. .. Add any aliases that existed on the old index to the new index.
  58. // Need to update the CSS to override sidebar titles.
  59. [role="xpack"]
  60. .Migration assistance and upgrade tools
  61. *******************************************
  62. {xpack} 5.6 provides migration assistance and upgrade tools that simplify
  63. reindexing and upgrading to 6.x. These tools are free with the X-Pack trial
  64. and Basic licenses and you can use them to upgrade whether or not X-Pack is a
  65. regular part of your Elastic Stack. For more information, see
  66. {stack-ref}/upgrading-elastic-stack.html.
  67. *******************************************
  68. [[reindex-upgrade-remote]]
  69. === Reindex from a remote cluster
  70. You can use <<reindex-from-remote,reindex from remote>> to migrate indices from
  71. your old cluster to a new 6.x cluster. This enables you move to 6.x from a
  72. pre-5.6 cluster without interrupting service.
  73. [WARNING]
  74. =============================================
  75. Elasticsearch provides backwards compatibility support that enables
  76. indices from the previous major version to be upgraded to the
  77. current major version. Skipping a major version means that you must
  78. resolve any backward compatibility issues yourself.
  79. =============================================
  80. To migrate your indices:
  81. . Set up a new 6.x cluster alongside your old cluster. Enable it to access
  82. your old cluster by adding your old cluster to the `reindex.remote.whitelist` in `elasticsearch.yml`:
  83. +
  84. --
  85. [source,yaml]
  86. --------------------------------------------------
  87. reindex.remote.whitelist: oldhost:9200
  88. --------------------------------------------------
  89. [NOTE]
  90. =============================================
  91. The new cluster doesn't have to start fully-scaled out. As you migrate
  92. indices and shift the load to the new cluster, you can add nodes to the new
  93. cluster and remove nodes from the old one.
  94. =============================================
  95. --
  96. . For each index that you need to migrate to the 6.x cluster:
  97. .. Create a new index in 6.x with the appropriate mappings and settings. Set the
  98. `refresh_interval` to `-1` and set `number_of_replicas` to `0` for
  99. faster reindexing.
  100. .. <<reindex-from-remote,Reindex from remote>> to pull documents from the
  101. old index into the new 6.x index:
  102. +
  103. --
  104. [source,js]
  105. --------------------------------------------------
  106. POST _reindex
  107. {
  108. "source": {
  109. "remote": {
  110. "host": "http://oldhost:9200",
  111. "username": "user",
  112. "password": "pass"
  113. },
  114. "index": "source",
  115. "query": {
  116. "match": {
  117. "test": "data"
  118. }
  119. }
  120. },
  121. "dest": {
  122. "index": "dest"
  123. }
  124. }
  125. --------------------------------------------------
  126. // CONSOLE
  127. // TEST[setup:host]
  128. // TEST[s/^/PUT source\n/]
  129. // TEST[s/oldhost:9200",/\${host}"/]
  130. // TEST[s/"username": "user",//]
  131. // TEST[s/"password": "pass"//]
  132. If you run the reindex job in the background by setting `wait_for_completion`
  133. to `false`, the reindex request returns a `task_id` you can use to
  134. monitor progress of the reindex job with the <<tasks,task API>>:
  135. `GET _tasks/TASK_ID`.
  136. --
  137. .. When the reindex job completes, set the `refresh_interval` and
  138. `number_of_replicas` to the desired values (the default settings are
  139. `30s` and `1`).
  140. .. Once replication is complete and the status of the new index is `green`,
  141. you can delete the old index.