前置工作索引备份
1.索引备份
#创建Es备份仓库es_bk文件夹cd /iflytek/datamkdir es_bk#给es用户添加访问权限chown -R elastic:elastic /iflytek/data/es_bk/cd /iflytek/server/elasticsearch-5.4.3#配置es配置vim config/elasticsearch.yml#添加一下数据行 配置以上创建的文件夹path.repo: ["/iflytek/data/es_bk"]#重启ES 确认用户是否为elastickill -9 espidsu elasticcd /iflytek/server/elasticsearch-5.4.3/bin./elasticsearch -d
2.新建索引备份仓库
#新建备份仓库PUT _snapshot/my_backup{"type": "fs","settings": {"location": "/iflytek/data/es_bk","compress": true}}#查看备份仓库GET _snapshot/my_backup#备份索引tuling-swk-sw 为索引名称 my_backup为仓库名称PUT _snapshot/my_backup/snapshot_swk?wait_for_completion=true{"indices": "tuling-swk-sw","ignore_unavailable": true,"include_global_state": false}#恢复数据POST /_snapshot/my_backup/snapshot_swk/_restore{"indices": "tuling-swk-sw","rename_pattern": "index_(.+)","rename_replacement": "restored_index_$1"}
3.删除语句(非必要不执行)
#以下删除语句不要执行#删除备份DELETE _snapshot/my_backup/snapshot_swk#删除仓库DELETE _snapshot/my_backup#查看所有GET _snapshot/my_backup/_all
附(curl执行语句)
#创建仓库curl -XPUT "http://10.124.41.11:9209/_snapshot/my_backup" -H 'Content-Type: application/json' -d'{"type": "fs","settings": {"location": "/iflytek/data/es_bk","compress": true}}'#查看仓库curl -XGET "http://10.124.41.11:9209/_snapshot/my_backup"#备份索引curl -XPUT "http://10.124.41.11:9209/_snapshot/my_backup/snapshot_swk?wait_for_completion=true" -H 'Content-Type: application/json' -d'{"indices": "tuling-swk-sw","ignore_unavailable": true,"include_global_state": false}'#恢复索引数据curl -XPOST "http://10.124.41.11:9209/_snapshot/my_backup/snapshot_swk/_restore" -H 'Content-Type: application/json' -d'{"indices": "tuling-swk-sw","rename_pattern": "index_(.+)","rename_replacement": "restored_index_$1"}'curl -XDELETE "http://10.124.41.11:9209/_snapshot/my_backup/snapshot_swk"curl -XDELETE "http://10.124.41.11:9209/_snapshot/my_backup"curl -XDELETE "http://10.124.41.11:9209/_snapshot/my_backup"
