博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ES数据迁移之elasticdump
阅读量:4579 次
发布时间:2019-06-09

本文共 1979 字,大约阅读时间需要 6 分钟。

1、安装步骤

如果出现以下错误:

(1)没有package.json这个文件:可以使用npm init -f命令生成一下
(2)relocation error: npm: symbol SSL_set_cert_cb, version libssl.so.10 not defined in file libss :
       先安装openssl 命令:yum install -y openssl 然后安装ws 命令:npm install ws
如果安装成功,elasticdump的默认路径在node_modules/elasticdump/bin,首先打开目录:cd node_modules/elasticdump/bin
在此目录下执行下面语句:

2、导入索引模板

elasticdump \--input=./templates.json \--output=http://es.com:9200 \--type=template

3、数据拷贝或迁移:

(1)

--type=analyzer:拷贝analyzer分词
--type=data :拷贝数据
--type=mapping  :拷贝映射(意思是把原始索引的mapping结构迁移给目标索引)
./elasticdump  --input=http://host1:9200/original --output=http://host2:9200/newCopy --type=data
elasticdump \  --input=http://production.es.com:9200/my_index \  --output=http://staging.es.com:9200/my_index \  --type=mapping

--all=trueinputoutput里不需要把索引名加上,这样就可以自动把原机器上的所有索引迁移到目标机器:

./elasticdump  --input=http://host1:9200/ --output=http://host2:9200/ --all=true

 (2)拷贝数据到一个文件:

elasticdump \  --input=http://host:9200/history_data\  --output=/home/xtt/my_index_mapping.json \  --type=mapping
elasticdump \  --input=http://host:9200/history_data\  --output=/home/xtt/my_index_mapping.json \  --type=data

(3)将数据导入多个文件,每个文件大小限定:  

elasticdump \  --input=http://production.es.com:9200/my_index \  --output=/data/my_index.json \  --fileSize=10mb

(4)备份索引到一个gzip:

elasticdump \  --input=http://host:9200/history_data \  --output=$ \  | gzip > /home/xtt/my_index.json.gz

(5)将查询结果备份到一个文件

elasticdump \  --input=http://host:9200/history_data \  --output=/home/xtt/query.json \  --searchBody='{"query":{"bool":{"filter":{"term":{"camera_id": "0115000013100"}}}}}'

(6)只备份一个shard的数据

elasticdump \  --input=http://org_host:9200/history_data \  --output=http://des_host:9200/my_index_test_ \  --params='{"preference" : "_shards:0"}'

(7)将json文件映射为索引:

elasticdump \--input=/home/xtt/my_index.json \--output=http://host:9200/history_data \--type=data

部分参考:https://blog.csdn.net/tiantang_1986/article/details/83540739

转载于:https://www.cnblogs.com/zling/p/10429191.html

你可能感兴趣的文章
HTML元素控件事件表
查看>>
通过Ajax方式上传文件(input file),使用FormData进行Ajax请求
查看>>
古诗词 中文 分词 自动化
查看>>
Frameworks.Entity.Core 7
查看>>
IE6/IE7下:inline-block解决方案
查看>>
匿名函数递归
查看>>
客户端存储
查看>>
QLabel播放gif
查看>>
appium+python自动化39-adb shell输入中文(ADBKeyBoard)
查看>>
HBase批量插入的简单代码
查看>>
为什么要去创业?
查看>>
JBoss 系列十七:使用JGroups构建块MessageDispatcher 构建群组通信应用
查看>>
ajax交互Struts2的action(1)
查看>>
数据结构与算法 多种排序算法
查看>>
Vijos P1794 文化之旅
查看>>
Coding源码学习第四部分(Masonry介绍与使用(一))
查看>>
Bug 汇总
查看>>
Windows Desktop Optimization.bat
查看>>
操作数据库,增删改查
查看>>
[jAudio] JAVA上经典特征提取工具
查看>>