你可以的,加油

发布个es迁移工具:elasticsearch-migration

Elasticsearch | 作者 medcl | 发布于2016年05月23日 | | 阅读数:31819

https://github.com/medcl/elasticsearch-migration
支持多个版本间的数据迁移,使用scroll+bulk
1.版本支持1.x,2.x.5.0 (0.x未测试)
2.支持http basic auth 认证的es集群
3.支持导入覆盖索引名称(目前只支持单个索引导入的情况下可指定)
4.支持index setting和mapping的同步(相关es大版本,2.x和5.0之间不支持)
5.支持dump到本地文件
6.支持从dump文件加载导入到指定索引
 
欢迎测试!
 
#copy index index_name from 192.168.1.x to 192.168.1.y:9200
./bin/esm -s http://192.168.1.x:9200 -d http://192.168.1.y:9200 -x index_name -w=5 -b=10 -c 10000

#copy index src_index from 192.168.1.x to 192.168.1.y:9200 and save with dest_index
./bin/esm -s http://localhost:9200 -d http://localhost:9200 -x src_index -y dest_index -w=5 -b=100

#support Basic-Auth
./bin/esm -s http://localhost:9200/ -x "src_index" -y "dest_index" -d http://localhost:9201 -n admin:111111

#copy settings and override shard size
./bin/esm -s http://localhost:9200/ -x "src_index" -y "dest_index" -d http://localhost:9201 -m admin:111111 -c 10000 --shards=50 --copy_settings

#copy settings and mapping, recreate target index, add query to source fetch, refresh after migration
./bin/esm -s http://localhost:9200/ -x "src_index" -q=query:phone -y "dest_index" -d http://localhost:9201 -c 10000 --shards=5 --copy_settings --copy_mapping --force --refresh

#dump elasticsearch documents into local file
./bin/esm -s http://localhost:9200 -x "src_index" -m admin:111111 -c 5000 -b -q=query:mixer --refresh -o=dump.bin

#loading data from dump files, bulk insert to another es instance
./bin/esm -d http://localhost:9200 -y "dest_index" -n admin:111111 -c 5000 -b 5 --refresh -i=dump.bin

 

[尊重社区原创,转载请保留或注明出处]
本文地址:http://elasticsearch.cn/article/id-78__page-2


135 个评论

it should be "copy_mappings"
后来怎么解决的?
执行命令如下:
./esm -sxxl:9200 -d xx:9200 -x bai -y bai -w=10 -b=10 -c 10000
结果如下:
Scroll 0 / 16126730 [---------------------------------------------------------------------------------------------------------------------------------------------] 0.00%
Scroll 0 / 16126730 [---------------------------------------------------------------------------------------------------------------------------------------------] 0.00%
Output 0 / 16126730 [--------------------------------------------------------------------------------------------------------------------------------------------] 0.00%

一直卡在这个界面,目标集群也没有建立索引和同步数据!?请问这个是什么原因,
版本是2.3->2.3
执行的时候url加了http,这里没加是发帖审核的时候不让贴,系统审核认为是外部链接
你好,我的elasticsearch版本是6.1.4,数据使用了join类型,使用楼主工具迁移数据出现一个问题。总共有6条数据,日志显示6条都成功,但是es中只查到3条。(我的数据总共三层,如a<---b<---c),最终es只有最上层a的数据,请问工具对join的支持情况?
join暂时不支持,routing 值没有处理
只能一个一个索引进行迁移嘛? 可以把所有的索引一次性全部迁移过来的嘛?
Scroll 26638383 / 26638383 [======================================================================================] 100.00% 17m39sBulk 26636538 / 26638383 [========================================================================================] 99.99% 18m14s
[01-25 15:34:25] [INF] [main.go:424,main] data migration finished.

[01-25 15:34:26] [INF] [main.go:401,main] start data migration..
Scroll 26425818 / 26425818 [===============================================================================================================================================================================================================================] 100.00% 18m54s
Bulk 26423983 / 26425818 [=================================================================================================================================================================================================================================] 99.99% 19m20s
[01-25 15:53:47] [INF] [main.go:424,main] data migration finished.

