2017-08-23 17:03:14 -04:00
|
|
|
[[reindex-upgrade]]
|
2017-12-05 13:58:52 -05:00
|
|
|
== Reindex before upgrading
|
2017-08-23 17:03:14 -04:00
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
{es} can read indices created in the previous major version. If you
|
|
|
|
have indices created in 5.x or before, you must reindex or delete them
|
|
|
|
before upgrading to {version}. {es} nodes will fail to start if
|
|
|
|
incompatible indices are present. Snapshots of 5.x or earlier indices cannot be
|
|
|
|
restored to a 7.x cluster even if they were created by a 6.x cluster.
|
2017-08-23 17:03:14 -04:00
|
|
|
|
2019-03-14 13:26:22 -04:00
|
|
|
This restriction also applies to the internal indices that are used by
|
|
|
|
{kib} and the {xpack} features. Therefore, before you can use {kib} and
|
|
|
|
{xpack} features in {version}, you must ensure the internal indices have a
|
|
|
|
compatible index structure.
|
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
You have two options for reindexing old indices:
|
2017-08-23 17:03:14 -04:00
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
* <<reindex-upgrade-inplace, Reindex in place>> on your 6.x cluster before upgrading.
|
|
|
|
* Create a new {version} cluster and <<reindex-upgrade-remote, Reindex from remote>>.
|
|
|
|
This enables you to reindex indices that reside on clusters running any version of {es}.
|
2017-08-23 17:03:14 -04:00
|
|
|
|
|
|
|
.Upgrading time-based indices
|
|
|
|
*******************************************
|
|
|
|
|
|
|
|
If you use time-based indices, you likely won't need to carry
|
2019-03-13 17:38:13 -04:00
|
|
|
pre-6.x indices forward to {version}. Data in time-based indices
|
2017-08-23 17:03:14 -04:00
|
|
|
generally becomes less useful as time passes and are
|
|
|
|
deleted as they age past your retention period.
|
|
|
|
|
2019-01-07 08:44:12 -05:00
|
|
|
Unless you have an unusually long retention period, you can just
|
2019-03-13 17:38:13 -04:00
|
|
|
wait to upgrade to 6.x until all of your pre-6.x indices have
|
2017-08-23 17:03:14 -04:00
|
|
|
been deleted.
|
|
|
|
|
|
|
|
*******************************************
|
|
|
|
|
|
|
|
|
|
|
|
[[reindex-upgrade-inplace]]
|
2017-12-05 13:58:52 -05:00
|
|
|
=== Reindex in place
|
2017-08-23 17:03:14 -04:00
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
You can use the Upgrade Assistant in {kib} 6.7 to automatically reindex 5.x
|
|
|
|
indices you need to carry forward to {version}.
|
2017-08-23 17:03:14 -04:00
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
To manually reindex your old indices in place:
|
|
|
|
|
|
|
|
. Create an index with 7.x compatible mappings.
|
2017-08-23 17:03:14 -04:00
|
|
|
. Set the `refresh_interval` to `-1` and the `number_of_replicas` to `0` for
|
|
|
|
efficient reindexing.
|
2019-03-13 17:38:13 -04:00
|
|
|
. Use the <<docs-reindex,`reindex` API>> to copy documents from the
|
|
|
|
5.x index into the new index. You can use a script to perform any necessary
|
|
|
|
modifications to the document data and metadata during reindexing.
|
2017-08-23 17:03:14 -04:00
|
|
|
. Reset the `refresh_interval` and `number_of_replicas` to the values
|
|
|
|
used in the old index.
|
|
|
|
. Wait for the index status to change to `green`.
|
|
|
|
. In a single <<indices-aliases,update aliases>> request:
|
|
|
|
.. Delete the old index.
|
|
|
|
.. Add an alias with the old index name to the new index.
|
|
|
|
.. Add any aliases that existed on the old index to the new index.
|
|
|
|
|
2019-03-14 13:26:22 -04:00
|
|
|
ifdef::include-xpack[]
|
|
|
|
[TIP]
|
|
|
|
====
|
|
|
|
If you use {ml-features} and your {ml} indices were created before
|
|
|
|
{prev-major-version}, you must
|
|
|
|
{stack-ov}/stopping-ml.html[stop all {dfeeds} and close all {ml} jobs] before
|
|
|
|
you reindex the indices.
|
|
|
|
|
|
|
|
If you use {es} {security-features}, before you reindex `.security*` internal
|
|
|
|
indices it is a good idea to create a temporary superuser account in the `file`
|
|
|
|
realm.
|
|
|
|
|
|
|
|
. On a single node, add a temporary superuser account to the `file` realm. For
|
|
|
|
example, run the <<users-command,elasticsearch-users useradd>> command:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
[source,sh]
|
|
|
|
----------------------------------------------------------
|
|
|
|
bin/elasticsearch-users useradd <user_name> \
|
|
|
|
-p <password> -r superuser
|
|
|
|
----------------------------------------------------------
|
|
|
|
--
|
|
|
|
|
|
|
|
. Use these credentials when you reindex the `.security*` index. That is to say,
|
|
|
|
use them to log into {kib} and run the Upgrade Assistant or to call the
|
|
|
|
reindex API. You can use your regular administration credentials to
|
|
|
|
reindex the other internal indices.
|
|
|
|
|
|
|
|
. Delete the temporary superuser account from the file realm. For
|
|
|
|
example, run the {ref}/users-command.html[elasticsearch-users userdel] command:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
[source,sh]
|
|
|
|
----------------------------------------------------------
|
|
|
|
bin/elasticsearch-users userdel <user_name>
|
|
|
|
----------------------------------------------------------
|
|
|
|
--
|
|
|
|
|
|
|
|
For more information, see <<configuring-file-realm>>.
|
|
|
|
====
|
|
|
|
endif::include-xpack[]
|
|
|
|
|
2017-08-23 17:03:14 -04:00
|
|
|
[[reindex-upgrade-remote]]
|
2017-12-05 13:58:52 -05:00
|
|
|
=== Reindex from a remote cluster
|
2017-08-23 17:03:14 -04:00
|
|
|
|
|
|
|
You can use <<reindex-from-remote,reindex from remote>> to migrate indices from
|
2019-03-13 17:38:13 -04:00
|
|
|
your old cluster to a new {version} cluster. This enables you move to {version}
|
|
|
|
from a pre-6.7 cluster without interrupting service.
|
2017-08-23 17:03:14 -04:00
|
|
|
|
|
|
|
[WARNING]
|
|
|
|
=============================================
|
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
{es} provides backwards compatibility support that enables
|
2017-08-23 17:03:14 -04:00
|
|
|
indices from the previous major version to be upgraded to the
|
|
|
|
current major version. Skipping a major version means that you must
|
|
|
|
resolve any backward compatibility issues yourself.
|
|
|
|
|
|
|
|
=============================================
|
|
|
|
|
|
|
|
To migrate your indices:
|
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
. Set up a new {version} cluster and add the existing cluster to the
|
|
|
|
`reindex.remote.whitelist` in `elasticsearch.yml`.
|
2017-08-23 17:03:14 -04:00
|
|
|
+
|
|
|
|
--
|
|
|
|
[source,yaml]
|
|
|
|
--------------------------------------------------
|
|
|
|
reindex.remote.whitelist: oldhost:9200
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
[NOTE]
|
|
|
|
=============================================
|
|
|
|
The new cluster doesn't have to start fully-scaled out. As you migrate
|
|
|
|
indices and shift the load to the new cluster, you can add nodes to the new
|
|
|
|
cluster and remove nodes from the old one.
|
|
|
|
|
|
|
|
=============================================
|
|
|
|
--
|
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
. For each index that you need to migrate to the new cluster:
|
2017-08-23 17:03:14 -04:00
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
.. Create an index the appropriate mappings and settings. Set the
|
2017-08-23 17:03:14 -04:00
|
|
|
`refresh_interval` to `-1` and set `number_of_replicas` to `0` for
|
|
|
|
faster reindexing.
|
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
.. Use the <<docs-reindex,`reindex` API>> to pull documents from the
|
|
|
|
remote index into the new {version} index:
|
2017-08-23 17:03:14 -04:00
|
|
|
+
|
|
|
|
--
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
POST _reindex
|
|
|
|
{
|
|
|
|
"source": {
|
|
|
|
"remote": {
|
|
|
|
"host": "http://oldhost:9200",
|
|
|
|
"username": "user",
|
|
|
|
"password": "pass"
|
|
|
|
},
|
|
|
|
"index": "source",
|
|
|
|
"query": {
|
|
|
|
"match": {
|
|
|
|
"test": "data"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"dest": {
|
|
|
|
"index": "dest"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[setup:host]
|
|
|
|
// TEST[s/^/PUT source\n/]
|
2017-08-24 05:45:53 -04:00
|
|
|
// TEST[s/oldhost:9200",/\${host}"/]
|
2017-08-23 17:03:14 -04:00
|
|
|
// TEST[s/"username": "user",//]
|
|
|
|
// TEST[s/"password": "pass"//]
|
|
|
|
|
|
|
|
If you run the reindex job in the background by setting `wait_for_completion`
|
|
|
|
to `false`, the reindex request returns a `task_id` you can use to
|
|
|
|
monitor progress of the reindex job with the <<tasks,task API>>:
|
|
|
|
`GET _tasks/TASK_ID`.
|
|
|
|
--
|
|
|
|
|
|
|
|
.. When the reindex job completes, set the `refresh_interval` and
|
|
|
|
`number_of_replicas` to the desired values (the default settings are
|
|
|
|
`30s` and `1`).
|
|
|
|
|
2019-03-13 17:38:13 -04:00
|
|
|
.. Once reindexing is complete and the status of the new index is `green`,
|
2017-08-23 17:03:14 -04:00
|
|
|
you can delete the old index.
|