1.elasticdump备份还原
1.1elasticdump 简介
用于转移和保存ES索引数据
# 获取集群的节点列表:
curl 'localhost:9200/_cat/nodes?v'
# 列出所有索引:
curl 'localhost:9200/_cat/indices?v'
创建一个名为“customer”的索引,然后再查看所有的索引:
curl -X PUT 'localhost:9200/customer?pretty'
curl 'localhost:9200/_cat/indices?v'
如果需要用户名和密码登录才可以访问,通过下面的方式指定用户名和密码
# 获取集群的节点列表:
curl --user username:password 'localhost:9200/_cat/nodes?v'
1.2前置条件
elasticdump具有两种两种方式:npm和Docker(假设已存在对应的安装环境,可直接跳转至安装elasticdump步骤),本文只讲述npm的安装方式,Docker的安装方式可以查阅官网文档细节。
1.下载node.js安装包
wget https://nodejs.org/dist/v10.13.0/node-v10.13.0-linux-x64.tar.gz
2. 解压node.js 安装包
tar xf node-v10.13.0-linux-x64.tar.gz
3. 创建链接
ln -s ~/node-v10.13.0-linux-x64/bin/node /usr/bin/node
ln -s ~/node-v10.13.0-linux-x64/bin/npm /usr/bin/npm
2.安装 elasticdump
使用npm安装elasticdump,执行如下命令。
npm install elasticdump -g
2.1elasticdump 使用方法
本文主要介绍数据导出为文件,从文件导入数据这两个常用的方法,但elasticdump并不局限于这两种使用方式,如果对此感兴趣,可以登陆官网查阅更为详细的用法细节。
[root@cndh1323-2-11 bin]# ./elasticdump --help
elasticdump: Import and export tools for elasticsearch
version: 6.27.5
Usage: elasticdump --input SOURCE --output DESTINATION [OPTIONS]
--input
Source location (required)
--input-index
Source index and type
(default: all, example: index/type)
--output
Destination location (required)
--output-index
Destination index and type
(default: all, example: index/type)
--overwrite
Overwrite output file if it exists
(default: false)
--limit
How many objects to move in batch per operation
limit is approximate for file streams
(default: 100)
--size
How many objects to retrieve
(default: -1 -> no limit)
--concurrency
How many concurrent request is sent to a specified transport
(default: 1)
--concurrencyInterval
The length of time in milliseconds before the interval count resets. Must be finite.
(default: 5000)
--intervalCap
The max number of transport request in the given interval of time.
(default: 5)
--carryoverConcurrencyCount
Whether the task must finish in the given concurrencyInterval
(intervalCap will reset to the default whether the request is completed or not)
or will be carried over into the next interval count,
which will effectively reduce the number of new requests created in the next interval
i.e. intervalCap -=
(default: true)
--throttleInterval
The length of time in milliseconds to delay between getting data from an inp