每次都剩一点没迁移过去,命令: ./esm -s http://192.168.35.49:9200 -d http://192.168.35.50:9200 -x filebeat-6.1.2-2019.01.21 -a -w=5 -b=10 -c=10000 是不是我少加了什么参数?
centos7下 导出数据报错
http://192.168.123.11:9200/_search/scroll?scroll=5m&scroll_id=c2Nhbjs0OzY2OlJvWnRQS3ptVDFPNnVTdE1OekVGMEE7NjU6Um9adFBLem1UMU82dVN0TU56RUYwQTs2NzpSb1p0UEt6bVQxTzZ1U3RNTnpFRjBBOzY4OlJvWnRQS3ptVDFPNnVTdE1OekVGMEE7MTt0b3RhbF9oaXRzOjI2OTQ2MDs=
[02-19 14:19:28] [ERR] [scroll.go:49,Next] {"_scroll_id":"c2NhbjswOzE7dG90YWxfaGl0czoyNjk0NjA7","took":1,"timed_out":false,"_shards":{"total":4,"successful":0,"failed":0},"hits":{"total":269460,"max_score":0.0,"hits":[]}}
http://192.168.123.11:9200/_search/scroll?scroll=5m&scroll_id=c2Nhbjs0OzY2OlJvWnRQS3ptVDFPNnVTdE1OekVGMEE7NjU6Um9adFBLem1UMU82dVN0TU56RUYwQTs2NzpSb1p0UEt6bVQxTzZ1U3RNTnpFRjBBOzY4OlJvWnRQS3ptVDFPNnVTdE1OekVGMEE7MTt0b3RhbF9oaXRzOjI2OTQ2MDs=
[08-21 09:31:43] [ERR] [scroll.go:49,Next] {"error":{"root_cause":[{"type":"too_long_frame_exception","reason":"An HTTP line is larger than 4096 bytes."}],"type":"too_long_frame_exception","reason":"An HTTP line is larger than 4096 bytes."},"status":400}

./esm -s http://10.27.69.118:9200 -a -c 5000 -b 5 --refresh -o=dump.bin
es 6.5.4 >> 7.2.0

另外给个建议
./esm -s http://10.27.69.118:9200 -x djcpslog-* -c 5000 -b 5 --refresh -o=dump.bin ### -x 这里可以支持*通配符吗
medcl

medcl 回复 wajika

支持通配符的,索引两边要带上“”才行
medcl

medcl 回复 hewww11

使用_all作为索引名就可以
wajika

wajika 回复 medcl

An HTTP line is larger than 4096 bytes 这个是什么意思
medcl

medcl 回复 wajika

一次索引太多会造成 HTTP请求太长了 ,修改 es 的参数可以调整:

http.max_initial_line_length: "8k"

http.max_header_size: "16k"
wajika

wajika 回复 medcl

好的 我试试
作者你好,请问一下migration能在采集器正常采集的情况下进行数据迁移么,会丢数据么
medcl

medcl 回复 wanghn

新增的数据要重新跑一次,可以加上时间条件过滤只跑新的数据
您好,medcl大神,打扰您,像您请请教个问题。昨天我使用您的esm v0.4.3版本,进行es数据复制。使用过程中,命令执行的服务器会突然卡死,无法连接,console也无法连接,监控数据不再更新,在能看到的最后监控也没有太多异常,会有cpu使正常占用和上下文切换较高,然后就突然夯住了。命令是 esm -s http://aaa -d http://bbb -x ccc -y bbb -w 5 --sluced_scroll_size=5 。我们有6个集群,基本容量一样,昨天执行备份多个索引,出现2个服务器hangs情况,不敢再执行了,请问您能指点一下可能的原因吗?
您好,medcl大神,打扰您,像您请请教个问题。昨天我使用您的esm v0.4.3版本,进行es数据复制。使用过程中,命令执行的服务器会突然卡死,无法连接,console也无法连接,监控数据不再更新,在能看到的最后监控也没有太多异常,会有cpu使正常占用和上下文切换较高,然后就突然夯住了。命令是 esm -s http://aaa -d http://bbb -x ccc -y bbb -w 5 --sluced_scroll_size=5 。我们有6个集群,基本容量一样,昨天执行备份多个索引,出现2个服务器hangs情况,不敢再执行了,请问您能指点一下可能的原因吗?

