Migrate Elasticsearch Index to OpenSearch Index.
As you already know that Elasticsearch is not open source anymore. Hence everybody looking for a good alternative, in this case OpenSearch could be a good option. Now i will share my experience how i migrate Elasticsearch-6.8.21 index into OpenSearch-2.2.0.
Step01: Configure OpenSearch
Open your OpenSearch configuration file and add below lines at the end of the file and and restart the service.
vim /etc/opensearch/opensearch.yml
compatibility.override_main_response_version: true
reindex.remote.whitelist: 192.168.100.10:9200 [Here IP will be ElasticSearch IP]
# systemctl restart opensearch
Step02: Check ElasticSearch Index
curl -XGET -u admin:admin "http://192.168.100.10:9200/_cat/indices?v"
You will get result as like below:
Step03: Import ElasticSearch index into Opensearch
# curl -u admin:admin -X POST "http://192.168.100.11:9200/_reindex" -H 'Content-Type: application/json' -d'
{
"source": {
"remote": {
"host": "http://192.168.100.10:9200",
"username": "admin",
"password": "admin"
},
"index": "winlogbeat-2022.10.17"
},
"dest": {
"index": "winlogbeat-2022.10.17"
}
}
'
After finish the process check the OpenSearch Indexes.
# curl -XGET -u admin:admin "http://192.168.100.11:9200/_cat/indices?v"
You will get result as like below:
Hope this will help you.
Bonus:
You cloud try below script if you have lots of indexs.
for index in i1 i2 i3 i4 i5; do
curl -HContent-Type:application/json -XPOST localhost:9200/_reindex?pretty -d'{
"source": {
"index": "'$index'"
},
"dest": {
"index": "'$index'-reindexed"
}
}'
done