elasticsearch备份工具elasticdump

  运维

安装

cd /root/
yum install -y  epel-release
yum install nodejs -y
yum install npm -y
npm install elasticdump
cd /root/node_modules/elasticdump/bin 

导出索引Mapping数据

./elasticdump \
–input=http://http://elastic:6vWk8sBBd81u3C062nRh15ck@172.16.0.21:30059/music/index_type \
–output=/root/music_index_mapping.json \
–type=mapping

导出索引数据

./elasticdump \
–input=http://elastic:6vWk8sBBd81u3C062nRh15ck@172.16.0.21:30059/music/index_type \
–output=/root/music_index.json \
–type=data

#拷贝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://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

LEAVE A COMMENT

Captcha Code