本文描述问题及解决方法同样适用于 腾讯云 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 索引属性同步
● 服务器准备
准备一台可以访问到 ES 实例的服务器,其网络环境应该是互通的;
rpm -vih https://tools-release-12345678.cos.ap-shanghai.myqcloud.com/elasticsearch/packages/es-index-properties-sync-xxxx.x86_64.rpm
或下载后上传再使用 rpm 安装:
rpm -vih es-index-properties-sync-lastest.x86_64.rpm
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 安装:
dpkg -i es-index-properties-sync-lastest.amd64.deb
安装完成后会生成 es-backup-progress 命令,查看 help:
es-index-properties-sync --help
--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 超时参数
● ES 实例没有密码认证
● 同步所有索引(排除.开头的系统索引)
es-index-properties-sync --src_url http://10.0.10.xx:9200 --dst_url http://10.0.10.xx:9200 --indices '*,-.*'
● ES 实例有密码认证,用户名默认 elastic
● 同步指定字符开头的通配索引
● 移除 setting 参数
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"}]'
● ES 实例有密码认证,指定用户名
● ES 实例指定端口
● 同步指定索引
● 移除 & 修改 setting 参数
● 移除 & 修改 mapping 参数
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"}]'
● ES 实例有密码认证,指定用户名
● ES 实例指定端口
● 同步指定索引
● 修改 mapping 参数且value中包含单引号
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'\''"}]'
● ES 实例有密码认证,指定用户名
● ES 实例指定端口
● 同步指定索引
● 7到8自研参数兼容
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"}]'
● ES 实例有密码认证,指定用户名
● ES 实例指定端口
● 同步指定索引
● 修改分片参数
● 指定后缀
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 删除。