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.
解决办法:
#升级nodejs
# npm install -g n # n latest