upgrade.asciidoc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. [[indices-upgrade]]
  2. == Upgrade
  3. The upgrade API allows to upgrade one or more indices to the latest Lucene
  4. format through an API. The upgrade process converts any segments written with
  5. older formats.
  6. [IMPORTANT]
  7. ===================================================
  8. **The upgrade API in its current form will not help you to migrate indices
  9. created in Elasticsearch 1.x to 5.x.**
  10. The upgrade API rewrites an index in the latest Lucene format, but it still
  11. retains the original data structures that were used when the index was first
  12. created. For instance:
  13. * Doc-values on numeric fields used to use BinaryDocValues, but now use dedicated NumericDocValues.
  14. * The parent-child feature has been completely rewritten to use a new data structure.
  15. * Geo-point fields now require doc values and the Lucene index where, previously, they relied on in-memory calculations.
  16. **Migrating 1.x indices to 5.x**
  17. The only way to prepare an index created in 1.x for use in 5.x is to **reindex
  18. your data** in a cluster running Elasticsearch 2.3.x, which you can do with
  19. the new <<docs-reindex,reindex API>>.
  20. The steps to do this are as follows:
  21. 1. Create a new index (e.g. `new_index`) with the correct settings and
  22. mappings. These can be retrieved from the old index with the
  23. <<indices-get-index,get-index>> API.
  24. 2. Reindex from `old_index` to `new_index` with the
  25. <<docs-reindex,reindex API>>.
  26. 3. Retrieve a list of any aliases associated with the `old_index` using the
  27. <<alias-retrieving,get-alias API>>.
  28. 4. Delete the `old_index` using the <<indices-delete-index,delete index API>>.
  29. 5. Add an alias called `old_index` to the `new_index` along with any aliases
  30. returned in step 3, using the <<indices-aliases,update aliases API>>.
  31. In the future, we plan to change the upgrade API to perform a reindex-in-
  32. place. In other words, it would reindex data from `old_index` to `.old_index`
  33. then atomically delete `old_index` and rename `.old_index` to `old_index`.
  34. ===================================================
  35. [float]
  36. === Start an upgrade
  37. [source,sh]
  38. --------------------------------------------------
  39. $ curl -XPOST 'http://localhost:9200/twitter/_upgrade'
  40. --------------------------------------------------
  41. NOTE: Upgrading is an I/O intensive operation, and is limited to processing a
  42. single shard per node at a time. It also is not allowed to run at the same
  43. time as an optimize/force-merge.
  44. This call will block until the upgrade is complete. If the http connection
  45. is lost, the request will continue in the background, and
  46. any new requests will block until the previous upgrade is complete.
  47. [float]
  48. [[upgrade-parameters]]
  49. ==== Request Parameters
  50. The `upgrade` API accepts the following request parameters:
  51. [horizontal]
  52. `only_ancient_segments`:: If true, only very old segments (from a
  53. previous Lucene major release) will be upgraded. While this will do
  54. the minimal work to ensure the next major release of Elasticsearch can
  55. read the segments, it's dangerous because it can leave other very old
  56. segments in sub-optimal formats. Defaults to `false`.
  57. [float]
  58. === Check upgrade status
  59. Use a `GET` request to monitor how much of an index is upgraded. This
  60. can also be used prior to starting an upgrade to identify which
  61. indices you want to upgrade at the same time.
  62. The `ancient` byte values that are returned indicate total bytes of
  63. segments whose version is extremely old (Lucene major version is
  64. different from the current version), showing how much upgrading is
  65. necessary when you run with `only_ancient_segments=true`.
  66. [source,sh]
  67. --------------------------------------------------
  68. curl 'http://localhost:9200/twitter/_upgrade?pretty&human'
  69. --------------------------------------------------
  70. [source,js]
  71. --------------------------------------------------
  72. {
  73. "size": "21gb",
  74. "size_in_bytes": "21000000000",
  75. "size_to_upgrade": "10gb",
  76. "size_to_upgrade_in_bytes": "10000000000"
  77. "size_to_upgrade_ancient": "1gb",
  78. "size_to_upgrade_ancient_in_bytes": "1000000000"
  79. "indices": {
  80. "twitter": {
  81. "size": "21gb",
  82. "size_in_bytes": "21000000000",
  83. "size_to_upgrade": "10gb",
  84. "size_to_upgrade_in_bytes": "10000000000"
  85. "size_to_upgrade_ancient": "1gb",
  86. "size_to_upgrade_ancient_in_bytes": "1000000000"
  87. }
  88. }
  89. }
  90. --------------------------------------------------
  91. The level of details in the upgrade status command can be controlled by
  92. setting `level` parameter to `cluster`, `index` (default) or `shard` levels.
  93. For example, you can run the upgrade status command with `level=shard` to
  94. get detailed upgrade information of each individual shard.