方法一: 将data整个目录拷贝到新的es集群即可
方法二: 先备份数据 然后将备份数据拷贝到新的es集群 再恢复数据
1.在老的es服务器备份数据
(1)创建es备份仓库
$ curl -u elastic:yourpass -XPOST '172.16.2.99:9200/_snapshot/hsbc_backup' -H 'Content-Type: application/json' -d '{ "type": "fs", "settings": { "location": "/alidata1/admin/backup/elasticsearch/", "compress": true, "chunk_size": "1g", "max_snapshot_bytes_per_sec": "50m", "max_restore_bytes_per_sec": "50m"}}'
(2)获取要备份的索引
$ curl -u elastic:yourpass -XGET http://172.16.2.99:9200/_cat/indices?v |awk '{print $3}'
(3)备份数据,注意.security-6不需要备份
curl -u elastic:yourpass -H "Content-Type: application/json" -XPUT http://172.16.2.99:9200/_snapshot/hsbc_backup/es_20200808_1 -d '{"indices": "search_hq_xman_msg,search_hq_xman_mengwang_up,search_hq_xman_mail_send,hq_xman_webchat_send,search_hq_xman_wechatcustome_send,adm_hq_user_insur_and_insured_info_label_20200304,adm_hq_user_info_label_20200304,search_hq_xman_apppush_send,search_hq_xman_webchat_send,adm_hq_user_info_all_label_20200304,search_hq_xman_wechatmp_send,search_hq_xman_mengwang_msg_history,search_hq_xman_mengwang_msg,mapindex,search_hq_xman_wechatgroup_send"}'
2.将备份文件打包压缩 发送到要恢复的es的repo.path指定的目录下
3.将数据恢复到新的es
(1)创建和原来es一样的备份仓库
$ curl -u elastic:123456 -XPOST '192.168.43.104:9200/_snapshot/hsbc_backup' -H 'Content-Type: application/json' -d '{ "type": "fs", "settings": { "location": "/alidata1/admin/backup/elasticsearch/", "compress": true, "chunk_size": "1g", "max_snapshot_bytes_per_sec": "50m", "max_restore_bytes_per_sec": "50m"}}'
(2)查看下当前索引
(3)数据恢复
$ curl -u elastic:123456 -XPOST 'http://192.168.43.104:9200/_snapshot/hsbc_backup/es_20200808_1/_restore' -H 'Content-Type: application/json' -d'{ "ignore_unavailable": true, "include_global_state": false }'
(4)查看索引