支持多个版本间的数据迁移,使用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://searchkit.cn/article/id-78
135 个评论
我是ubuntu14.04,直接下的和build的我都试了一下,都没有什么反应
-q, --query= query against source elasticsearch instance, filter data before migrate, ie: name:medcl
支持DSL吗?
1 最新代码, ubuntu 14.04 下 make all-platform 生成结果,启动自动退出
2 解析 epoch_millis 字段时候,会中 json.Unmarshal 的坑,吧 int64 变成科学计数法字符串,改成 Decoder.UseNumber 好一些
rm -rif bin
mkdir bin
get Dependencies
go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/jianxinyu/elasticsearch-migration:"
GORACE=""
GOROOT="/usr/lib64/golang"
GOTOOLDIR="/usr/lib64/golang/pkg/tool/linux_amd64"
TERM="dumb"
CC="gcc"
GOGCCFLAGS="-g -O2 -fPIC -m64 -pthread"
CXX="g++"
CGO_ENABLED="1"
go get gopkg.in/cheggaaa/pb.v1
停在这一步没反应了... ...
[m@test-master-01 /root/jianxinyu]$
执行命令bin/linux64/esm,没有反应,麻烦看下
medcl 回复 aaronhadoop
aaronhadoop 回复 medcl
[root@test-master-01 ~/jianxinyu]# tar -zxvf linux64.tar.gz
[root@test-master-01 ~/jianxinyu]# bin/linux64/esm
[root@test-master-01 ~/jianxinyu]# bin/linux64/esm -s
[root@test-master-01 ~/jianxinyu]# bin/linux64/esm -xxx
[root@test-master-01 ~/jianxinyu]#
都没有什么反应(我的系统是CentOS 6.2)
请教下,这个是为什么呢
C:\Users\jianxinyu\Desktop\elasticsearch-migration\bin\windows32>esm.exe
和64位的
C:\Users\jianxinyu\Desktop\elasticsearch-migration\bin\windows64>esm.exe
敲回车后,都没有什么响应,请问有可以用的朋友吗
可否麻烦先帮忙看下linux下为何不能用吧(我的linux环境是Centos 6.2,下载的版本是linux64.tar.gz),万分感谢
@medcl 可否方便留下你的联系方式,交流方便些
medcl 回复 aaronhadoop
(我的联系方式,手机:18588497759,QQ:1152596901)
medcl 回复 aaronhadoop
我这边在测试大数据量操作时,数据导出失败,我再测试整理下,有问题的话,再请教交流。
medcl 回复 aaronhadoop
我自己用Java写了个工具,先把ES中的数据导出到本地文件,再把文件导入到另外的ES集群。
medcl 回复 aaronhadoop
./bin/esm -s http://10.10.104.145:9200 -d http://10.10.106.91:9200 -x hn-alarm-20170118 -w=5 -b=10 -c=10000
这是我的命令
medcl 回复 jingpeiyang
现在支持2.x 到 5.x 的index setting和mapping的同步吗?
现在用的是2.3.4 有300G数据,怎么能快速升级到5.5.x版本?请赐教
[10-09 21:30:33] [ERR] [main.go:100,main] No handler found for uri [/'/ngr_lft-test/test50nightly'/_search?scroll=1m&search_type=scan&size=1000] and method [POST]
windows 的 迁移 老报这个错 是什么原因
Scroll 0 / 205 [---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0.00%
Scroll 205 / 205 [==================================================================================================================================================================================================================================================================================] 100.00% 1s
Scroll 205 / 205 [==================================================================================================================================================================================================================================================================================] 100.00% 1s
Output 0 / 205 [--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------] 0.00%
参数修改了, 执行后一直卡在这不动了,linux 和windows都试了,都同样这个问题,麻烦帮看看,谢谢
版本为:esm-0.3.4.zip,直接下载使用的
src_index有208条记录
导出文件src_index.bin 也208条记录
但重新导入会该集群只有156条记录
./esm -s http://10.24.8.XX:9200 -x "src_index" --refresh -o=src_index.bin
./esm -d http://10.24.8.XX:9200 -y "dest_index" --refresh -i=src_index.bin
src_index有208条记录
导出文件src_index.bin 也208条记录
但重新导入会该集群只有156条记录
./esm -s http://10.24.8.XX:9200 -x "src_index" --refresh -o=src_index.bin
./esm -d http://10.24.8.XX:9200 -y "dest_index" --refresh -i=src_index.bin
可以怎么解决呢?
以下方式都不行:
make build 和
go build -gcflags "-N -l" -o ./esm ./*.go
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="xxx"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build872736006=/tmp/go-build"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/medcl/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/r4/fp0jznxj48z8_g_dcdv1f5lh0000gn/T/go-build959804095=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
medcl 回复 xinfanwang
[04-02 15:04:23] [ERR] [v0.go:240,UpdateIndexMapping] http://x.x.x.x:9200/production_shop_nginx_err-2018.04.01/production_shop_nginx_err/_mapping
[04-02 15:04:23] [ERR] [v0.go:241,UpdateIndexMapping]
[04-02 15:04:23] [ERR] [v0.go:242,UpdateIndexMapping] server error: {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"production_shop_nginx_err-2018.04.01","index_uuid":"_na_","index":"production_shop_nginx_err-2018.04.01"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"production_shop_nginx_err-2018.04.01","index_uuid":"_na_","index":"production_shop_nginx_err-2018.04.01"},"status":404}
panic: server error: {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"production_shop_nginx_err-2018.04.01","index_uuid":"_na_","index":"production_shop_nginx_err-2018.04.01"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"production_shop_nginx_err-2018.04.01","index_uuid":"_na_","index":"production_shop_nginx_err-2018.04.01"},"status":404}
goroutine 1 [running]:
main.(*ESAPIV0).UpdateIndexMapping(0xc423130810, 0xc423117770, 0x24, 0xc423130f60, 0xc421a81d40, 0xc423211eb8)
/Users/medcl/BTSync/github/elasticsearch-migration/v0.go:243 +0x9ad
main.(*ESAPIV5).UpdateIndexMapping(0xc423130810, 0xc423117770, 0x24, 0xc423130f60, 0xc421a81dc8, 0xc4231421a0)
/Users/medcl/BTSync/github/elasticsearch-migration/v5.go:59 +0x4b
main.main()
/Users/medcl/BTSync/github/elasticsearch-migration/main.go:364 +0x2a1e
请问这个报错是啥意思,我用的这个命令
./esm -s http://172.x.x.x:9200 -d http://x.x.x.x:9200 -x "production_shop_nginx_err-2018.04.01" -y "production_shop_nginx_err-2018.04.01" -w=5 -b=10 -c 10000 --copy_settings --copy_mappings --force --refresh
但是我不加--copy_mappings就可以迁移成功,但是到99%就finish了
# cd .; git clone https://github.com/mattn/go-runewidth /usr/local/src/esm-master/src/github.com/mattn/go-runewidth
Initialized empty Git repository in /usr/local/src/esm-master/src/github.com/mattn/go-runewidth/.git/
error: while accessing https://github.com/mattn/go-runewidth/info/refs
fatal: HTTP request failed
package github.com/mattn/go-runewidth: exit status 128
package golang.org/x/sys/unix: unrecognized import path "golang.org/x/sys/unix" (https fetch: Get https://golang.org/x/sys/unix?go-get=1: dial tcp 216.239.37.1:443: getsockopt: connection timed out)
make: *** [config] Error 1
这个是git链接有问题吗?请解????
我看只写了5.0
另外 要把一个实例的所有数据全部迁移到另外一个实例怎么操作呢?
刚用了没几天es 就赶上一个迁移的事情,对es还没啥了解
求大神帮助
net/http.(*persistConn).writeLoop(0xc58b5da000)
/usr/local/Cellar/go/1.10.2/libexec/src/net/http/transport.go:1822 +0x14b
created by net/http.(*Transport).dialConn
/usr/local/Cellar/go/1.10.2/libexec/src/net/http/transport.go:1238 +0x97f
goroutine 579 [IO wait]:
internal/poll.runtime_pollWait(0x7f041a7a56e0, 0x72, 0xc424a859a8)
/usr/local/Cellar/go/1.10.2/libexec/src/runtime/netpoll.go:173 +0x57
internal/poll.(*pollDesc).wait(0xc5770a8418, 0x72, 0xffffffffffffff00, 0x813aa0, 0x98c260)
/usr/local/Cellar/go/1.10.2/libexec/src/internal/poll/fd_poll_runtime.go:85 +0x9b
internal/poll.(*pollDesc).waitRead(0xc5770a8418, 0xc5e8a62000, 0x1000, 0x1000)
/usr/local/Cellar/go/1.10.2/libexec/src/internal/poll/fd_poll_runtime.go:90 +0x3d
internal/poll.(*FD).Read(0xc5770a8400, 0xc5e8a62000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.10.2/libexec/src/internal/poll/fd_unix.go:157 +0x17d
net.(*netFD).Read(0xc5770a8400, 0xc5e8a62000, 0x1000, 0x1000, 0x4515f0, 0xc422a38780, 0x4)
/usr/local/Cellar/go/1.10.2/libexec/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc4228b8008, 0xc5e8a62000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.10.2/libexec/src/net/net.go:176 +0x6a
net/http.(*persistConn).Read(0xc58b5da000, 0xc5e8a62000, 0x1000, 0x1000, 0xc424a85b98, 0x403355, 0xc55c8922a0)
/usr/local/Cellar/go/1.10.2/libexec/src/net/http/transport.go:1453 +0x136
bufio.(*Reader).fill(0xc61d238180)
/usr/local/Cellar/go/1.10.2/libexec/src/bufio/bufio.go:100 +0x11e
bufio.(*Reader).Peek(0xc61d238180, 0x1, 0x0, 0x0, 0x1, 0xc55c8930e0, 0x0)
/usr/local/Cellar/go/1.10.2/libexec/src/bufio/bufio.go:132 +0x3a
net/http.(*persistConn).readLoop(0xc58b5da000)
/usr/local/Cellar/go/1.10.2/libexec/src/net/http/transport.go:1601 +0x185
created by net/http.(*Transport).dialConn
/usr/local/Cellar/go/1.10.2/libexec/src/net/http/transport.go:1237 +0x95a
goroutine 72 [select]:
net/http.(*persistConn).writeLoop(0xc5f0db97a0)
/usr/local/Cellar/go/1.10.2/libexec/src/net/http/transport.go:1822 +0x14b
created by net/http.(*Transport).dialConn
/usr/local/Cellar/go/1.10.2/libexec/src/net/http/transport.go:1238 +0x97f
charles368 回复 medcl
medcl 回复 charles368
这条语句执行报错“unknown flag `copy_mapping'”,我这是copy的你的命令行,有什么问题吗?