elasticsearch 集群或单机离线数据迁移
-
安装离线工具
https://blog.csdn.net/luqingjie7213/article/details/139518249?spm=1001.2014.3001.5501
-
工具使用
-
elasticsearch 关闭写权限
curl --user elastic:xxx -H "Content-Type:application/json" -XPUT http://192.168.3.30:9200/_all/_settings -d '{ "index.blocks.read_only": true }'
-
实时单索引-其他操作参考下面离线迁移
#导出
elasticdump
--input=http://192.168.1.140:9200/source_index
--output=http://192.168.1.141:9200/target_index
--type=mapping
#导入
elasticdump
--input=http://192.168.1.140:9200/source_index
--output=http://192.168.1.141:9200/target_index
--type=data
--limit=2000 # 每次操作的objects数量,默认100,数据量大的话,可以调大加快迁移速度
-
离线迁移 - 将源es索引数据导出为json文件,然后再导入目标es
导出-单索引
elasticdump
–input=http://192.168.1.140:9200/source_index
–output=/data/source_index_mapping.json
–type=mapping
elasticdump
–input=http://192.168.1.140:9200/source_index
–output=/data/source_index.json
–type=data
–limit=2000导入-单索
elasticdump
–input=/data/source_index_mapping.json
–output=http://192.168.1.141:9200/source_index
–type=mapping
elasticdump
–input=/data/source_index.json
–output=http://192.168.1.141:9200/source_index
–type=data
–limit=2000导出-全量
./multielasticdump
–direction=dump
–input=http://elastic:lqj7667213@192.168.3.30:9200
–output=/root/esBak
–includeType=data,mapping,analyzer,alias,settings,template
–limit=10000
–fileSize 1mb导入-全量
./multielasticdump
–direction=load
–input=/root/esBak
–output=http://elastic:lqj7667213@192.168.3.30:9201
–limit=10000
–includeType=data,mapping,analyzer,alias,settings,template
elasticsearch 打开写权限
curl --user elastic:xxx -H "Content-Type:application/json" -XPUT http://192.168.3.30:9200/_all/_settings -d '{ "index.blocks.read_only": false }'