elasticsearch-dump 迁移es数据 (elasticdump)
elasticsearch 部分查询语句
# 获取集群的节点列表:
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'
参考链接: https://blog.csdn.net/pilihaotian/article/details/52452014
github地址 :https://github.com/taskrabbit/elasticsearch-dump
或者 : https://www.npmjs.com/package/elasticdump
wget https://nodejs.org/dist/v8.11.2/node-v8.11.2-linux-x64.tar.xz tar xf node-v8.11.2-linux-x64.tar.xz mv node-v8.11.2-linux-x64 /usr/local ln -s /usr/local/node-v8.11.2-linux-x64/bin/npm /usr/local/bin/npm ln -s /usr/local/node-v8.11.2-linux-x64/bin/node /usr/local/bin/node npm init -f npm install elasticdump #因为我只用一次,所以这里没有安装到全局,需要到node_modules目录下才能找到 elasticdump , 我安装的位置如下: /usr/local/node-v8.11.2-linux-x64/node_modules/elasticdump/bin/elasticfump
数据迁移:
'#拷贝analyzer分词
elasticdump \
--input=http://production.es.com:9200/my_index \
--output=http://staging.es.com:9200/my_index \
--type=analyzer
'#拷贝映射
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
# 注意 elasticdump 提供给了--httpAuthFile 参数来做认证
--httpAuthFile When using http auth provide credentials in ini file in form
`user=<username>
password=<password>` # 只需要写一个ini文件 ,文件中写入用户名和密码就可以了
# 这里其实还有另外一个好的方法
# 在--input参数和--output参数的的url中添加账号密码
# 例如
elasticdump \
--input=http://prod-username:prod-passowrd@production.es.com:9200/my_index \
--output=http://stage-username:stage-password@staging.es.com:9200/my_index \
--type=data
如果网络情况不好,或者没有网络还可以先备份到文件:
# 备份索引数据到文件里:
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 # 备份到标准输出,且进行压缩(这里有一个需要注意的地方,我查询索引信息有6.4G,用下面的方式备份后得到一个789M的压缩文件,这个压缩文件解压后有19G):
elasticdump \
--input=http://production.es.com:9200/my_index \
--output=$ \
| gzip > /data/my_index.json.gz # 把一个查询结果备份到文件中
elasticdump \
--input=http://production.es.com:9200/my_index \
--output=query.json \
--searchBody '{"query":{"term":{"username": "admin"}}}'
elasticdump还是非常方便的,主要是可以指定查询条件,把查询结果进行备份。如果按照日期进行查询,那么就可以迁移指定之间段内的数据, 恢复数据
# 将备份文件的数据导入ES
elasticdump \
--input=./data.json \
--output=http://es.com:9200
其实对ES了解还很少,中间可能有问题,还需要学习,就目前的了解程度,不保证上面的步骤完整,只是给大家一个大概的思路。
elasticsearch-dump 迁移es数据 (elasticdump)的更多相关文章
- ELK之elasticdump迁移es数据
参考:https://www.cnblogs.com/resn/p/9082663.html elasticsearch部分查询语句 获取集群节点列表 curl "172.16.30.55: ...
- 使用elasticdump迁移es数据
安装elasticdump github地址:https://github.com/elasticsearch-dump/elasticsearch-dump # yum -y install npm ...
- 使用Elasticsearch-dump迁移ES数据
1. Elasticsearch-dump 安装 1) yum install epel-release 2) yum install nodejs 3) yum install nodejs npm ...
- 实际使用Elasticdump工具对Elasticsearch集群进行数据备份和数据还原
文/朱季谦 目录 一.Elasticdump工具介绍 二.Elasticdump工具安装 三.Elasticdump工具使用 最近在开发当中做了一些涉及到Elasticsearch映射结构及数据导出导 ...
- ELK数据迁移,ES快照备份迁移
通过curl命令或者kibana快照备份,恢复的方式进行数据迁移 环境介绍 之前创建的ELK 因为VPC环境的问题,需要对ELK从新部署,但是还需要保留现有的数据,于是便有了这篇文档. 10.0.20 ...
- es 数据 导出 到 MySQL
暂时没有找到直接 导出到 mysql 数据库的工具 或者项目 目前实现思路: 使用 elasticdump 工具 实现 从 es 数据 导出到 json 文件 ,然后 使用 脚本程序 操作 改 js ...
- 你的ES数据备份了吗?
前言: 无论使用哪种存储软件,定期的备份数据都是重中之重,在使用ElasticSearch的时候,随着数据日益积累,存放es数据的磁盘空间也捉襟见肘, 此时对于业务功能使用不到的索引数据,又不能直接删 ...
- Elasticsearch 全量遍历数据
1,利用分页,from,to参数,但是当数据量特别大的时候(大约100w),分页是不现实的,排序排不开. 2,利用scan功能. 上 Python代码 from elasticsearch impor ...
- 通过hive向写elasticsearch的写如数据
通过hive向写elasticsearch的写如数据 hive 和 elasticsearch 的整合可以参考官方的文档: ES-hadoop的hive整合 : https://www.elastic ...
随机推荐
- OpenGL 笔记 <2> Compiling and Linking a shader program
Preface 这一节所有的主要内容都在一个OpenGL库文件中<LoadShaders.h> ,只需要用LoadShader()函数进行加载即可.但是由于老是出错,所以自己实现了一下,也 ...
- ssm整合各配置文件
ssm整合 1.配置web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns ...
- linux一切皆文件之tcp socket描述符(三)
一.知识准备 1.在linux中,一切皆为文件,所有不同种类的类型都被抽象成文件(比如:块设备,socket套接字,pipe队列) 2.操作这些不同的类型就像操作文件一样,比如增删改查等 二.环境准备 ...
- Laravel 5.6 视图用Blade语法传递变量和流程控制if 语句和循环语句
Laravel5.6 视图用Blade语法传递变量和流程控制if 语句和循环语句 Laravel 的 View 部分是内置了两套输出系统:直接输出和使用 Blade 引擎“编译”后输出,默认情况下它们 ...
- Fragment 使用总结
1. 要深刻理解Fragment 的生命周期 2. Fragment.getActivity()并不能保证非空. 3.如果在Fragment中有异步的回调, 特别要注意此时Fragment 是否还at ...
- Error:java: 无效的源发行版: 1.8
出现这种情况是gradle或者maven的版本与 本地电脑jdk不一致,具体看一下链接 http://blog.csdn.net/leixingbang1989/article/details/519 ...
- DHCP中续代理
什么是DHCP中继代理? 答:DCHP中继代理(即DHCP Relay Agent )用于转发来自于另一个没有DHCP服务器子网段中的客户端的DHCP请求,即当一台DCHP客户机发起请求后,此时DH ...
- DHCP介绍
DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工作, 主要有两个用途:给内部网络或网络服务供应商自动分配IP ...
- SqlServer测试SQL语句执行效率
方法一: SET STATISTICS io ON SET STATISTICS time ON go ---需要测试的sql语句 go SET STATISTICS profile OFF SET ...
- LVS(Linus Virtual Server):三种负载均衡方式比较+另三种负载均衡方式
还有个姊妹篇也可以参考这个文章:六大Web负载均衡原理与实现 什么是LVS (Linux Virtual Server)? 首先简单介绍一下LVS (Linux Virtual Server)到底 ...