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)的更多相关文章

  1. ELK之elasticdump迁移es数据

    参考:https://www.cnblogs.com/resn/p/9082663.html elasticsearch部分查询语句 获取集群节点列表 curl "172.16.30.55: ...

  2. 使用elasticdump迁移es数据

    安装elasticdump github地址:https://github.com/elasticsearch-dump/elasticsearch-dump # yum -y install npm ...

  3. 使用Elasticsearch-dump迁移ES数据

    1. Elasticsearch-dump 安装 1) yum install epel-release 2) yum install nodejs 3) yum install nodejs npm ...

  4. 实际使用Elasticdump工具对Elasticsearch集群进行数据备份和数据还原

    文/朱季谦 目录 一.Elasticdump工具介绍 二.Elasticdump工具安装 三.Elasticdump工具使用 最近在开发当中做了一些涉及到Elasticsearch映射结构及数据导出导 ...

  5. ELK数据迁移,ES快照备份迁移

    通过curl命令或者kibana快照备份,恢复的方式进行数据迁移 环境介绍 之前创建的ELK 因为VPC环境的问题,需要对ELK从新部署,但是还需要保留现有的数据,于是便有了这篇文档. 10.0.20 ...

  6. es 数据 导出 到 MySQL

    暂时没有找到直接 导出到 mysql 数据库的工具 或者项目 目前实现思路: 使用 elasticdump  工具 实现 从 es 数据 导出到 json 文件 ,然后 使用 脚本程序 操作 改 js ...

  7. 你的ES数据备份了吗?

    前言: 无论使用哪种存储软件,定期的备份数据都是重中之重,在使用ElasticSearch的时候,随着数据日益积累,存放es数据的磁盘空间也捉襟见肘, 此时对于业务功能使用不到的索引数据,又不能直接删 ...

  8. Elasticsearch 全量遍历数据

    1,利用分页,from,to参数,但是当数据量特别大的时候(大约100w),分页是不现实的,排序排不开. 2,利用scan功能. 上 Python代码 from elasticsearch impor ...

  9. 通过hive向写elasticsearch的写如数据

    通过hive向写elasticsearch的写如数据 hive 和 elasticsearch 的整合可以参考官方的文档: ES-hadoop的hive整合 : https://www.elastic ...

随机推荐

  1. 七个要素帮你打造现象级手游!优化程度堪比《QQ飞车》

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由WeTest质量开放平台团队发表于云+社区专栏 作者:申江涛,腾讯互娱客户端工程师 商业转载请联系腾讯WeTest获得授权,非商业转载 ...

  2. Unity插件-NGUI学习笔记

    Anchors 的作用 类似Android里面的.9格式图片的功能, 边框可以随着文字变大而变大. 实现方法: 用NGUI 创建一个Sprite, 命名为TextBg, 一个Label, Label的 ...

  3. 如何在一个电脑上同时使用两个Git的账号

    前言 又需要登录公司的账号,又想在电脑上使用自己的账号. 实现 首先是git config方面的设置,要取消掉原本对于git账号的全局设置. git config --global --unset u ...

  4. 第二阶段Sprint9

    昨天:重新规划主界面,把视频录制暂放到主页面里 今天:查看有关“共享平台”的资料,看如何实现上传下载功能,并尝试编码, 遇到的问题:看不懂什么意思,照例子做不行,还得需要联网等

  5. Mac安装Appium的Android环境

    1.下载android sdk http://down.tech.sina.com.cn/page/45703.html   2.解压,配置环境变量   ANDROID_HOME=/Users/wp/ ...

  6. mysql 清空数据

    清空数据有2 个命令 -- 清空全部数据,不写日志,不可恢复,速度极快 truncate table 表名; -- 清空全部数据,写日志,数据可恢复,速度慢 delete from 表名 业务需求:清 ...

  7. Zoom 会议系统

    Jfrog的培训过程中 发现ppt的效果很不理想  讲师使用zoom的方式效果很好 首先说一下 zoom的定价体系 官网信息: https://www.zoom.us/profile 好像必须使用 企 ...

  8. Delphi中如何实现模拟组合按键,如发送Ctrl+F的按键

    利用 keybd_event函数可实现,如下面的代码用以实现在一个公共菜单中模拟Ctrl_F按钮以调用DBGridEH的查找对话框功能:这是在一个ActionList中的某一Action的OnExec ...

  9. Vue项目部署问题及解决方案

    Vue项目部署问题及解决方案 Vue-Router 有两种模式,默认是 hash 模式,另外一种是 history 模式. hash:也就是地址栏里的 # 符号.比如 http://www.examp ...

  10. Cucumber java + Webdriver(一)

    一.打开Eclipse,新建一个maven项目,打开pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xm ...