Elasticsearch的数据导出和导入操作(elasticdump工具),以及删除指定type的数据(delete-by-query插件)
Elasticseach目前作为查询搜索平台,的确非常实用方便。我们今天在这里要讨论的是如何做数据备份和type删除。我的ES的版本是2.4.1。
ES的备份,可不像MySQL的mysqldump这么方便,需要一个插件进行数据的导出和导入进行备份和恢复操作。这里要说的插件是elasticdump。
elasticdump的安装:
- [root@localhost ~]# yum install elasticdump
- 已加载插件:fastestmirror, product-id, subscription-manager
- This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
- Repodata is over weeks old. Install yum-cron? Or run: yum makecache fast
- base | 3.6 kB ::
- cuda | 2.5 kB ::
- epel/x86_64/metalink | 5.0 kB ::
- epel | 4.3 kB ::
- extras | 3.4 kB ::
- updates | 3.4 kB ::
- (/): base/x86_64/primary_db | 5.7 MB ::
- (/): epel/x86_64/group_gz | kB ::
- (/): epel/x86_64/updateinfo | kB ::
- (/): extras/x86_64/primary_db | kB ::
- (/): base/x86_64/group_gz | kB ::
- (/): updates/x86_64/primary_db | 2.8 MB ::
- (/): epel/x86_64/primary_db | 4.8 MB ::
- cuda/primary_db FAILED
- http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/repodata/1d4cabb230a45d5f78f46ccd1b04914a98eab1b3-primary.sqlite.bz2: [Errno 12] Timeout on http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/repodata/1d4cabb230a45d5f78f46ccd1b04914a98eab1b3-primary.sqlite.bz2: (28, 'Operation too slow. Less than 1000 bytes/sec transferred the last 30 seconds')
- 正在尝试其它镜像。
- cuda/primary_db FAILED
- http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/repodata/1d4cabb230a45d5f78f46ccd1b04914a98eab1b3-primary.sqlite.bz2: [Errno 14] curl#52 - "Empty reply from server"0 ETA
- 正在尝试其它镜像。
- Determining fastest mirrors
- * epel: mirrors.tuna.tsinghua.edu.cn
- 正在解决依赖关系
- --> 正在检查事务
- ---> 软件包 elasticdump.noarch.0.2.2.0-.el7 将被 安装
- --> 正在处理依赖关系 npm(request) < ,它被软件包 elasticdump-2.2.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(async) < ,它被软件包 elasticdump-2.2.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(request) >= ,它被软件包 elasticdump-2.2.-.el7.noarch 需要
- --> 正在处理依赖关系 nodejs(engine) >= 1.0.,它被软件包 elasticdump-2.2.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(optimist),它被软件包 elasticdump-2.2.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(JSONStream),它被软件包 elasticdump-2.2.-.el7.noarch 需要
- --> 正在处理依赖关系 /usr/bin/node,它被软件包 elasticdump-2.2.-.el7.noarch 需要
- --> 正在检查事务
- ---> 软件包 nodejs.x86_64.1.6.11.1-.el7 将被 安装
- --> 正在处理依赖关系 npm = :3.10.-1.6.11.1..el7,它被软件包 :nodejs-6.11.-.el7.x86_64 需要
- --> 正在处理依赖关系 libuv >= :1.9.,它被软件包 :nodejs-6.11.-.el7.x86_64 需要
- --> 正在处理依赖关系 http-parser >= 2.7.,它被软件包 :nodejs-6.11.-.el7.x86_64 需要
- --> 正在处理依赖关系 libuv.so.()(64bit),它被软件包 :nodejs-6.11.-.el7.x86_64 需要
- --> 正在处理依赖关系 libhttp_parser.so.()(64bit),它被软件包 :nodejs-6.11.-.el7.x86_64 需要
- ---> 软件包 nodejs-async.noarch.0.0.2.10-.el7 将被 安装
- ---> 软件包 nodejs-jsonstream.noarch.0.0.10.0-.el7 将被 安装
- --> 正在处理依赖关系 npm(through),它被软件包 nodejs-jsonstream-0.10.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(jsonparse),它被软件包 nodejs-jsonstream-0.10.-.el7.noarch 需要
- ---> 软件包 nodejs-optimist.noarch.0.0.4.0-.el7 将被 安装
- --> 正在处理依赖关系 npm(wordwrap) < 0.1,它被软件包 nodejs-optimist-0.4.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(wordwrap) >= 0.0.,它被软件包 nodejs-optimist-0.4.-.el7.noarch 需要
- ---> 软件包 nodejs-request.noarch.0.2.25.0-.el7 将被 安装
- --> 正在处理依赖关系 npm(tunnel-agent) < 0.4,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(qs) < 0.7,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(oauth-sign) < 0.4,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(node-uuid) < 1.5,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(mime) < 1.3,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(json-stringify-safe) < 5.1,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(http-signature) < 0.11,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(hawk) < 1.1,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(form-data) < 0.2,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(forever-agent) < 0.6,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(cookie-jar) < 0.4,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(aws-sign) < 0.4,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(tunnel-agent) >= 0.3.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(qs) >= 0.6.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(oauth-sign) >= 0.3.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(node-uuid) >= 1.4.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(mime) >= 1.2.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(json-stringify-safe) >= 5.0.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(http-signature) >= 0.10.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(hawk) >= 1.0.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(form-data) >= 0.1.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(forever-agent) >= 0.5.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(cookie-jar) >= 0.3.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(aws-sign) >= 0.3.,它被软件包 nodejs-request-2.25.-.el7.noarch 需要
- --> 正在检查事务
- ---> 软件包 http-parser.x86_64.0.2.7.1-.el7_4 将被 安装
- ---> 软件包 libuv.x86_64.1.1.10.2-.el7 将被 安装
- ---> 软件包 nodejs-aws-sign.noarch.0.0.3.0-.el7 将被 安装
- ---> 软件包 nodejs-cookie-jar.noarch.1.0.3.0-.el7 将被 安装
- ---> 软件包 nodejs-forever-agent.noarch.0.0.5.0-.el7 将被 安装
- ---> 软件包 nodejs-form-data.noarch.0.0.1.1-.el7 将被 安装
- --> 正在处理依赖关系 npm(combined-stream) < 0.1,它被软件包 nodejs-form-data-0.1.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(combined-stream) >= 0.0.,它被软件包 nodejs-form-data-0.1.-.el7.noarch 需要
- ---> 软件包 nodejs-hawk.noarch.0.1.0.0-.el7 将被 安装
- --> 正在处理依赖关系 npm(sntp) < 0.3,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(hoek) < 0.10,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(cryptiles) < 0.3,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(boom) < 0.5,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(sntp) >= 0.2,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(hoek) >= 0.9,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(cryptiles) >= 0.2,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(boom) >= 0.4,它被软件包 nodejs-hawk-1.0.-.el7.noarch 需要
- ---> 软件包 nodejs-http-signature.noarch.0.0.10.0-.el7 将被 安装
- --> 正在处理依赖关系 npm(ctype) < 0.6,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(assert-plus) < 0.2,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(asn1) < 0.2,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(ctype) >= 0.5.,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(assert-plus) >= 0.1.,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
- --> 正在处理依赖关系 npm(asn1) >= 0.1.,它被软件包 nodejs-http-signature-0.10.-.el7.noarch 需要
- ---> 软件包 nodejs-json-stringify-safe.noarch.0.5.0.0-.el7 将被 安装
- ---> 软件包 nodejs-jsonparse.noarch.0.1.0.0-.el7 将被 安装
- ---> 软件包 nodejs-mime.noarch.0.1.2.11-.el7 将被 安装
- ---> 软件包 nodejs-node-uuid.noarch.0.1.4.1-.el7 将被 安装
- ---> 软件包 nodejs-oauth-sign.noarch.0.0.3.0-.el7 将被 安装
- ---> 软件包 nodejs-qs.noarch.0.0.6.6-.el7 将被 安装
- ---> 软件包 nodejs-through.noarch.0.2.3.4-.el7 将被 安装
- ---> 软件包 nodejs-tunnel-agent.noarch.0.0.3.0-.el7 将被 安装
- ---> 软件包 nodejs-wordwrap.noarch.0.0.0.2-.el7 将被 安装
- ---> 软件包 npm.x86_64.1.3.10.10-1.6.11.1..el7 将被 安装
- --> 正在检查事务
- ---> 软件包 nodejs-asn1.noarch.0.0.1.11-.el7 将被 安装
- ---> 软件包 nodejs-assert-plus.noarch.0.0.1.4-.el7 将被 安装
- ---> 软件包 nodejs-boom.noarch.0.0.4.2-.el7 将被 安装
- ---> 软件包 nodejs-combined-stream.noarch.0.0.0.4-.el7 将被 安装
- --> 正在处理依赖关系 npm(delayed-stream) = 0.0.,它被软件包 nodejs-combined-stream-0.0.-.el7.noarch 需要
- ---> 软件包 nodejs-cryptiles.noarch.0.0.2.2-.el7 将被 安装
- ---> 软件包 nodejs-ctype.noarch.0.0.5.3-.el7 将被 安装
- ---> 软件包 nodejs-hoek.noarch.0.0.9.1-.el7 将被 安装
- ---> 软件包 nodejs-sntp.noarch.0.0.2.4-.el7 将被 安装
- --> 正在检查事务
- ---> 软件包 nodejs-delayed-stream.noarch.0.0.0.5-.el7 将被 安装
- --> 解决依赖关系完成
- 依赖关系解决
- ===============================================================================================================================================================================================
- Package 架构 版本 源 大小
- ===============================================================================================================================================================================================
- 正在安装:
- elasticdump noarch 2.2.-.el7 epel k
- 为依赖而安装:
- http-parser x86_64 2.7.-.el7_4 updates k
- libuv x86_64 :1.10.-.el7 epel k
- nodejs x86_64 :6.11.-.el7 epel 4.5 M
- nodejs-asn1 noarch 0.1.-.el7 epel k
- nodejs-assert-plus noarch 0.1.-.el7 epel 7.3 k
- nodejs-async noarch 0.2.-.el7 epel k
- nodejs-aws-sign noarch 0.3.-.el7 epel 5.7 k
- nodejs-boom noarch 0.4.-.el7 epel k
- nodejs-combined-stream noarch 0.0.-.el7 epel 7.9 k
- nodejs-cookie-jar noarch :0.3.-.el7 epel 6.1 k
- nodejs-cryptiles noarch 0.2.-.el7 epel 6.9 k
- nodejs-ctype noarch 0.5.-.el7 epel k
- nodejs-delayed-stream noarch 0.0.-.el7 epel 7.9 k
- nodejs-forever-agent noarch 0.5.-.el7 epel 5.6 k
- nodejs-form-data noarch 0.1.-.el7 epel k
- nodejs-hawk noarch 1.0.-.el7 epel k
- nodejs-hoek noarch 0.9.-.el7 epel k
- nodejs-http-signature noarch 0.10.-.el7 epel k
- nodejs-json-stringify-safe noarch 5.0.-.el7 epel 6.6 k
- nodejs-jsonparse noarch 1.0.-.el7 epel k
- nodejs-jsonstream noarch 0.10.-.el7 epel 9.5 k
- nodejs-mime noarch 1.2.-.el7 epel k
- nodejs-node-uuid noarch 1.4.-.el7 epel k
- nodejs-oauth-sign noarch 0.3.-.el7 epel 4.9 k
- nodejs-optimist noarch 0.4.-.el7 epel k
- nodejs-qs noarch 0.6.-.el7 epel 8.7 k
- nodejs-request noarch 2.25.-.el7 epel k
- nodejs-sntp noarch 0.2.-.el7 epel k
- nodejs-through noarch 2.3.-.el7 epel 7.1 k
- nodejs-tunnel-agent noarch 0.3.-.el7 epel 6.3 k
- nodejs-wordwrap noarch 0.0.-.el7 epel 6.4 k
- npm x86_64 :3.10.-1.6.11.1..el7 epel 2.5 M
- 事务概要
- ===============================================================================================================================================================================================
- 安装 软件包 (+ 依赖软件包)
- 总下载量:7.7 M
- 安装大小: M
- Is this ok [y/d/N]: y
- Downloading packages:
- (/): http-parser-2.7.-.el7_4.x86_64.rpm | kB ::
- (/): elasticdump-2.2.-.el7.noarch.rpm | kB ::
- (/): libuv-1.10.-.el7.x86_64.rpm | kB ::
- (/): nodejs-6.11.-.el7.x86_64.rpm | 4.5 MB ::
- (/): nodejs-asn1-0.1.-.el7.noarch.rpm | kB ::
- (/): nodejs-assert-plus-0.1.-.el7.noarch.rpm | 7.3 kB ::
- (/): nodejs-async-0.2.-.el7.noarch.rpm | kB ::
- (/): nodejs-aws-sign-0.3.-.el7.noarch.rpm | 5.7 kB ::
- (/): nodejs-boom-0.4.-.el7.noarch.rpm | kB ::
- (/): nodejs-combined-stream-0.0.-.el7.noarch.rpm | 7.9 kB ::
- (/): nodejs-cookie-jar-0.3.-.el7.noarch.rpm | 6.1 kB ::
- (/): nodejs-cryptiles-0.2.-.el7.noarch.rpm | 6.9 kB ::
- (/): nodejs-ctype-0.5.-.el7.noarch.rpm | kB ::
- (/): nodejs-delayed-stream-0.0.-.el7.noarch.rpm | 7.9 kB ::
- (/): nodejs-forever-agent-0.5.-.el7.noarch.rpm | 5.6 kB ::
- (/): nodejs-form-data-0.1.-.el7.noarch.rpm | kB ::
- (/): nodejs-hawk-1.0.-.el7.noarch.rpm | kB ::
- (/): nodejs-hoek-0.9.-.el7.noarch.rpm | kB ::
- (/): nodejs-http-signature-0.10.-.el7.noarch.rpm | kB ::
- (/): nodejs-json-stringify-safe-5.0.-.el7.noarch.rpm | 6.6 kB ::
- (/): nodejs-jsonparse-1.0.-.el7.noarch.rpm | kB ::
- (/): nodejs-jsonstream-0.10.-.el7.noarch.rpm | 9.5 kB ::
- (/): nodejs-mime-1.2.-.el7.noarch.rpm | kB ::
- (/): nodejs-node-uuid-1.4.-.el7.noarch.rpm | kB ::
- (/): nodejs-oauth-sign-0.3.-.el7.noarch.rpm | 4.9 kB ::
- (/): nodejs-optimist-0.4.-.el7.noarch.rpm | kB ::
- (/): nodejs-qs-0.6.-.el7.noarch.rpm | 8.7 kB ::
- (/): nodejs-request-2.25.-.el7.noarch.rpm | kB ::
- (/): nodejs-sntp-0.2.-.el7.noarch.rpm | kB ::
- (/): nodejs-through-2.3.-.el7.noarch.rpm | 7.1 kB ::
- (/): nodejs-tunnel-agent-0.3.-.el7.noarch.rpm | 6.3 kB ::
- (/): nodejs-wordwrap-0.0.-.el7.noarch.rpm | 6.4 kB ::
- (/): npm-3.10.-1.6.11.1..el7.x86_64.rpm | 2.5 MB ::
- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- 总计 2.0 MB/s | 7.7 MB ::
- Running transaction check
- Running transaction test
- Transaction test succeeded
- Running transaction
- 警告:RPM 数据库已被非 yum 程序修改。
- ** 发现 个已存在的 RPM 数据库问题, 'yum check' 输出如下:
- rhn-check-2.0.-.el7.noarch 有缺少的需求 yum-rhn-plugin >= ('', '1.6.4', '')
- 正在安装 : :libuv-1.10.-.el7.x86_64 /
- 正在安装 : http-parser-2.7.-.el7_4.x86_64 /
- 正在安装 : :npm-3.10.-1.6.11.1..el7.x86_64 /
- 正在安装 : :nodejs-6.11.-.el7.x86_64 /
- 正在安装 : nodejs-hoek-0.9.-.el7.noarch /
- 正在安装 : nodejs-boom-0.4.-.el7.noarch /
- 正在安装 : nodejs-mime-1.2.-.el7.noarch /
- 正在安装 : nodejs-async-0.2.-.el7.noarch /
- 正在安装 : nodejs-cryptiles-0.2.-.el7.noarch /
- 正在安装 : nodejs-sntp-0.2.-.el7.noarch /
- 正在安装 : nodejs-hawk-1.0.-.el7.noarch /
- 正在安装 : nodejs-forever-agent-0.5.-.el7.noarch /
- 正在安装 : nodejs-aws-sign-0.3.-.el7.noarch /
- 正在安装 : nodejs-qs-0.6.-.el7.noarch /
- 正在安装 : nodejs-wordwrap-0.0.-.el7.noarch /
- 正在安装 : nodejs-optimist-0.4.-.el7.noarch /
- 正在安装 : nodejs-assert-plus-0.1.-.el7.noarch /
- 正在安装 : nodejs-oauth-sign-0.3.-.el7.noarch /
- 正在安装 : nodejs-tunnel-agent-0.3.-.el7.noarch /
- 正在安装 : nodejs-asn1-0.1.-.el7.noarch /
- 正在安装 : nodejs-delayed-stream-0.0.-.el7.noarch /
- 正在安装 : nodejs-combined-stream-0.0.-.el7.noarch /
- 正在安装 : nodejs-form-data-0.1.-.el7.noarch /
- 正在安装 : :nodejs-cookie-jar-0.3.-.el7.noarch /
- 正在安装 : nodejs-jsonparse-1.0.-.el7.noarch /
- 正在安装 : nodejs-through-2.3.-.el7.noarch /
- 正在安装 : nodejs-jsonstream-0.10.-.el7.noarch /
- 正在安装 : nodejs-node-uuid-1.4.-.el7.noarch /
- 正在安装 : nodejs-ctype-0.5.-.el7.noarch /
- 正在安装 : nodejs-http-signature-0.10.-.el7.noarch /
- 正在安装 : nodejs-json-stringify-safe-5.0.-.el7.noarch /
- 正在安装 : nodejs-request-2.25.-.el7.noarch /
- 正在安装 : elasticdump-2.2.-.el7.noarch /
- 验证中 : elasticdump-2.2.-.el7.noarch /
- 验证中 : nodejs-forever-agent-0.5.-.el7.noarch /
- 验证中 : nodejs-aws-sign-0.3.-.el7.noarch /
- 验证中 : nodejs-qs-0.6.-.el7.noarch /
- 验证中 : http-parser-2.7.-.el7_4.x86_64 /
- 验证中 : nodejs-combined-stream-0.0.-.el7.noarch /
- 验证中 : nodejs-wordwrap-0.0.-.el7.noarch /
- 验证中 : nodejs-assert-plus-0.1.-.el7.noarch /
- 验证中 : nodejs-oauth-sign-0.3.-.el7.noarch /
- 验证中 : nodejs-hoek-0.9.-.el7.noarch /
- 验证中 : nodejs-cryptiles-0.2.-.el7.noarch /
- 验证中 : nodejs-jsonstream-0.10.-.el7.noarch /
- 验证中 : nodejs-request-2.25.-.el7.noarch /
- 验证中 : nodejs-http-signature-0.10.-.el7.noarch /
- 验证中 : :libuv-1.10.-.el7.x86_64 /
- 验证中 : nodejs-tunnel-agent-0.3.-.el7.noarch /
- 验证中 : nodejs-mime-1.2.-.el7.noarch /
- 验证中 : nodejs-hawk-1.0.-.el7.noarch /
- 验证中 : nodejs-asn1-0.1.-.el7.noarch /
- 验证中 : nodejs-delayed-stream-0.0.-.el7.noarch /
- 验证中 : :npm-3.10.-1.6.11.1..el7.x86_64 /
- 验证中 : nodejs-optimist-0.4.-.el7.noarch /
- 验证中 : nodejs-sntp-0.2.-.el7.noarch /
- 验证中 : nodejs-form-data-0.1.-.el7.noarch /
- 验证中 : :nodejs-cookie-jar-0.3.-.el7.noarch /
- 验证中 : nodejs-boom-0.4.-.el7.noarch /
- 验证中 : :nodejs-6.11.-.el7.x86_64 /
- 验证中 : nodejs-jsonparse-1.0.-.el7.noarch /
- 验证中 : nodejs-through-2.3.-.el7.noarch /
- 验证中 : nodejs-node-uuid-1.4.-.el7.noarch /
- 验证中 : nodejs-ctype-0.5.-.el7.noarch /
- 验证中 : nodejs-async-0.2.-.el7.noarch /
- 验证中 : nodejs-json-stringify-safe-5.0.-.el7.noarch /
- 已安装:
- elasticdump.noarch :2.2.-.el7
- 作为依赖被安装:
- http-parser.x86_64 :2.7.-.el7_4 libuv.x86_64 :1.10.-.el7 nodejs.x86_64 :6.11.-.el7 nodejs-asn1.noarch :0.1.-.el7
- nodejs-assert-plus.noarch :0.1.-.el7 nodejs-async.noarch :0.2.-.el7 nodejs-aws-sign.noarch :0.3.-.el7 nodejs-boom.noarch :0.4.-.el7
- nodejs-combined-stream.noarch :0.0.-.el7 nodejs-cookie-jar.noarch :0.3.-.el7 nodejs-cryptiles.noarch :0.2.-.el7 nodejs-ctype.noarch :0.5.-.el7
- nodejs-delayed-stream.noarch :0.0.-.el7 nodejs-forever-agent.noarch :0.5.-.el7 nodejs-form-data.noarch :0.1.-.el7 nodejs-hawk.noarch :1.0.-.el7
- nodejs-hoek.noarch :0.9.-.el7 nodejs-http-signature.noarch :0.10.-.el7 nodejs-json-stringify-safe.noarch :5.0.-.el7 nodejs-jsonparse.noarch :1.0.-.el7
- nodejs-jsonstream.noarch :0.10.-.el7 nodejs-mime.noarch :1.2.-.el7 nodejs-node-uuid.noarch :1.4.-.el7 nodejs-oauth-sign.noarch :0.3.-.el7
- nodejs-optimist.noarch :0.4.-.el7 nodejs-qs.noarch :0.6.-.el7 nodejs-request.noarch :2.25.-.el7 nodejs-sntp.noarch :0.2.-.el7
- nodejs-through.noarch :2.3.-.el7 nodejs-tunnel-agent.noarch :0.3.-.el7 nodejs-wordwrap.noarch :0.0.-.el7 npm.x86_64 :3.10.-1.6.11.1..el7
- 完毕!
- [root@localhost ~]#
elasticdump相关功能描述:
- [root@localhost ~]# elasticdump --help
- elasticdump: Import and export tools for elasticsearch
- version: 2.2.
- 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)
- --limit
- How many objects to move in batch per operation
- limit is approximate for file streams
- (default: )
- --debug
- Display the elasticsearch commands being used
- (default: false)
- --type
- What are we exporting?
- (default: data, options: [data, mapping])
- --delete
- Delete documents one-by-one from the input as they are
- moved. Will not delete the source index
- (default: false)
- --searchBody
- Preform a partial extract based on search results
- (when ES is the input,
- (default: '{"query": { "match_all": {} } }'))
- --sourceOnly
- Output only the json contained within the document _source
- Normal: {"_index":"","_type":"","_id":"", "_source":{SOURCE}}
- sourceOnly: {SOURCE}
- (default: false)
- --all
- Load/store documents from ALL indexes
- (default: false)
- --ignore-errors
- Will continue the read/write loop on write error
- (default: false)
- --scrollTime
- Time the nodes will hold the requested search in order.
- (default: 10m)
- --maxSockets
- How many simultaneous HTTP requests can we process make?
- (default:
- [node <= v0..x] /
- Infinity [node >= v0..x] )
- --timeout
- Integer containing the number of milliseconds to wait for
- a request to respond before aborting the request. Passed
- directly to the request library. Mostly used when you don't
- care too much if you lose some data when importing
- but rather have speed.
- --offset
- Integer containing the number of rows you wish to skip
- ahead from the input transport. When importing a large
- index, things can go wrong, be it connectivity, crashes,
- someone forgetting to `screen`, etc. This allows you
- to start the dump again from the last known line written
- (as logged by the `offset` in the output). Please be
- advised that since no sorting is specified when the
- dump is initially created, there's no real way to
- guarantee that the skipped rows have already been
- written/parsed. This is more of an option for when
- you want to get most data as possible in the index
- without concern for losing some rows in the process,
- similar to the `timeout` option.
- --inputTransport
- Provide a custom js file to us as the input transport
- --outputTransport
- Provide a custom js file to us as the output transport
- --toLog
- When using a custom outputTransport, should log lines
- be appended to the output stream?
- (default: true, except for `$`)
- --help
- This page
- Examples:
- # Copy an index from production to staging with mappings:
- elasticdump \
- --input=http://production.es.com:9200/my_index \
- --output=http://staging.es.com:9200/my_index \
- --type=mapping
- elasticdump \
- --input=http://production.es.com:9200/my_index \
- --output=http://staging.es.com:9200/my_index \
- --type=data
- # Backup index data to a file:
- elasticdump \
- --input=http://production.es.com:9200/my_index \
- --output=/data/my_index_mapping.json \
- --type=mapping
- elasticdump \
- --input=http://production.es.com:9200/my_index \
- --output=/data/my_index.json \
- --type=data
- # Backup and index to a gzip using stdout:
- elasticdump \
- --input=http://production.es.com:9200/my_index \
- --output=$ \
- | gzip > /data/my_index.json.gz
- # Backup the results of a query to a file
- elasticdump \
- --input=http://production.es.com:9200/my_index \
- --output=query.json \
- --searchBody '{"query":{"term":{"username": "admin"}}}'
- ------------------------------------------------------------------------------
- Learn more @ https://github.com/taskrabbit/elasticsearch-dump
- [root@localhost ~]#
重点说明:
依据上述的帮助文件,我们重点看elasticdump --input SOURCE --output DESTINATION
这里的source和destination可以是es的数据源,也可以是文件。也就是说,这个命令elasticdump既可以完成数据的导出,也可以完成数据的导入。
当表示es的数据源时,必须是{protocol}://{host}:{port}/{index}.
1. 将es集群中的某个index的数据导出到文件中。
- [root@localhost ~]# elasticdump --input http://10.90.7.10:9200/robotkdb --output /opt/shihuc/robotkdb.json
- Thu, Sep :: GMT | starting dump
- Thu, Sep :: GMT | got objects from source elasticsearch (offset: )
- Thu, Sep :: GMT | sent objects to destination file, wrote
- Thu, Sep :: GMT | got objects from source elasticsearch (offset: )
- Thu, Sep :: GMT | sent objects to destination file, wrote
- Thu, Sep :: GMT | got objects from source elasticsearch (offset: )
- Thu, Sep :: GMT | sent objects to destination file, wrote
- Thu, Sep :: GMT | got objects from source elasticsearch (offset: )
- Thu, Sep :: GMT | Total Writes:
- Thu, Sep :: GMT | dump complete
- [root@localhost ~]#
2.直接删除指定的type下的内容
- [root@localhost ~]# curl -XDELETE "http://10.90.7.10:9200/robotkdb/weibao?v"
- No handler found for uri [/robotkdb/weibao?v] and method [DELETE][root@localhost ~]#
删除不成功。
查询资料显示说,ES2.x版本以上的系统中,禁止了直接删除type。
那我要快速删除一个type的内容,该如何处理呢?其实是有的,安装delete-by-query的插件进行。安装完成后,将Elasticsearch重启一下。
- [root@localhost bin]# ll
- 总用量
- -rwxr-xr-x es es 8月 elasticsearch
- -rw-rw-r-- es es 8月 elasticsearch.bat
- -rw-rw-r-- es es 9月 elasticsearch.in.bat
- -rwxr-xr-x es es 8月 elasticsearch.in.sh
- -rw-rw-r-- es es 7月 elasticsearch-service-mgr.exe
- -rw-rw-r-- es es 7月 elasticsearch-service-x64.exe
- -rw-rw-r-- es es 7月 elasticsearch-service-x86.exe
- -rwxr-xr-x es es 8月 plugin
- -rw-rw-r-- es es 8月 plugin.bat
- -rw-rw-r-- es es 8月 service.bat
- [root@localhost bin]# ./plugin install delete-by-query #注意,要到elasticsearch的安装路径下的bin下面执行这个命令
- -> Installing delete-by-query...
- Trying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/delete-by-query/2.4.1/delete-by-query-2.4.1.zip ...
- Downloading ..DONE
- Verifying https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/delete-by-query/2.4.1/delete-by-query-2.4.1.zip checksums if available ...
- Downloading .DONE
- Installed delete-by-query into /opt/ES/elasticsearch-2.4./plugins/delete-by-query
- [root@localhost bin]#
重启elasticsearch的过程,就不描述了。然后再用命令执行删除指定的type的数据:
- [root@localhost ES]# curl -XDELETE "http://10.90.7.10:9200/robotkdb/weibao/_query?pretty" -d '{
- "query":{
- "match_all":{}
- }}'
- {
- "took" : ,
- "timed_out" : false,
- "_indices" : {
- "_all" : {
- "found" : ,
- "deleted" : ,
- "missing" : ,
- "failed" :
- },
- "robotkdb" : {
- "found" : ,
- "deleted" : ,
- "missing" : ,
- "failed" :
- }
- },
- "failures" : [ ]
- }
- [root@localhost ES]#
从上述结果看,没有错误。那么,再去查看下,weibao这个type下,还有没有数据!
- [root@localhost ES]# curl -XGET "http://10.90.7.10:9200/robotkdb/weibao/_search?pretty"
- {
- "took" : ,
- "timed_out" : false,
- "_shards" : {
- "total" : ,
- "successful" : ,
- "failed" :
- },
- "hits" : {
- "total" : ,
- "max_score" : null,
- "hits" : [ ]
- }
- }
说明删除指定type的内容成功了。
3. elasticdump数据恢复
那最后再来恢复下刚才删除掉的208个记录吧。前面不是备份了一个数据吗,在这个文件里面/opt/shihuc/robotkdb.json
- [root@localhost shihuc]# elasticdump --input /opt/shihuc/robotkdb.json --output "http://10.90.7.10:9200/robotkdb"
- Thu, Sep :: GMT | starting dump
- Thu, Sep :: GMT | got objects from source file (offset: )
- Thu, Sep :: GMT | sent objects to destination elasticsearch, wrote
- Thu, Sep :: GMT | got objects from source file (offset: )
- Thu, Sep :: GMT | sent objects to destination elasticsearch, wrote
- Thu, Sep :: GMT | got objects from source file (offset: )
- Thu, Sep :: GMT | Total Writes:
- Thu, Sep :: GMT | dump complete
最后在浏览器上访问看看吧,验证数据载入、恢复是否成功!
Elasticsearch的数据备份,删除以及恢复逻辑,到此验证完毕!
总结:
1. Elasticsearch的2.x以上版本不支持直接删除type级别的数据。支持删除index,也支持逐个id的删除。
2. Elasticsearch的数据备份和恢复,没有直接的指令操作,需要安装插件elasticdump来实现。
Elasticsearch的数据导出和导入操作(elasticdump工具),以及删除指定type的数据(delete-by-query插件)的更多相关文章
- PCB MS SERVER 数据导出与导入操作步骤----使用第3方工具
工作每天都与数据库打交道,经常会遇到一些需要将数据库中的数据导出来或将数据导入到数据库 而用微软数据库客户端自带的功能操作步骤好麻烦的,用过的大家都会有相同的感受吧. 微软客户端不好之处整理:这里吐槽 ...
- memcached命令行、Memcached数据导出和导入、php连接memcache、php的session存储到memcached
1.memcached命令行 telnet 127.0.0.1 11211set key2 0 30 2abSTOREDget key2VALUE key2 0 2abEND 如: set key3 ...
- memcached命令行、Memcached数据导出和导入
1.memcached命令行 telnet 127.0.0.1 11211set key2 0 30 2abSTOREDget key2VALUE key2 0 2abEND 如: set key3 ...
- elasticsearch 2.4在head删除数据(使用Delete By Query插件)
之所以说明是2.4版,是因为不同版本删除的语法不一样(例如跟5.x就不同) 首先安装Delete By Query插件,方式跟安装head插件差不多,安装命令:plugin install delet ...
- MYSQL数据导出与导入,secure_file_priv参数设置
https://www.imooc.com/article/41883 MySQL 报错 [Code: 1290, SQL State: HY000] The MySQL server is run ...
- DB2表数据导出、导入及常用sql使用总结
一.DB2数据的导出: export to [path(例:D:"TABLE1.ixf)]of ixf select [字段(例: * or col1,col2,col3)] from ...
- mongoDB 数据导出与导入
一.导出 命令格式:在mongodb/bin目录下 mongoexport -h IP --port 端口 -u 用户名 -p 密码 -d 数据库 -c 表名 -f 字段 -q 条件导出 --csv ...
- oracle数据库数据导出和导入
oracle的客户端里面的bin下面有两个可执行文件,名称分别为exp.exe和imp.exe. 他俩的用途就是导出和导入数据用的. 全库 导出:exp 用户名/密码@数据库名 full=y file ...
- mysql创建账号、授权、数据导出、导入
1.账号创建及授权 grant all privileges on *.* to 'yangxin'@'%' identified by 'yangxin123456' with grant opti ...
随机推荐
- web前端优化
在谈到Web优化之前,我们回到一个更原始的问题,Web前端的本质是什么.我的理解是: 将信息快速并友好的展示给用户并能够与用户进行交互.快速的意思就是在尽可能短的时间内完成页面的加载,试想一下当你在淘 ...
- ubuntu16.04系统安装
0x1镜像下载 (1)下载地址http://cn.ubuntu.com/download/ 0x2 安装 (1)打开vmware,创建新的虚拟机 (2)选择自定义安装 (3)直接下一步,选择稍后安装系 ...
- 5个适用于初学者的有用数据分析表达式(DAX)函数
数据分析表达式(DAX)入门可能令人生畏,但是,当你了解一些基本功能后,你就可以帮助你解答许多有关数据的新见解.虽然在Power BI或Pivot Charts中创建视觉效果很容易,但我们经常希望查看 ...
- [转]Skynet之斗转星移 - 将控制权交给Lua
Skynet之斗转星移 - 将控制权交给Lua http://www.outsky.org/code/skynet-lua.html Sep 7, 2014 在我看来,Skynet的一个重要优势是 ...
- JAVA小程序-----买衣服
import java.util.Scanner; //引用扫描器 public class TestDemo1 { public static void main(String [] args){ ...
- Implementing a CNN for Text Classification in TensorFlow
参考: 1.Understanding Convolutional Neural Networks for NLP 2.Implementing a CNN for Text Classificati ...
- day 017面向对象-反射
主要内容: isinstance, type, issubclass( 内置函数) 区分函数和方法 反射 一 ( isinstance, type, issubclass) isinstance ...
- POJ 2751:Seek the Name, Seek the Fame(Hash)
Seek the Name, Seek the Fame Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 24077 Ac ...
- linux 执行脚本
crontab -e 直接编辑定时脚本 保存后,在/var/spool/cron/下自动生成一个以用户名命名的脚本文件.
- 02 http,servlet,servletconfig,HttpServletRequest ,HttpServletResponse
Http协议 协议:双方在交互.通讯的时候, 遵守的一种规范.规则.http协议:针对网络上的客户端 与 服务器端在执行http请求的时候,遵守的一种规范. 其实就是规定了客户端在访问服务器端的时候, ...