前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >「最佳实践」ES_IndexPropertiesSync 工具使用指导

「最佳实践」ES_IndexPropertiesSync 工具使用指导

原创
作者头像
岳涛
发布2024-11-28 15:38:48
发布2024-11-28 15:38:48
10500
代码可运行
举报
文章被收录于专栏:大数据生态大数据生态
运行总次数:0
代码可运行

说明

本文描述问题及解决方法同样适用于 腾讯云 Elasticsearch Service(ES)

修订历史

修订编号

修订日期

变更描述

撰写

V1.0

2024-02-23

创建文档

腾讯云/开发者社区/岳涛

V1.1

2024-02-27

更新:支持更新嵌套 key 的 value

腾讯云/开发者社区/岳涛

V1.2

2024-03-26

更新:新增 AWS Opensearch 兼容,并默认移除个别 ES 不兼容的参数

腾讯云/开发者社区/岳涛

V1.3

2024-04-10

更新:修复已知问题

腾讯云/开发者社区/岳涛

V1.4

2024-04-16

更新:增加 timeout 参数

腾讯云/开发者社区/岳涛

V1.5

2024-06-05

更新:增加后缀参数

腾讯云/开发者社区/岳涛

V1.6

2024-06-18

更新:修复已知问题

腾讯云/开发者社区/岳涛

V1.7

2024-06-27

更新:适配 8.x,默认移除settings history 参数

腾讯云/开发者社区/岳涛

V1.8

2024-11-13

更新:允许不指定端口 ● http 即为 80 ● https 即为 443

腾讯云/开发者社区/岳涛

V1.9

2024-11-14

更新:兼容 AWS Opensearch 免密认证

腾讯云/开发者社区/岳涛

V1.10

2024-11-15

更新:修复 AWS Opensearch type 识别问题

腾讯云/开发者社区/岳涛

V1.11

2024-11-27

更新:修复 AWS Opensearch 携带低版本 ES 属性(< 7)而导致同步失败的问题

腾讯云/开发者社区/岳涛

相关说明

使用说明

● 本工具适用于社区版本为 5.x/6.x/7.x/8.x 的 es、以及版本为 2.x 的 opensearch,其他社区版本暂未验证

● 本工具适用于一键同步索引属性(setting / mapping)

● 本工具适用于解决索引属性兼容性问题,在同步时支持修改、删除属性

兼容说明

● 当两端都是 ES 5.x 时,兼容 ES 5.x 的多 type,否则只同步单 type;

● 调整了 ES 7.x 以下及 opensearch 的 type 层级,对 mapping 结构进行了兼容,不影响后续问题;

● 默认丢弃 Opensearch 参数 index.replication.type,该特性 ES 不兼容,移除不影响使用。

工具适用场景

● elasticsearch 索引属性同步

1. 准备工作

服务器准备

准备一台可以访问到 ES 实例的服务器,其网络环境应该是互通的;

2. 执行方式

2.1. 一键安装

安装 ES_IndexPropertiesSync:

Centos
代码语言:javascript
代码运行次数:0
运行
复制
rpm -vih https://tools-release-12345678.cos.ap-shanghai.myqcloud.com/elasticsearch/packages/es-index-properties-sync-xxxx.x86_64.rpm

或下载后上传再使用 rpm 安装:

代码语言:javascript
代码运行次数:0
运行
复制
rpm -vih es-index-properties-sync-lastest.x86_64.rpm
Ubuntu
代码语言:javascript
代码运行次数:0
运行
复制
wget https://tools-release-12345678.cos.ap-shanghai.myqcloud.com/elasticsearch/packages/es-index-properties-sync-xxxx.amd64.deb -O /tmp/eips.deb && sudo dpkg -i /tmp/eips.deb

或下载后上传再使用 dpkg 安装:

代码语言:javascript
代码运行次数:0
运行
复制
dpkg -i es-index-properties-sync-lastest.amd64.deb

安装完成后会生成 es-backup-progress 命令,查看 help:

代码语言:javascript
代码运行次数:0
运行
复制
es-index-properties-sync --help

2.2. 参数说明

代码语言:javascript
代码运行次数:0
运行
复制
  --src_url             源 URL
  --src_user            源用户
  --src_password        源密码
  --dst_url DST_URL     目标 URL
  --dst_user DST_USER   目标用户
  --dst_password        目标密码
  --indices             需要同步的索引
  --updates-settings    需要更新/添加的setting
  --updates-mappings    需要更新/添加的mapping
  --index_suffix        增加索引后缀
  --timeout TIMEOUT     超时参数

