Commit 6915f5c4 authored by Raphaël Flores's avatar Raphaël Flores
Browse files

Clean readme.

parent ca771b41
......@@ -193,143 +193,6 @@ curl -X PUT "localhost:9200/rare-dev-resource-physical-index" -H 'Content-Type:
`createIndexAndAliases.sh` script. The exact content of the settings is omitted here for brevity and readability.
{: .alert .alert-info}
#### Deleting with no downtime
If you don't want any downtime, you can instead use the following procedure:
- create a new physical index (let's name it `rare-dev-resource-new-physical-index`);
- delete the `rare-dev-resource-harvest-index` alias, and recreate it so that it refers to `rare-dev-resource-new-physical-index`;
- trigger a harvest. During the harvest, the `rare-dev-resource-index` alias, used by the search,
still refers to the old physical index, and it thus still works flawlessly;
- once the harvest is finished, delete the `rare-dev-resource-index` alias, and recreate it so that it refers to
`rare-dev-resource-new-physical-index`. All the search operations will now use the new index, containing up-to-date
documents;
- delete the old physical index.
Here are curl commands illustrating the above scenario:
```
# create a new physical index
curl -X PUT "localhost:9200/rare-dev-resource-new-physical-index" -H 'Content-Type: application/json' -d'
{
"settings": ...
}
'
# delete the `rare-dev-resource-harvest-index` alias, and recreate it so that it refers to `rare-dev-resource-new-physical-index`
curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'
{
"actions" : [
{ "remove" : { "index" : "rare-dev-resource-physical-index", "alias" : "rare-dev-resource-harvest-index" } },
{ "add" : { "index" : "rare-dev-resource-new-physical-index", "alias" : "rare-dev-resource-harvest-index" } }
]
}
'
# once the harvest is finished, delete the `resource-index` alias, and recreate it so that it refers to `resource-new-physical-index`
curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'
{
"actions" : [
{ "remove" : { "index" : "rare-dev-resource-physical-index", "alias" : "rare-dev-resource-index" } },
{ "add" : { "index" : "rare-dev-resource-new-physical-index", "alias" : "rare-dev-resource-index" } }
]
}
'
# delete the old physical index
curl -X DELETE "localhost:9200/rare-dev-resource-physical-index"
```
### Mapping migration
Another situation where you might need to reindex all the documents is when the mapping has changed and a new version
of the application must be redeployed.
#### Upgrading with some downtime
This is the easiest and safest procedure, that I would recommend:
- create a new physical index (let's name it `rare-dev-resource-new-physical-index`);
- delete the `rare-dev-resource-harvest-index` and the `rare-dev-resource-index` aliases, and recreate them both so that they refer to
`rare-dev-resource-new-physical-index`;
- stop the existing application, deploy and start the new one;
- trigger a harvest;
- once everything is running fine, remove the old physical index.
In case anything goes wrong, the two aliases can always be recreated to refer to the old physical index, and the old
application can be restarted.
Here are curl commands illustrating the above scenario:
```
# create a new physical index
curl -X PUT "localhost:9200/rare-dev-resource-new-physical-index" -H 'Content-Type: application/json' -d'
{
"settings": ...
}
'
# delete the `rare-dev-resource-harvest-index` and the `rare-dev-resource-index` aliases, and recreate them both so that they refer to `rare-dev-resource-new-physical-index`
curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'
{
"actions" : [
{ "remove" : { "index" : "rare-dev-resource-physical-index", "alias" : "resource-harvest-index" } },
{ "add" : { "index" : "rare-dev-resource-new-physical-index", "alias" : "resource-harvest-index" } },
{ "remove" : { "index" : "rare-dev-resource-physical-index", "alias" : "rare-dev-resource-index" } },
{ "add" : { "index" : "rare-dev-resource-new-physical-index", "alias" : "rare-dev-resource-index" } }
]
}
'
# once everything is running fine, remove the old physical index.
curl -X DELETE "localhost:9200/rare-dev-resource-physical-index"
```
#### Upgrading with a very short downtime (or no downtime at all)
- create a new physical index (let's name it `resource-new-physical-index`);
- delete the `rare-dev-resource-harvest-index` alias, and recreate it so that it refers to `rare-dev-resource-new-physical-index`;
- start the new application, on another machine, or on a different port, so that the new application code can be
used to trigger a harvest with the new schema, while the old application is still running and exposed to the users
- trigger the harvest on the **new** application
- once the harvest is finished, delete the `rare-dev-resource-index` alias, and recreate it so that it refers to
`rare-dev-resource-new-physical-index`;
- expose the new application to the users instead of the old one
- stop the old application
How you execute these various steps depend on the production infrastructure, which is unknown to me. You could
use your own development server to start the new application and do the harvest, and then stop the production application,
deploy the new one and start it. Or you could have a reverse proxy in front of the application, and change its
configuration to route to the new application once the harvest is done, for example.
Here are curl commands illustrating the above scenario:
```
# create a new physical index
curl -X PUT "localhost:9200/rare-dev-resource-new-physical-index" -H 'Content-Type: application/json' -d'
{
"settings": ...
}
'
# delete the `rare-dev-resource-harvest-index` alias, and recreate it so that it refers to `rare-dev-resource-new-physical-index`
curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'
{
"actions" : [
{ "remove" : { "index" : "rare-dev-resource-physical-index", "alias" : "rare-dev-resource-harvest-index" } },
{ "add" : { "index" : "rare-dev-resource-new-physical-index", "alias" : "rare-dev-resource-harvest-index" } }
]
}
'
# once the harvest is finished, delete the `resource-index` alias, and recreate it so that it refers to `resource-new-physical-index`
curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'
{
"actions" : [
{ "remove" : { "index" : "rare-dev-resource-physical-index", "alias" : "rare-dev-resource-index" } },
{ "add" : { "index" : "rare-dev-resource-new-physical-index", "alias" : "rare-dev-resource-index" } }
]
}
'
```
## Spring Cloud config
On bootstrap, the application will try to connect to a remote Spring Cloud config server to fetch its configuration.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment