当前位置: 首页 > news >正文

网站建设 空间阿森纳英超积分

网站建设 空间,阿森纳英超积分,腾讯大浙网 网站开发,做公司网站需要准备什么本文使用 elasticdump 做数据迁移,支持在线和离线俩种方式,适用于数据量比较小的情况。 1、Node 安装 由于elasticdump 依赖于 node,首先需要安装下node。 1.1、 Linux 安装 $ wget https://nodejs.org/dist/v10.15.0/node-v10.15.0-linu…

在这里插入图片描述

本文使用 elasticdump 做数据迁移,支持在线和离线俩种方式,适用于数据量比较小的情况。

1、Node 安装

由于elasticdump 依赖于 node,首先需要安装下node。

1.1、 Linux 安装

$ wget https://nodejs.org/dist/v10.15.0/node-v10.15.0-linux-x64.tar.xz
$ tar -xf node-v10.15.0-linux-x64.tar.xz
#配置相关的环境变量
$ vim /etc/profile
> PATH=$PATH:/software/node-v10.15.0-linux-x64/bin
$ source /etc/profile

1.2、Windows安装

选择对应的windows版本一路下一步即可,以下是64位的安装包标注:
在这里插入图片描述

2、安装 elasticdump

linux和windows基本相同,建议全局安装下:

#本地安装和全局安装的区别在于它是否自动给你设置环境变量,其他的没有区别
# 本地安装
$ npm install elasticdump
$ ./bin/elasticdump
# 全局安装
$ npm install elasticdump -g
$ elasticdump

3、数据迁移

ES索引的迁移需要一个个的迁移,并且分:analyzer、mapping、data三部分。

备注:
http://production.es.com:9200/my_index 为源索引
http://staging.es.com:9200/my_index 为目标索引
“” 为换行符,一行可以不用写
如果es是有用户密码做为鉴权的,则需要修改下URL:

# 注意 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

3.1、在线迁移

#拷贝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

3.2、离线迁移

3.2.1 备份

# 备份索引数据到文件里:
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"}}}'

3.2.2 恢复

# 将备份文件的数据导入ES
elasticdump \--input=./data.json \--output=http://es.com:9200 

4、Docker 环境下ES迁移

# 镜像下载
$ docker pull taskrabbit/elasticsearch-dump
# 下面还是例子:通过镜像导出数据到本地
# 创建一个文件夹用于保存导出数据
$ mkdir -p /root/data
# 下面需要对路径进行映射并执行命令(导出mapping)
$ docker run --rm -ti -v /data:/tmp taskrabbit/elasticsearch-dump \--input=http://production.es.com:9200/my_index \--output=/tmp/my_index_mapping.json \--type=mapping
# 导出(data)
$ docker run --rm -ti -v /root/data:/tmp taskrabbit/elasticsearch-dump \--input=http://192.168.56.104:9200/test_index \--output=/tmp/elasticdump_export.json \--type=data-----------------------------------------------------------------------------
# 以下内容为ES -> ES的数据迁移例子
$ docker run --rm -ti taskrabbit/elasticsearch-dump \--input=http://production.es.com:9200/my_index \--output=http://staging.es.com:9200/my_index \--type=mapping
$ docker run --rm -ti taskrabbit/elasticsearch-dump \--input=http://production.es.com:9200/my_index \--output=http://staging.es.com:9200/my_index \--type=data

5、附录

# Copy an index from production to staging with analyzer and mapping:
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# 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"}}}'# Copy a single shard data:
elasticdump \--input=http://es.com:9200/api \--output=http://es.com:9200/api2 \--params='{"preference" : "_shards:0"}'# Backup aliases to a file
elasticdump \--input=http://es.com:9200/index-name/alias-filter \--output=alias.json \--type=alias# Import aliases into ES
elasticdump \--input=./alias.json \--output=http://es.com:9200 \--type=alias# Backup templates to a file
elasticdump \--input=http://es.com:9200/template-filter \--output=templates.json \--type=template# Import templates into ES
elasticdump \--input=./templates.json \--output=http://es.com:9200 \--type=template# Split files into multiple parts
elasticdump \--input=http://production.es.com:9200/my_index \--output=/data/my_index.json \--fileSize=10mb# Import data from S3 into ES (using s3urls)
elasticdump \--s3AccessKeyId "${access_key_id}" \--s3SecretAccessKey "${access_key_secret}" \--input "s3://${bucket_name}/${file_name}.json" \--output=http://production.es.com:9200/my_index# Export ES data to S3 (using s3urls)
elasticdump \--s3AccessKeyId "${access_key_id}" \--s3SecretAccessKey "${access_key_secret}" \--input=http://production.es.com:9200/my_index \--output "s3://${bucket_name}/${file_name}.json"
http://www.mmbaike.com/news/95726.html

相关文章:

  • 贵州做网站找谁seo推广软件
  • 网站有收录但是没排名交换友情链接平台
  • 阿里云可以建设网站吗站长资讯
  • 南通网站建设策划品牌推广的方式
  • 丹徒网站建设平台谷歌seo排名优化
  • 推销产品的万能句子济南网络优化网址
  • 做兼职编辑的网站seo培训中心
  • 怎样创建个人购物网站网络文章发布平台
  • 体验营销宁波seo推广公司排名
  • 祥云平台做网站好不好推广软文范文800字
  • 有人打电话说请我做网站 骗子十大流量平台
  • 做网站建设公司排名免费制作网站
  • 网站做推广需要营业执照徐州网站优化
  • 鲜花外贸网站建设上海推广网络营销咨询热线
  • 升降机网站怎么做揭阳seo快速排名
  • 网站开发简单吗厦门人才网官网招聘信息网
  • 网站提高banner图打开速度知名网站排名
  • 怎么做简单的网站公关公司
  • 网站超链接怎么做 word文档郑州网站推广技术
  • 佛山网站建设专业公司网络营销和直播电商专业学什么
  • 正常网站 月均ip pv建一个自己的网站
  • 国内网站如何做流量提供seo顾问服务适合的对象是
  • 网站 php 源码推广产品的方法和步骤
  • 怎样弄网站广告推广网站
  • 重庆北京网站建设网站seo标题优化技巧
  • 深圳网站建设是什么seo的基本步骤
  • 织梦cms官方网站网站设计的基本原则
  • 建设银行官网学生交费网站百度推广电话销售话术
  • 武汉网站开发公司哪家好企业培训心得
  • 乐辰网站建设网推是什么