1.從old-cluster中查出template,然後在new-cluster中導入template:
curl -X PUT "http://new-ip:9200/_template/template_name" -H "Content-Type: application/json" -d 'template內容'
2.創建index:
curl -X PUT "http://new-ip:9200/index_name"
3.按照官方指導將refresh_interval設置爲-1,number_of replica設置爲0
curl -X PUT -u username:password "http://new-ip:9200/_settings?pretty" -H 'Content-Type: application/json' -d '
{
"index" : {
"number_of_replicas" : 0
}
}
'
curl -X PUT -u username:password "http://new-ip:9200/_settings?pretty" -H 'Content-Type: application/json' -d '
{
"index" : {
"refresh_interval" : "-1"
}
}
'
4.在new-cluster的機器上的elasticsaerch.yml中添加如下配置,然後重啓new cluster:
reindex.remote.whitelist: old-ip:9200
5.執行reindex:
curl -X PUT "http://new-ip:9200/_reindex?wait_for_completion=false" -H 'Content-Type: application/json' -d '
{
"source": {
"remote": {
"host": "http://old-ip:9200",
"username": "xxx",
"password": "xxxx"
},
"index": "index-on-old-cluster",
"size": 10
},
"dest": {
"index": "index-on-new-cluster"
}
}
'
6.執行上一步時會返回一個task_id,我們可以根據task_id查看reindex的進度:
http://new-ip:9200/_task/taskid