有两种方式实现:
1、快照和还原
2、导出和导入
一、快照和还原
1、在源Elasticsearch集群上创建快照存储库
PUT _snapshot/my_backup
{
"type": "fs",
"settings": {
"location": "/path/to/backup/directory"
}
}
2、创建快照
PUT _snapshot/my_backup/snapshot_1
{
"indices": "index1,index2",
"ignore_unavailable": true,
"include_global_state": false
}
3、在还原库上创建同样的快照存储库
PUT _snapshot/my_backup
{
"type": "fs",
"settings": {
"location": "/path/to/backup/directory"
}
}
4、从快照还原
POST _snapshot/my_backup/snapshot_1/_restore
{
"indices": "index1,index2",
"ignore_unavailable": true,
"include_global_state": false
}
二、使用导出和导入进行备份和恢复
1、导出索引数据文章来源:https://www.toymoban.com/news/detail-678420.html
POST _export
{
"indices": "index1,index2",
"query": {
"match_all": {}
},
"size": 1000,
"sort": ["_doc"]
}
2、导入数据文章来源地址https://www.toymoban.com/news/detail-678420.html
POST _import
{
"index": "index1",
"data": [
{"index": {"_id": "1"}},
{"field1": "value1", "field2": "value2"},
{"index": {"_id": "2"}},
{"field1": "value3", "field2": "value4"}
]
}
到了这里,关于Elasticsearch中的数据完全备份至另外的Elasticsearch的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!