前言
在进行ES数据迁移的时候,由于一些原因需要将索引进行备份到本地,然后在导入到新的ES集群中
一、操作流程
- 安装备份索引工具elasticdump
- 导出索引(备份操作)
- 在合适的时间清除旧的EFK集群
- 部署新的EFK集群
- 恢复数据
二、执行操作
1、安装elasticdump
#本地安装,使用mac或者linux
sudo npm install elasticdump -g
2、备份数据
#备份mapping:
elasticdump --input=http://127.0.0.1:9200/lux-prod-2023.07.10 --output=lux-prod-2023.07.10-mapping.json --type=mapping --limit=2000
#备注:备份数据文件
elasticdump --input=http://127.0.0.1:9200/lux-prod-2023.07.13 --output=lux-prod-2023.07.13.json --type=data --limit=2000
3、导入索引
#备注:因为新的ES集群是有用户名密码的,需要创建auth.ini文件:
vim auth.ini
user=elastic
password=xxxxxxx
#备注:提前创建好索引:
curl -k -u elastic:xxxxxxx -XPUT -H "Content-Type: application/json" https://elasticsearch-client:9200/lux-prod-2023.07.10 -d '{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}'
#备注:新的ES集群是通过自签证书加密的,需要使用域名和https:域名可以通过hosts,证书不受信任,所以需要忽略
忽略证书:
export NODE_TLS_REJECT_UNAUTHORIZED=0
导入索引:
elasticdump --httpAuthFile=./auth.ini --input=lux-prod-2023.07.10.json --output=https://elasticsearch-client:9200 --type=data --limit=2000
4、查看索引释放导入成功即可。
【完成】

4066

被折叠的 条评论
为什么被折叠?



