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. HTML表单与输入实例

    解释HTML 表单用于搜集不同类型的用户输入.HTML 表单包含表单元素.表单元素指的是不同类型的 input 元素.复选框.单选按钮.提交按钮等等.<input> 元素<input ...

  2. 一个Boss直聘机器人, 自动回复发简历

    goBoss 基佬github地址 这是基于go语言编写的一款boss直聘机器人软件(牛人版).附上Python版本, 无需配置Go环境, 我会提供windows和macos的可执行程序.不喜勿喷O( ...

  3. VLAN入门知识

    版权声明: https://blog.csdn.net/xinyuan510214/article/details/52020987 本文乃fireaxe原创,使用GPL发布,可以自由拷贝,转载.但转 ...

  4. ping命令使用及其常用参数

    PING (Packet Internet Groper),因特网包探索器,用于测试网络连接量检查网络是否连通,可以很好地帮助我们分析和判定网络故障.Ping发送一个ICMP(Internet Con ...

  5. 微软职位内部推荐-Senior SW Engineer for Application Ecosystem

    微软近期Open的职位: Job posting title: Senior Development Engineer Location: China, Beijing Division: Opera ...

  6. Alpha阶段_团队分数分配

    小组成员 分数分配 薄霖 74 徐越 65 赵庶宏 65 赵铭 41 武鑫 39 卞忠昊 36 叶能端 30

  7. No.1101_第十次团队会议

    今天项目进展很多,大家都在现在的成果而开心,信心高涨,后面的任务的完成也基本都能指日可待.之前团队出现了各种问题,沟通出现了很多障碍,导致各方面受阻.现在大家再面对面坦诚相对,交流了一下自己的想法,结 ...

  8. 【Alpha】第九次Scrum meeting

    今日任务一览: 姓名 今日完成任务 所耗时间 刘乾 由于发现之前版本的模板引擎存在致命bug,所以重新更换,现在使用jinja2作为模板渲染引擎. 3 鲁聃 卤蛋今天为了给编译老师做视频,没有做软工项 ...

  9. 20135316王剑桥Linux内核学习笔记

    王剑桥Linux内核学习笔记 <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 计算机是如何工作的 个人理 ...

  10. C语言编程—自动生成四则运算升级版

    #include<stdio.h> #include<time.h> struct fenshu { int fenzi; int fenmu; }Fenshu[]; int ...