Created
November 26, 2020 00:23
-
-
Save rodrickbrown/64b4191b3649fff2ee1544f61b04618d to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
source_cluster=es-eks.npe-estest-euw1.euw1.rms-npe-internal.com | |
target_cluster=es-eks2.npe-estest-euw1.euw1.rms-npe-internal.com | |
# We need to set reindex.remote.whitelist in elasticsearch.yml on the new cluster | |
# reindex.remote.whitelist: oldhost:9200 | |
indexes=$(http -a elastic:xxxxxxx http://${source_cluster}/_cat/indices | awk '/green/ { print $3 }') | |
function listIndexes { | |
http -a elastic:xxxxxx http://${source_cluster}/_cat/indices | |
} | |
function reindex { | |
listIndexes | |
sleep 5; | |
for index in ${indexes}; | |
do | |
http -a elastic:g2nZchOBhyJ78YviR7Rr POST ${target_cluster}/_reindex?wait_for_completion=false <<< \ | |
'{ "source": | |
{ | |
"remote": | |
{ | |
"host": "'http://${source_cluster}:80'", | |
"username": "elastic", | |
"password": "xxxxxxxxxx" | |
}, | |
"index": "'$index'" | |
}, | |
"dest": | |
{ | |
"index": "'$index'-reindexed-rod" | |
} | |
}' | |
done | |
} | |
reindex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment