Created
December 18, 2019 18:29
-
-
Save doohee323/7883fc3028b5d01bbbe1951f3bd8c60c to your computer and use it in GitHub Desktop.
Upgrade Elasticsearch from 6.4 to 6.8 on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| ############################################################################################ | |
| echo Upgrade Elasticsearch from 6.4 to 6.8 on Ubuntu | |
| # cf. https://www.elastic.co/guide/en/elasticsearch/reference/current/rolling-upgrades.html | |
| ############################################################################################ | |
| ############################################################################################ | |
| echo 1. Disable shard allocation. | |
| ############################################################################################ | |
| curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d' | |
| { | |
| "persistent": { | |
| "cluster.routing.allocation.enable": "primaries" | |
| } | |
| } | |
| ' | |
| ############################################################################################ | |
| echo 2. Stop sync flush | |
| ############################################################################################ | |
| curl -XPOST 'localhost:9200/_flush/synced' -H 'Content-Type: application/json' | |
| ############################################################################################ | |
| echo 3. Remove plugins | |
| ############################################################################################ | |
| curl -XGET 'localhost:9200/_cat/plugins' | |
| cd /usr/share/elasticsearch/bin | |
| ./elasticsearch-plugin remove discovery-ec2 | |
| ./elasticsearch-plugin remove ingest-user-agent | |
| ./elasticsearch-plugin remove repository-s3 | |
| ############################################################################################ | |
| echo 4. Upgrade elasticsear | |
| ############################################################################################ | |
| sudo service elasticsearch stop | |
| export USER=elasticsearch | |
| export PROJ_NAME=elk | |
| export PROJ_DIR=/home/$USER | |
| export SRC_DIR=$PROJ_DIR/crew-elk/resources | |
| ELASTIC_VERSION=6.8.0 | |
| ELASTICSEARCH_VERSION=6.8.0 | |
| KIBANA_VERSION=6.8.0 | |
| cd $PROJ_DIR | |
| sudo wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
| #sudo apt autoremove | |
| sudo apt-get install apt-transport-https -y | |
| sudo echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list | |
| sudo apt-get update -y | |
| sudo apt-get install -y openjdk-8-jdk -y | |
| sudo apt install python-pip -y | |
| echo "[INFO] Installing Elasticsearch..." | |
| sudo apt-get install elasticsearch=$ELASTICSEARCH_VERSION -y | |
| /usr/share/elasticsearch/bin/elasticsearch --version | |
| ############################################################################################ | |
| echo 5. Reinstall plugins | |
| ############################################################################################ | |
| cd /usr/share/elasticsearch/bin | |
| ./elasticsearch-plugin install discovery-ec2 | |
| ./elasticsearch-plugin install repository-s3 | |
| ############################################################################################ | |
| echo 6. restart elasticsearch | |
| ############################################################################################ | |
| sudo service elasticsearch start | |
| sleep 20 | |
| ############################################################################################ | |
| echo 7. Reenable shard allocation. | |
| ############################################################################################ | |
| curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d' | |
| { | |
| "persistent": { | |
| "cluster.routing.allocation.enable": null | |
| } | |
| } | |
| ' | |
| ############################################################################################ | |
| echo 8. Reinstall Kibana | |
| ############################################################################################ | |
| /usr/share/kibana/bin/kibana-plugin list | |
| sudo apt-get install kibana=$KIBANA_VERSION -y | |
| service kibana restart | |
| exit 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment