使用elasticdump数据备份和迁移
工具安装
npm install elasticdump -g# 不用的话可以删除npm uninstall elasticdump -g
直接数据迁移
# Copy an index from production to staging with analyzer and mapping:elasticdump \--input=http://production.es.com:9200/my_index \--output=http://staging.es.com:9200/my_index \--type=analyzerelasticdump \--input=http://production.es.com:9200/my_index \--output=http://staging.es.com:9200/my_index \--type=mappingelasticdump \--input=http://production.es.com:9200/my_index \--output=http://staging.es.com:9200/my_index \--type=data \--limit=10000 # 默认是100,速度很慢
ip->文件->ip
# 导出索引Mapping数据elasticdump \--input=http://es实例IP:9200/index_name/index_type \--output=/data/my_index_mapping.json \ # 存放目录--type=mapping# 导出索引数据elasticdump \--input=http://es实例IP:9200/index_name/index_type \--output=/data/my_index.json \--type=data \--limit=10000 # 默认是100,速度很慢======================================================# Mapping 数据导入至索引elasticdump \--output=http://es实例IP:9200/index_name \--input=/home/indexdata/roll_vote_mapping.json \--type=mapping# ES文档数据导入至索引elasticdump \--output=http:///es实例IP:9200/index_name \--input=/home/indexdata/roll_vote.json \--type=data
实例:
# 导出elasticdump \--input=http://elastic:123456@10.20.222.188:9200/people/man \--output=/c/Users/1/Desktop/my_index_mapping.json \--type=mappingelasticdump \--input=http://elastic:123456@10.20.222.188:9200/people/man \--output=/c/Users/1/Desktop/my_index.json \--type=data \--limit=10000# 导入elasticdump \--output=http://elastic:123456@10.20.222.188:9200/people2 \--input=/c/Users/1/Desktop/my_index_mapping.json \--type=mappingelasticdump \--output=http://elastic:123456@10.20.222.188:9200/people2 \--input=/c/Users/1/Desktop/my_index.json \--type=data \--limit=10000
