upgrade.asciidoc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. .When to use the `upgrade` API
  7. **************************************************
  8. Newer versions of Lucene often come with a new index format which provides bug
  9. fixes and performance improvements. In order to take advantage of these
  10. improvements, the segments in each shard need to be rewritten using the latest
  11. Lucene format.
  12. .Automatic upgrading
  13. Indices that are actively being written to will automatically write new
  14. segments in the latest format. The background merge process which combines
  15. multiple small segments into a single bigger segment will also write the new
  16. merged segment in the latest format.
  17. .Optional manual upgrades
  18. Some old segments may never be merged away because they are already too big to
  19. be worth merging, and indices that no longer receive changes will not be
  20. upgraded automatically. Upgrading segments is not required for most
  21. Elasticsearch upgrades because it can read older formats from the current and
  22. previous major version of Lucene.
  23. You can, however, choose to upgrade old segments manually to take advantage of
  24. the latest format. The `upgrade` API will rewrite any old segments in the
  25. latest Lucene format. It can be run on one index, multiple or all indices, so
  26. you can control when it is run and how many indices it should upgrade.
  27. .When you must use the `upgrade` API
  28. Elasticsearch can only read formats from the current and previous major
  29. version of Lucene. For instance, Elasticsearch 2.x (Lucene 5) can read disk
  30. formats from Elasticsearch 0.90 and 1.x (Lucene 4), but not from Elasticsearch
  31. 0.20 and before (Lucene 3).
  32. In fact, an Elasticsearch 2.0 cluster will refuse to start if any indices
  33. created before Elasticsearch 0.90 are present, and it will refuse to open them
  34. if they are imported as dangling indices later on. It will not be possible to
  35. restore an index created with Elasticsearch 0.20.x and before into a 2.0
  36. cluster.
  37. These ancient indices must either be deleted or upgraded before migrating to
  38. Elasticsearch 2.0. Upgrading will:
  39. * Rewrite old segments in the latest Lucene format.
  40. * Add the `index.version.minimum_compatible` setting to the index, to mark it as
  41. 2.0 compatible
  42. Instead of upgrading all segments that weren't written with the most recent
  43. version of Lucene, you can choose to do the minimum work required before
  44. moving to Elasticsearch 2.0, by specifying the `only_ancient_segments` option,
  45. which will only rewrite segments written by Lucene 3.
  46. **************************************************
  47. [float]
  48. === Start an upgrade
  49. [source,sh]
  50. --------------------------------------------------
  51. $ curl -XPOST 'http://localhost:9200/twitter/_upgrade'
  52. --------------------------------------------------
  53. NOTE: Upgrading is an I/O intensive operation, and is limited to processing a
  54. single shard per node at a time. It also is not allowed to run at the same
  55. time as optimize.
  56. This call will block until the upgrade is complete. If the http connection
  57. is lost, the request will continue in the background, and
  58. any new requests will block until the previous upgrade is complete.
  59. [float]
  60. [[upgrade-parameters]]
  61. ==== Request Parameters
  62. The `upgrade` API accepts the following request parameters:
  63. [horizontal]
  64. `only_ancient_segments`:: If true, only very old segments (from a
  65. previous Lucene major release) will be upgraded. While this will do
  66. the minimal work to ensure the next major release of Elasticsearch can
  67. read the segments, it's dangerous because it can leave other very old
  68. segments in sub-optimal formats. Defaults to `false`.
  69. [float]
  70. === Check upgrade status
  71. Use a `GET` request to monitor how much of an index is upgraded. This
  72. can also be used prior to starting an upgrade to identify which
  73. indices you want to upgrade at the same time.
  74. The `ancient` byte values that are returned indicate total bytes of
  75. segments whose version is extremely old (Lucene major version is
  76. different from the current version), showing how much upgrading is
  77. necessary when you run with `only_ancient_segments=true`.
  78. [source,sh]
  79. --------------------------------------------------
  80. curl 'http://localhost:9200/twitter/_upgrade?pretty&human'
  81. --------------------------------------------------
  82. [source,js]
  83. --------------------------------------------------
  84. {
  85. "size": "21gb",
  86. "size_in_bytes": "21000000000",
  87. "size_to_upgrade": "10gb",
  88. "size_to_upgrade_in_bytes": "10000000000"
  89. "size_to_upgrade_ancient": "1gb",
  90. "size_to_upgrade_ancient_in_bytes": "1000000000"
  91. "indices": {
  92. "twitter": {
  93. "size": "21gb",
  94. "size_in_bytes": "21000000000",
  95. "size_to_upgrade": "10gb",
  96. "size_to_upgrade_in_bytes": "10000000000"
  97. "size_to_upgrade_ancient": "1gb",
  98. "size_to_upgrade_ancient_in_bytes": "1000000000"
  99. }
  100. }
  101. }
  102. --------------------------------------------------
  103. The level of details in the upgrade status command can be controlled by
  104. setting `level` parameter to `cluster`, `index` (default) or `shard` levels.
  105. For example, you can run the upgrade status command with `level=shard` to
  106. get detailed upgrade information of each individual shard.