How to migrate old index from Old Server to New Server

Hi,

I have one index in old elasticsearch server in 6.2.0 version (windows server) and now I am trying to move it to new server (Linux) on 7.6.2 version of elasticsearch. I tried below command to migrate my index from old to new server but it is throwing an exception.

POST _reindex
{
"source": {
"remote": {
"host": "http://oldelasticsearchdns:9200"
},
"index": "testIndex",
"query": {
"match_all": {}
}
},
"dest": {
"index": "testIndex"
}
}

Exception I am getting is -

"type" : "illegal_argument_exception",
"reason" : "[oldelasticsearchdns:9200] not whitelisted in reindex.remote.whitelist"

Note : I did not created any index in new elastic search server. do I have to create it with my old schema and then try to execute the above command ?

As per instruction I created the index in new server with old mappings. then I tried the same command. still getting same issue :

{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "[dns:9200] not whitelisted in reindex.remote.whitelist"
}
],
"type" : "illegal_argument_exception",
"reason" : "[dns:9200] not whitelisted in reindex.remote.whitelist"
},
"status" : 400
}

Please read the docs on remote reindexing and especially the part on whitelisting: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#reindex-from-remote

I did almost same thing but still not sure why I am keep getting the same error.

while passing server name in reindex.remote.whitelist: do we need to provide old server name or current server name

You run the _reindex the current cluster (against otherhost:9200 from the docs) and you also need to whitelist otherhost:9200 on the current cluster.