我在本地备份了mongodb (第4版)
mongodump -u adminUser --authenticationDatabase admin --gzip --archive=/tmp/file.gz --db <dbname>现在,我想将这些数据还原到我的远程mongodb,它是一个副本集,其中两个副本运行在一个kubernetes集群上。
诺马利,我会用
mongorestore -u adminUser --authenticationDatabase admin --gzip --archive=/tmp/file.gz但是,如何在复制的体系结构上进行这种恢复呢?
我必须在任何荚实例上运行shell吗?
kubectl exec -it <pod-name> -n mongodb -- bash发布于 2022-11-09 08:56:49
您需要连接到一个复制集。它需要在连接字符串uri中设置:
mongorestore --uri="mongodb://adminUser:password@hostname1,hostname2,hostname3/?authSource=admin&replicaSet=<replSetName>"根据文档,您可以使用--host参数指定副本集。
mongorestore -u adminUser --authenticationDatabase admin --host=<replSetName>/hostname1,hostname2,hostname3mongorestore将连接到主成员,将数据还原到其中,然后复制到辅助成员。
如果您必须恢复大量数据,那么请考虑通过从另一个成员复制数据文件进行同步
https://stackoverflow.com/questions/74371767
复制相似问题