elasticsearch数据迁移

本文详细介绍了如何使用Elasticsearch的快照功能进行数据备份,并在新的ES集群中恢复数据。首先,通过创建备份仓库并指定索引进行备份,接着将备份文件传输到目标集群的指定目录,最后在新集群中恢复数据。整个过程包括了数据的全量迁移和恢复操作,确保数据的安全迁移。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

方法一: 将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)查看索引
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sun_xuegang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值