mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-04-10 00:53:51 +02:00
fix and improvements in ES upgrade script
This commit is contained in:
parent
b6181f49fa
commit
c10d35a7d8
@ -1,5 +1,9 @@
|
|||||||
# Changelog Fab Manager
|
# Changelog Fab Manager
|
||||||
|
|
||||||
|
- Allow running the ElasticSearch upgrade script while being root
|
||||||
|
- Fix an issue with ES upgrade script, preventing reindexing in some cases
|
||||||
|
- Improved ES upgrade documentation
|
||||||
|
|
||||||
# v2.7.1 2018 November 27
|
# v2.7.1 2018 November 27
|
||||||
|
|
||||||
- Updated angular.js to 1.6
|
- Updated angular.js to 1.6
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
# Instructions for upgrading ElasticSearch
|
# Instructions for upgrading ElasticSearch
|
||||||
|
|
||||||
|
## Automatic upgrade
|
||||||
|
|
||||||
Fab-manager release 2.6.5 has upgraded its dependency to ElasticSearch from version 1.7 to version 5.6 as the previous was unsupported for months.
|
Fab-manager release 2.6.5 has upgraded its dependency to ElasticSearch from version 1.7 to version 5.6 as the previous was unsupported for months.
|
||||||
To keep using fab-manager you need to upgrade your installation with the new version.
|
To keep using fab-manager you need to upgrade your installation with the new version.
|
||||||
We've wrote a script to automate the process while keeping your data integrity, but there's some requirements to understand before running it.
|
We've wrote a script to automate the process while keeping your data integrity, but there's some requirements to understand before running it.
|
||||||
@ -22,6 +24,93 @@ cd /apps/fabmanager
|
|||||||
\curl https://raw.githubusercontent.com/LaCasemate/fab-manager/master/scripts/elastic-upgrade.sh | bash
|
\curl https://raw.githubusercontent.com/LaCasemate/fab-manager/master/scripts/elastic-upgrade.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Manual upgrade
|
||||||
|
|
||||||
For instructions regarding a manual upgrade, please refer to the official documentation:
|
For instructions regarding a manual upgrade, please refer to the official documentation:
|
||||||
|
|
||||||
- https://www.elastic.co/guide/en/elasticsearch/reference/2.4/restart-upgrade.html
|
- https://www.elastic.co/guide/en/elasticsearch/reference/2.4/restart-upgrade.html
|
||||||
- https://www.elastic.co/guide/en/elasticsearch/reference/5.6/restart-upgrade.html
|
- https://www.elastic.co/guide/en/elasticsearch/reference/5.6/restart-upgrade.html
|
||||||
|
|
||||||
|
## Revert the upgrade
|
||||||
|
|
||||||
|
So something goes wrong and the upgrade was not successful.
|
||||||
|
Sad news, but everything isn't lost, follow this procedure to downgrade to ElasticSearch 1.7.
|
||||||
|
|
||||||
|
First, check the status of your indices:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Replace fabmanager_elasticsearch_1 in the next command with your container's name.
|
||||||
|
# You can get it running `docker ps`
|
||||||
|
ES_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fabmanager_elasticsearch_1)
|
||||||
|
curl "$ES_IP:9200/_cat/indices?v"
|
||||||
|
```
|
||||||
|
|
||||||
|
You should get something like this:
|
||||||
|
```
|
||||||
|
health status index pri rep docs.count docs.deleted store.size pri.store.size
|
||||||
|
green open fablab_24 1 0 1944 0 1mb 1mb
|
||||||
|
green open stats_24 1 0 0 0 2.8mb 104b
|
||||||
|
green open stats 5 0 13515 0 2.7mb 2.7mb
|
||||||
|
green open fablab 5 0 1944 4 1.2mb 1.2mb
|
||||||
|
```
|
||||||
|
|
||||||
|
Here, we can see that the migration is not complete, as *docs.count* are not equal for `stat_24` and `stats`.
|
||||||
|
|
||||||
|
|
||||||
|
Now let's stop and remove the ElasticSearch container.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose stop elasticsearch
|
||||||
|
docker-compose rm -f elasticsearch
|
||||||
|
docker-compose down
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, edit your [docker-compose.yml](../docker/docker-compose.yml) and change the *elasticsearch* block according to the following:
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr><td>
|
||||||
|
<pre style="max-width:350px; overflow-y: scroll">
|
||||||
|
elasticsearch:
|
||||||
|
image: elasticsearch:2.4
|
||||||
|
ulimits:
|
||||||
|
memlock:
|
||||||
|
soft: -1
|
||||||
|
hard: -1
|
||||||
|
environment:
|
||||||
|
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
|
||||||
|
volumes:
|
||||||
|
- ${PWD}/elasticsearch/config:/usr/share/elasticsearch/config
|
||||||
|
- ${PWD}/elasticsearch:/usr/share/elasticsearch/data
|
||||||
|
restart: always
|
||||||
|
</pre>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
=>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<pre style="max-width:350px; overflow-y: scroll">
|
||||||
|
elasticsearch:
|
||||||
|
image: elasticsearch:1.7
|
||||||
|
volumes:
|
||||||
|
- ${PWD}/elasticsearch:/usr/share/elasticsearch/data
|
||||||
|
restart: always
|
||||||
|
</pre>
|
||||||
|
</td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
Restart your containers:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose pull
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you're back with ElasticSearch 1.7. You can safely restart the upgrade script.
|
||||||
|
|
||||||
|
## Debugging the upgrade
|
||||||
|
|
||||||
|
You can check for any error during container startup, using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose logs elasticsearch
|
||||||
|
```
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
http.host: 0.0.0.0
|
http.host: 0.0.0.0
|
||||||
script.inline: true
|
script.inline: true
|
||||||
script.stored: true
|
script.engine.groovy.inline.update: true
|
||||||
script.painless.regex.enabled: true
|
|
||||||
path.repo: /usr/share/elasticsearch
|
path.repo: /usr/share/elasticsearch
|
||||||
|
|
||||||
|
@ -308,6 +308,19 @@ upgrade_compose()
|
|||||||
then
|
then
|
||||||
sed -i.bak "/image: $image/s/.*/&\n ulimits:\n memlock:\n soft: -1\n hard: -1/" "$FM_PATH/docker-compose.yml"
|
sed -i.bak "/image: $image/s/.*/&\n ulimits:\n memlock:\n soft: -1\n hard: -1/" "$FM_PATH/docker-compose.yml"
|
||||||
fi
|
fi
|
||||||
|
if [ $target = '2.4' ]
|
||||||
|
then
|
||||||
|
# get current data directory
|
||||||
|
dir=$(awk 'BEGIN { FS="\n"; RS="";} { match($0, /image: elasticsearch:2\.4(\n|.)+volumes:(\n|.)+(-.*elasticsearch\/data)/, lines); FS="[ :]+"; RS="\r\n"; split(lines[3], line); print line[2] }' "$FM_PATH/docker-compose.yml")
|
||||||
|
# set the configuration directory
|
||||||
|
dir=$(echo "${dir//[$'\t\r\n ']}/config")
|
||||||
|
# insert configuration directory into docker-compose bindings
|
||||||
|
awk "BEGIN { FS=\"\n\"; RS=\"\";} { print gensub(/(image: elasticsearch:2\.4(\n|.)+)volumes:\n/, \"\\1volumes:\n - ${dir}:/usr/share/elasticsearch/config\n\", \"g\") }" "$FM_PATH/docker-compose.yml" > "$FM_PATH/.awktmpfile" && mv "$FM_PATH/.awktmpfile" "$FM_PATH/docker-compose.yml"
|
||||||
|
echo -e "\nCopying ElasticSearch 2.4 configuration files from $(pwd)/docker to $dir..."
|
||||||
|
mkdir -p "$dir"
|
||||||
|
curl -sSL https://raw.githubusercontent.com/LaCasemate/fab-manager/master/docker/elasticsearch.yml > "$dir/elasticsearch.yml"
|
||||||
|
curl -sSL https://raw.githubusercontent.com/LaCasemate/fab-manager/master/docker/log4j2.properties > "$dir/log4j2.properties"
|
||||||
|
fi
|
||||||
docker-compose pull
|
docker-compose pull
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
wait_for_online
|
wait_for_online
|
||||||
@ -351,7 +364,7 @@ upgrade_docker()
|
|||||||
then
|
then
|
||||||
image_name="elasticsearch-oss:$target"
|
image_name="elasticsearch-oss:$target"
|
||||||
image="docker.elastic.co/elasticsearch/$image_name"
|
image="docker.elastic.co/elasticsearch/$image_name"
|
||||||
elif [ $target = '5.6' ]
|
elif [ $target = '2.4' ]
|
||||||
then
|
then
|
||||||
configdir=$(echo "$volumes" | grep config | awk -F'[ :]' '{print $2}')
|
configdir=$(echo "$volumes" | grep config | awk -F'[ :]' '{print $2}')
|
||||||
echo -e "\nCopying ElasticSearch 2.4 configuration files from $(pwd)/docker to $configdir..."
|
echo -e "\nCopying ElasticSearch 2.4 configuration files from $(pwd)/docker to $configdir..."
|
||||||
@ -497,6 +510,9 @@ reindex_indices()
|
|||||||
},
|
},
|
||||||
"dest": {
|
"dest": {
|
||||||
"index": "'"$migration_index"'"
|
"index": "'"$migration_index"'"
|
||||||
|
},
|
||||||
|
"script": {
|
||||||
|
"inline": "ctx._source.remove('"'"'_id'"'"')"
|
||||||
}
|
}
|
||||||
}'
|
}'
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user