有兩種方式實(shí)現(xiàn):
1、快照和還原
2、導(dǎo)出和導(dǎo)入
一、快照和還原
1、在源Elasticsearch集群上創(chuàng)建快照存儲(chǔ)庫
PUT _snapshot/my_backup
{
"type": "fs",
"settings": {
"location": "/path/to/backup/directory"
}
}
2、創(chuàng)建快照
PUT _snapshot/my_backup/snapshot_1
{
"indices": "index1,index2",
"ignore_unavailable": true,
"include_global_state": false
}
3、在還原庫上創(chuàng)建同樣的快照存儲(chǔ)庫
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
}
二、使用導(dǎo)出和導(dǎo)入進(jìn)行備份和恢復(fù)
1、導(dǎo)出索引數(shù)據(jù)文章來源:http://www.zghlxwxcb.cn/news/detail-678420.html
POST _export
{
"indices": "index1,index2",
"query": {
"match_all": {}
},
"size": 1000,
"sort": ["_doc"]
}
2、導(dǎo)入數(shù)據(jù)文章來源地址http://www.zghlxwxcb.cn/news/detail-678420.html
POST _import
{
"index": "index1",
"data": [
{"index": {"_id": "1"}},
{"field1": "value1", "field2": "value2"},
{"index": {"_id": "2"}},
{"field1": "value3", "field2": "value4"}
]
}
到了這里,關(guān)于Elasticsearch中的數(shù)據(jù)完全備份至另外的Elasticsearch的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!