使用 shuf 来打乱一个文件中的行或是选择文件中一个随机的行。
dump

dump

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

Elasticsearchmedcl 发表了文章 • 129 个评论 • 20985 次浏览 • 2016-05-23 17:09 • 来自相关话题

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
 

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

Elasticsearchmedcl 发表了文章 • 129 个评论 • 20985 次浏览 • 2016-05-23 17:09 • 来自相关话题

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