rolling_upgrade.asciidoc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. [[rolling-upgrades]]
  2. === Rolling upgrades
  3. A rolling upgrade allows the Elasticsearch cluster to be upgraded one node at
  4. a time, with no downtime for end users. Running multiple versions of
  5. Elasticsearch in the same cluster for any length of time beyond that required
  6. for an upgrade is not supported, as shards will not be replicated from the
  7. more recent version to the older version.
  8. Consult this <<setup-upgrade,table>> to verify that rolling upgrades are
  9. supported for your version of Elasticsearch.
  10. To perform a rolling upgrade:
  11. ==== Step 1: Disable shard allocation
  12. When you shut down a node, the allocation process will immediately try to
  13. replicate the shards that were on that node to other nodes in the cluster,
  14. causing a lot of wasted I/O. This can be avoided by disabling allocation
  15. before shutting down a node:
  16. [source,js]
  17. --------------------------------------------------
  18. PUT /_cluster/settings
  19. {
  20. "transient": {
  21. "cluster.routing.allocation.enable": "none"
  22. }
  23. }
  24. --------------------------------------------------
  25. // AUTOSENSE
  26. ==== Step 2: Stop non-essential indexing and perform a synced flush (Optional)
  27. You may happily continue indexing during the upgrade. However, shard recovery
  28. will be much faster if you temporarily stop non-essential indexing and issue a
  29. <<indices-synced-flush, synced-flush>> request:
  30. [source,js]
  31. --------------------------------------------------
  32. POST /_flush/synced
  33. --------------------------------------------------
  34. // AUTOSENSE
  35. A synced flush request is a ``best effort'' operation. It will fail if there
  36. are any pending indexing operations, but it is safe to reissue the request
  37. multiple times if necessary.
  38. [[upgrade-node]]
  39. ==== Step 3: Stop and upgrade a single node
  40. Shut down one of the nodes in the cluster *before* starting the upgrade.
  41. [TIP]
  42. ================================================
  43. When using the zip or tarball packages, the `config`, `data`, `logs` and
  44. `plugins` directories are placed within the Elasticsearch home directory by
  45. default.
  46. It is a good idea to place these directories in a different location so that
  47. there is no chance of deleting them when upgrading Elasticsearch. These
  48. custom paths can be <<paths,configured>> with the `path.config` and
  49. `path.data` settings.
  50. The Debian and RPM packages place these directories in the
  51. <<setup-dir-layout,appropriate place>> for each operating system.
  52. ================================================
  53. To upgrade using a <<setup-repositories,Debian or RPM>> package:
  54. * Use `rpm` or `dpkg` to install the new package. All files should be
  55. placed in their proper locations, and config files should not be
  56. overwritten.
  57. To upgrade using a zip or compressed tarball:
  58. * Extract the zip or tarball to a new directory, to be sure that you don't
  59. overwrite the `config` or `data` directories.
  60. * Either copy the files in the `config` directory from your old installation
  61. to your new installation, or use the `--path.config` option on the command
  62. line to point to an external config directory.
  63. * Either copy the files in the `data` directory from your old installation
  64. to your new installation, or configure the location of the data directory
  65. in the `config/elasticsearch.yml` file, with the `path.data` setting.
  66. ==== Step 4: Start the upgraded node
  67. Start the now upgraded node and confirm that it joins the cluster by checking
  68. the log file or by checking the output of this request:
  69. [source,sh]
  70. --------------------------------------------------
  71. GET _cat/nodes
  72. --------------------------------------------------
  73. // AUTOSENSE
  74. ==== Step 5: Reenable shard allocation
  75. Once the node has joined the cluster, reenable shard allocation to start using
  76. the node:
  77. [source,js]
  78. --------------------------------------------------
  79. PUT /_cluster/settings
  80. {
  81. "transient": {
  82. "cluster.routing.allocation.enable": "all"
  83. }
  84. }
  85. --------------------------------------------------
  86. // AUTOSENSE
  87. ==== Step 6: Wait for the node to recover
  88. You should wait for the cluster to finish shard allocation before upgrading
  89. the next node. You can check on progress with the <<cat-health,`_cat/health`>>
  90. request:
  91. [source,sh]
  92. --------------------------------------------------
  93. GET _cat/health
  94. --------------------------------------------------
  95. // AUTOSENSE
  96. Wait for the `status` column to move from `yellow` to `green`. Status `green`
  97. means that all primary and replica shards have been allocated.
  98. [IMPORTANT]
  99. ====================================================
  100. During a rolling upgrade, primary shards assigned to a node with the higher
  101. version will never have their replicas assigned to a node with the lower
  102. version, because the newer version may have a different data format which is
  103. not understood by the older version.
  104. If it is not possible to assign the replica shards to another node with the
  105. higher version -- e.g. if there is only one node with the higher version in
  106. the cluster -- then the replica shards will remain unassigned and the
  107. cluster health will remain status `yellow`.
  108. In this case, check that there are no initializing or relocating shards (the
  109. `init` and `relo` columns) before proceding.
  110. As soon as another node is upgraded, the replicas should be assigned and the
  111. cluster health will reach status `green`.
  112. ====================================================
  113. Shards that have not been <<indices-synced-flush,sync-flushed>> may take some time to
  114. recover. The recovery status of individual shards can be monitored with the
  115. <<cat-recovery,`_cat/recovery`>> request:
  116. [source,sh]
  117. --------------------------------------------------
  118. GET _cat/recovery
  119. --------------------------------------------------
  120. // AUTOSENSE
  121. If you stopped indexing, then it is safe to resume indexing as soon as
  122. recovery has completed.
  123. ==== Step 7: Repeat
  124. When the cluster is stable and the node has recovered, repeat the above steps
  125. for all remaining nodes.