@medcl 大神,请您指点一下,非常感谢啊。
您好,medcl大神,打扰您,像您请请教个问题。昨天我使用您的esm v0.4.3版本,进行es数据复制。使用过程中,命令执行的服务器会突然卡死,无法连接,console也无法连接,监控数据不再更新,在能看到的最后监控也没有太多异常,会有cpu使正常占用和上下文切换较高,然后就突然夯住了。命令是 esm -s http://aaa -d http://bbb -x ccc -y bbb -w 5 --sluced_scroll_size=5 。我们有6个集群,基本容量一样,昨天执行备份多个索引,出现2个服务器hangs情况,不敢再执行了,请问您能指点一下可能的原因吗?
copy_mapping后面有s,你可以去掉这个参数,另外相同版本才建议直接copy mapping
请问下,我是5.x数据迁移到7.x;出现了[root@k8s-master-3 linux64]# ./esm -s http://10.1.171.194:9203 -d http://172.31.131.9:9200 -x iotlogindex-2020-02-21 -w=5 -b=100
[04-20 20:33:40] [INF] [main.go:454,main] start data migration..
Scroll 10145 / 10145 [=====================================================================================================================================================================] 100.00% 5s
Bulk 0 / 10145 [------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0.00%
{"took":4963,"errors":true,"items":[{"index":{"_index":"iotlogindex-2020-02-21","_type":"iotPlatformOpenApiLog","_id":"AXB7ie7QHau-bHj3KaJr","status":400,"error":{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [iotlogindex-2020-02-21] as the final mapping would have more than 1 type: [_doc, iotPlatformOpenApiLog]"}}}
这个需要怎么处理?
es 新版本只支持一个 type,@wenlinzou 加参数 -u "_doc" 来统一 type
请教一下大神,我用你的esm的迁移es的工具,数据从2.x迁移到7.x,命令是:
./esm -s http://xx.xx.xx.xx:80 -x "month_news_zh-cn_201601_v_1" -y "month_news_zh-cn_201601_v_1" -d http://xx.xx.xx.xx:9200 -u "_doc"
报错是:
Scroll 6967 / 6967 [=======================================================================================================================================================================================================] 100.00% 13sBulk 6739 / 6967 [===================================================================================================================================================================================================>------] 96.73% 0s
server error: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_routing]"}],"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_routing]"},"status":400}
[05-11 11:42:57] [ERR] [v0.go:79,Bulk] server error: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_routing]"}],"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_routing]"},"status":400}
server error: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_routing]"}],"type":"illegal_argument_exception","reason":"Action/metadata line [1] contains an unknown parameter [_routing]"},"status":400}
这个是什么原因呢
2.几啊?我试试
2.3.5-》7.2.0
我用6.4.3 -> 7.2.0也是会有这个问题
已修复,使用最新的 0.4.4 版本
请问如何后台运行,并能在后台日志中看到进度条呢
两种方法,第一种可以使用 screen 命令来切后台,第二种是使用 nohup 和&切换到后台,不过这种方法就不能显示进度条了。
支持aliases 导出吗?
medcl

medcl 回复 mie

支持
mie

mie 回复 medcl

但我使用v0.5.0版本的esm命令,执行esm -s elastic:changeme@xxx:9200 -d elastic:changeme@xxx:9200 -x other_v1 -w=5 -b=10 -c 10000 -a --all --copy_settings --copy_mappings --force --refresh ,
导入后查看GET _other_v1/_alias是少别名的,是使用的参数不对吗
参考 GitHub 里面的 readme,copy-mapping 不建议用了,建议手动提取创建好索引,确认没问题之后再使用 esm 导数据,主要是各种版本之间不兼容,比较难处理,如果等到倒完数据再检查 mapping 就比较麻烦,要重新倒。
如何自己编译安装新版的迁移工具,例如v0.6.0或v0.6.1
目前可以支持多个索引dump到本地,然后再导入集群吗?

要回复文章请先登录注册