mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-26 20:54:21 +01:00
fix ES upgrade script for classical docker installations
This commit is contained in:
parent
ffbe3e0b4a
commit
770ae9aaef
@ -80,10 +80,14 @@ This procedure is not easy to follow so if you don't need to write some code for
|
|||||||
Your system may provide a pre-packaged version of docker in its repositories, but this version may be outdated.
|
Your system may provide a pre-packaged version of docker in its repositories, but this version may be outdated.
|
||||||
Please refer to [ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/), [debian](https://docs.docker.com/install/linux/docker-ce/debian/) or [MacOS](https://docs.docker.com/docker-for-mac/install/) documentation to setup a recent version of docker.
|
Please refer to [ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/), [debian](https://docs.docker.com/install/linux/docker-ce/debian/) or [MacOS](https://docs.docker.com/docker-for-mac/install/) documentation to setup a recent version of docker.
|
||||||
|
|
||||||
5. Add your current user to the docker group and restart.
|
5. Add your current user to the docker group, to allow using docker without sudo.
|
||||||
This may not be required on some systems, if docker was already installed.
|
This may not be required on some systems, if docker was already installed.
|
||||||
```bash
|
```bash
|
||||||
|
# add the docker group if it doesn't already exist
|
||||||
|
sudo groupadd doker
|
||||||
|
# add the current user to the docker group
|
||||||
sudo usermod -aG docker $(whoami)
|
sudo usermod -aG docker $(whoami)
|
||||||
|
# restart to validate changes
|
||||||
sudo reboot
|
sudo reboot
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -334,8 +334,11 @@ upgrade_docker()
|
|||||||
local name=$(docker inspect -f '{{.Name}}' "$id" | sed s:^/::g)
|
local name=$(docker inspect -f '{{.Name}}' "$id" | sed s:^/::g)
|
||||||
# get container network name
|
# get container network name
|
||||||
local network=$(docker inspect -f '{{.NetworkSettings.Networks}}' "$id" | sed 's/map\[\(.*\):0x[a-f0-9]*\]/\1/')
|
local network=$(docker inspect -f '{{.NetworkSettings.Networks}}' "$id" | sed 's/map\[\(.*\):0x[a-f0-9]*\]/\1/')
|
||||||
# get container mapping to data folder
|
# get container mappings
|
||||||
local mounts=$(docker inspect -f '{{.Mounts}}' "$id" | sed 's/} {/\n/g' | sed 's/^\[\?{\?bind[[:blank:]]*\([^[:blank:]]*\)[[:blank:]]*\([^[:blank:]]*\)[[:blank:]]*true \(rprivate\)\?}\?]\?$/-v \1:\2/g' | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g')
|
local volumes=$(docker inspect -f '{{.Mounts}}' "$id" | sed 's/} {/\n/g' | sed 's/^\[\?{\?bind[[:blank:]]*\([^[:blank:]]*\)[[:blank:]]*\([^[:blank:]]*\)[[:blank:]]*true \(rprivate\)\?}\?]\?$/-v \1:\2/g')
|
||||||
|
local mounts=$(echo "$volumes" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g')
|
||||||
|
# get mapped ports
|
||||||
|
local ports=$(docker inspect -f '{{.NetworkSettings.Ports}}' "$id") | sed 's!\([0-9]*\)/tcp:\[{0\.0\.0\.0 \([0-9]*\)}\]!\1:\2!g' | sed 's/^map\[\(.*\)\]/\1/'| sed 's/^map\[\(.*\)\]/\1/' | sed 's/ / -p /' | sed 's/^/-p /'
|
||||||
prepare_upgrade
|
prepare_upgrade
|
||||||
# stop current elastic
|
# stop current elastic
|
||||||
docker stop "$name"
|
docker stop "$name"
|
||||||
@ -344,12 +347,18 @@ upgrade_docker()
|
|||||||
local image="elasticsearch:$target"
|
local image="elasticsearch:$target"
|
||||||
local image_name="$image"
|
local image_name="$image"
|
||||||
if [ $target = '6.2' ]
|
if [ $target = '6.2' ]
|
||||||
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' ]
|
||||||
|
then
|
||||||
|
configdir=$(echo "$volumes" | grep config | awk -F'[ :]' '{print $2}')
|
||||||
|
echo -e "\nCopying ElasticSearch 2.4 configuration files from $(pwd)/docker to $configdir..."
|
||||||
|
sudo cp docker/elasticsearch.yml "$configdir"
|
||||||
|
sudo cp docker/log4j2.properties "$configdir"
|
||||||
fi
|
fi
|
||||||
docker pull "$image"
|
docker pull "$image"
|
||||||
echo docker run --restart=always -d --name="$name" --network="$network" --ip="$ES_IP" "$mounts" "$image_name" | bash
|
echo docker run --restart=always -d --name="$name" --network="$network" --ip="$ES_IP" "$mounts" "$ports" "$image_name" | bash
|
||||||
wait_for_online
|
wait_for_online
|
||||||
wait_for_green_status
|
wait_for_green_status
|
||||||
# check status
|
# check status
|
||||||
@ -479,7 +488,7 @@ reindex_indices()
|
|||||||
local migration_index="$index""_$1"
|
local migration_index="$index""_$1"
|
||||||
migration_indices+="$migration_index,"
|
migration_indices+="$migration_index,"
|
||||||
# create the temporary migration index with the previous mapping
|
# create the temporary migration index with the previous mapping
|
||||||
curl -XPUT "http://$ES_IP:9200/$migration_index/" 2>/dev/null -H 'Content-Type: application/json' -d "$definition"
|
curl -XPUT "http://$ES_IP:9200/$migration_index/" 2>/dev/null -H 'Content-Type: application/json' -d "$definition"
|
||||||
# reindex data content to the new migration index
|
# reindex data content to the new migration index
|
||||||
curl -XPOST "$ES_IP:9200/_reindex?pretty" 2>/dev/null -H 'Content-Type: application/json' -d '{
|
curl -XPOST "$ES_IP:9200/_reindex?pretty" 2>/dev/null -H 'Content-Type: application/json' -d '{
|
||||||
"source": {
|
"source": {
|
||||||
@ -534,7 +543,7 @@ reindex_final_indices()
|
|||||||
local final_index=$(echo "$index" | sed "s/\(.*\)_$previous$/\1/")
|
local final_index=$(echo "$index" | sed "s/\(.*\)_$previous$/\1/")
|
||||||
final_indices+="$final_index,"
|
final_indices+="$final_index,"
|
||||||
# create the final index with the previous mapping
|
# create the final index with the previous mapping
|
||||||
curl -XPUT "http://$ES_IP:9200/$final_index" 2>/dev/null -H 'Content-Type: application/json' -d "$definition"
|
curl -XPUT "http://$ES_IP:9200/$final_index" 2>/dev/null -H 'Content-Type: application/json' -d "$definition"
|
||||||
# reindex data content to the new migration index
|
# reindex data content to the new migration index
|
||||||
curl -XPOST "$ES_IP:9200/_reindex?pretty" 2>/dev/null -H 'Content-Type: application/json' -d '{
|
curl -XPOST "$ES_IP:9200/_reindex?pretty" 2>/dev/null -H 'Content-Type: application/json' -d '{
|
||||||
"source": {
|
"source": {
|
||||||
@ -548,7 +557,7 @@ reindex_final_indices()
|
|||||||
echo "Indices are reindexing. This may take a while, waiting to finish... "
|
echo "Indices are reindexing. This may take a while, waiting to finish... "
|
||||||
# first we wait for all indices states became green
|
# first we wait for all indices states became green
|
||||||
wait_for_green_status
|
wait_for_green_status
|
||||||
# then we wait for all documents to be reindexed
|
# then we wait for all documents to be reindexed
|
||||||
local new_docs=$(curl "$ES_IP:9200/_cat/indices?index=$final_indices" 2>/dev/null | awk '{s+=$7} END {printf "%.0f", s}')
|
local new_docs=$(curl "$ES_IP:9200/_cat/indices?index=$final_indices" 2>/dev/null | awk '{s+=$7} END {printf "%.0f", s}')
|
||||||
while [ "$new_docs" != "$docs" ]
|
while [ "$new_docs" != "$docs" ]
|
||||||
do
|
do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user