2.3. 执行示例

示例 1

● ES 实例没有密码认证

● 同步所有索引(排除.开头的系统索引)

代码语言:javascript
代码运行次数:0
运行
复制
es-index-properties-sync --src_url http://10.0.10.xx:9200 --dst_url http://10.0.10.xx:9200 --indices '*,-.*'

示例 2

● ES 实例有密码认证,用户名默认 elastic

● 同步指定字符开头的通配索引

● 移除 setting 参数

代码语言:javascript
代码运行次数:0
运行
复制
es-index-properties-sync \
  --src_url http://10.0.10.xx:9200 \
  --dst_url http://10.0.10.xx:9200 \
  --src_password ****** \
  --dst_password ****** \
  --indices 'users-2022*' \
  --updates-settings '[{"action": "remove", "key": "index.bulk_routing.enabled"}]'

示例 3

● ES 实例有密码认证,指定用户名

● ES 实例指定端口

● 同步指定索引

● 移除 & 修改 setting 参数

● 移除 & 修改 mapping 参数

代码语言:javascript
代码运行次数:0
运行
复制
es-index-properties-sync \
  --src_url http://10.0.10.xx:9200 \
  --dst_url http://10.0.10.xx:9200 \
  --src_user elastic \
  --dst_user elastic \
  --src_password ****** \
  --dst_password ****** \
  --indices 'users-2024.02.27' \
  --updates-settings '[{"action": "remove", "key": "index.bulk_routing.enabled"}, {"action": "update", "key": "index.number_of_shards", "value": 10}]' \
  --updates-mappings '[{"action": "update", "key": "properties.job.type", "value": "keyword"},{"action": "remove", "key": "properties.job.fields"}]'

示例 4

● ES 实例有密码认证,指定用户名

● ES 实例指定端口

● 同步指定索引

修改 mapping 参数且value中包含单引号

代码语言:javascript
代码运行次数:0
运行
复制
es-index-properties-sync \
  --src_url http://10.0.10.xx:9200 \
  --dst_url http://10.0.10.xx:9200 \
  --src_user elastic \
  --dst_user elastic \
  --src_password ****** \
  --dst_password ****** \
  --indices 'users-2024.02.27' \
  --updates-mappings '[{"action":"update","key":"properties.update_timestamp.format","value":"yyyy-MM-dd'\''T'\''HH:mm:ssZ||yyyy-MM-dd'\''T'\''HH:mm:ss||yyyy-MM-dd HH:mm||yyyy-MM-dd'\''T'\''HH:mm:ss'\''+0800'\''"}]'

示例 5

● ES 实例有密码认证,指定用户名

● ES 实例指定端口

● 同步指定索引

7到8自研参数兼容

代码语言:javascript
代码运行次数:0
运行
复制
es-index-properties-sync \
  --src_url http://10.0.10.xx:9200 \
  --dst_url http://10.0.10.xx:9200 \
  --src_user elastic \
  --dst_user elastic \
  --src_password ****** \
  --dst_password ****** \
  --indices 'users-2024.02.27' \
  --updates-settings '[{"action": "remove", "key": "index.merge.policy.auto_merge_enabled"},{"action": "remove", "key": "index.merge.policy.inactive_merge_enabled"},{"action": "remove", "key": "index.bulk_routing.enabled"},{"action": "remove", "key": "index.search.slowlog"},{"action": "remove", "key": "index.indexing.slowlog"}]' \
  --updates-mappings '[{"action": "remove", "key": "_all"}]'

示例 6

● ES 实例有密码认证,指定用户名

● ES 实例指定端口

● 同步指定索引

● 修改分片参数

● 指定后缀

代码语言:javascript
代码运行次数:0
运行
复制
es-index-properties-sync \
  --src_url http://10.0.10.xx:9200 \
  --dst_url http://10.0.10.xx:9200 \
  --src_user elastic \
  --dst_user elastic \
  --src_password ****** \
  --dst_password ****** \
  --indices '*2024.06*' \
  --updates-settings '[{"action": "update", "key": "index.number_of_shards", "value": 6}]' \
  --index_suffix _v2

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 说明
  • 相关说明
    • 使用说明
    • 兼容说明
    • 工具适用场景
  • 1. 准备工作
  • 2. 执行方式
    • 2.1. 一键安装
      • 安装 ES_IndexPropertiesSync:
    • 2.2. 参数说明
    • 2.3. 执行示例
      • 示例 1
      • 示例 2
      • 示例 3
      • 示例 4
      • 示例 5
      • 示例 6
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档