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