使用elasticdump做数据迁移
es版本
[root@localhost bin]# ./elasticdump --help
elasticdump: Import and export tools for elasticsearch
version: 4.6.0
1.elasticdump
安装
su - root
cd /opt
yum install epel-release
yum install nodejs
yum install npm
npm install elasticdump
cd node_modules/elasticdump/bin 后便可以执行操作。
#拷贝analyzer如分词
./elasticdump \
--input=http://192.168.1.85:9200/db_customer \
--output=http://192.168.1.118:9200/db_customer \
--type=analyzer
#拷贝映射
./elasticdump \
--input=http://192.168.1.85:9200/db_customer \
--output=http://192.168.1.118:9200/db_customer \
--type=mapping
#拷贝数据
./elasticdump \
--input=http://192.168.1.85:9200/db_customer \
--output=http://192.168.1.118:9200/db_customer \
--type=data
带验证的导入
./elasticdump \
--input=http://elastic:elastic@192.168.1.134:29200/db_customer \
--output=http://elastic:elastic@192.168.1.118:9200/db_customer \
--type=analyzer
#拷贝映射
./elasticdump \
--input=http://elastic:elastic@192.168.1.134:29200/db_customer \
--output=http://elastic:elastic@192.168.1.118:9200/db_customer \
--type=mapping
#拷贝数据
./elasticdump \
--input=http://elastic:elastic@192.168.1.134:29200/db_customer \
--output=http://elastic:elastic@192.168.1.118:9200/db_customer \
--type=data
------------------------原封不动的迁移----------------------------------------------
#拷贝分词
./elasticdump --input=http://192.168.1.136:19200/hxl_test --output=http://192.168.1.136:19200/bak01_hxl_test --type=analyzer
#拷贝映射
./elasticdump --input=http://192.168.1.136:19200/hxl_test --output=http://192.168.1.136:19200/bak01_hxl_test --type=mapping
#拷贝数据
./elasticdump --input=http://192.168.1.136:19200/hxl_test --output=http://192.168.1.136:19200/bak01_hxl_test --type=data
----------------------------提前创建索引后,只迁移数据------------------------
1.提前创建索引,结构可以跟源库的有一定的差异
比如在原来索引的基础上添加了"type": "nested"
2.同步数据
/opt/node_modules/elasticdump/bin/elasticdump
--input=http://192.168.1.136:19200/inoculate
--output=http://192.168.1.136:19200/inoculate_new --type=data
遇到的错误:
/opt/node_modules/elasticdump/lib/processor.js:40
async _loop (limit, offset, totalWrites) {
^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/opt/node_modules/elasticdump/elasticdump.js:3:28)
[root@yeemiao-oracle-9e96168-prd bin]#
[root@yeemiao-oracle-9e96168-prd bin]# npm install -g n
/usr/bin/n -> /usr/lib/node_modules/n/bin/n
/usr/lib
└── n@6.0.1
[root@yeemiao-oracle-9e96168-prd
bin]# /opt/node_modules/elasticdump/bin/elasticdump
--input=http://172.17.10.20:19200/child_inocexamine_student
--output=http://172.17.10.61:29200/child_inocexamine_student
--type=analyzer
/opt/node_modules/elasticdump/lib/processor.js:40
async _loop (limit, offset, totalWrites) {
^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/opt/node_modules/elasticdump/elasticdump.js:3:28)
解决办法:
#升级nodejs
[root@localhost ~]# npm install -g n
[root@localhost ~]# n latest
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?