elasticsearch reindex步驟

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

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章