目录
ES配置仓库
elasticsearch.yml
注册仓库
仓库相关操作
查看仓库
删除仓库
创建快照
快照相关操作
查询快照
删除快照
恢复快照
快照全量恢复
指定索引恢复
恢复时重命名
合并索引
索引相关操作
查询全量索引
查询索引状态
打开/关闭索引
删除索引
迁移步骤说明:
#挂载的共享目录,新旧集群每台都需要配置
配置项:path.repo: /filehome/ods/tmap
curl -u elastic:Cfca@Es1234 -XPUT '10.241.132.75: 9200/_snapshot/imp' -H 'content-Type:application/json' -d '{
"type": "fs",
"settings": {
"location": " /filehome/ods/tmap/imp",
"compress": "true",
"max_restore_bytes_per_sec": "50mb",
"max_snapshot_bytes_per_sec": "50mb"
}
}'
curl -u elastic:Cfca@Es1234 -XGET '10.241.132.75:9200/_snapshot/_all?pretty'
#多集群操作后仓库数据发生变化注销仓库,后重新注册(注销仓库不会删除仓库下快照)
curl -u elastic:Cfca@Es1234 -XDELETE '10.241.132.75:9200/_snapshot/exp'
#全量索引创建快照,es根据已创建快照增量备份
curl -u elastic:Cfca@Es1234 -XPUT '10.241.132.75:9200/_snapshot/exp/snapshot_1?wait_for_completion=true'
#指定索引创建快照
curl -u elastic:Cfca@Es1234 -XPUT '10.241.132.75:9200/_snapshot/exp/snapshot_75?wait_for_completion=true' -H 'content-Type:application/json' -d '{ "indices": "index1,index2,..,… "}'
curl -u elastic:Cfca@Es1234 -XGET '10.241.22.17:9200/_snapshot/exp/_all?pretty'
curl -u elastic:Cfca@Es1234 -XDELETE '10.241.132.75:9200/_snapshot/exp/snapshot_1'
curl -u elastic:Cfca@Es1234 -XPOST '10.241.22.17:9200/_snapshot/exp/snapshot_75/_restore'
curl -u elastic:Cfca@Es1234 -XPOST '10.241.22.17:9200/_snapshot/exp/snapshot_75/_restore' -H 'content-Type:application/json' -d '{"indices":"eventindex"}'
#二次恢复时将索引重命名防止删除已恢复数据
curl -u elastic:Cfca@Es1234 -X POST "10.241.22.17:9200/_snapshot/exp/snapshot_17.20230227/_restore?pretty" -H 'Content-Type: application/json' -d'
{
"indices": "index1,index2,…",
"rename_pattern": "(.+)",
"rename_replacement": "restored-$1"
}'
#reindex将restored-tradeindex索引数据合并到tradeindex,不会对tradeindex原数据修改
curl -u elastic:Cfca@Es1234 -X POST "10.241.22.17:9200/_reindex?pretty" -H 'Content-Type: application/json' -d'
{
"source": {
"index": "restored-tradeindex"
},
"dest": {
"index": "tradeindex"
}
}'
curl -u elastic:Cfca@Es1234 '10.241.22.17:9200/_cat/indices?v'
curl -u elastic:Cfca@Es1234 -XGET '10.241.22.17:9200/_cat/indices/eventindex?v'
#open/close
curl -u elastic:Cfca@Es1234 -XPOST '10.241.22.17:9200/eventindex/_close?pretty
#慎用通配符*,_all,防止误删
curl -u elastic:Cfca@Es1234 -XDELETE '10.241.22.17:9200/index,habit*'