【发布时间】:2021-03-16 05:14:59
【问题描述】:
我是 mongodb 的新手,我一直在尝试从 mongodump 恢复我的数据。每当我尝试在终端中运行脚本时,它几乎完全执行,然后恢复。我试过环顾四周,但解决方案没有触及 'not master' 问题
这是我的 mongorestore 脚本;为简洁起见的占位符
mongorestore --host 'the-given-shard.net:27017' \
--ssl -u 'username' -p 'placeholder' --authenticationDatabase admin --db=loc8r \
--collection=locations dump/loc8r/locations.bson
这是输出
2020-02-04T17:30:21.817+0000 checking for collection data in dump/loc8r/locations.bson
2020-02-04T17:30:22.123+0000 restoring to existing collection loc8r.locations without dropping
2020-02-04T17:30:22.123+0000 reading metadata for loc8r.locations from dump/loc8r/locations.metadata.json
2020-02-04T17:30:22.124+0000 restoring loc8r.locations from dump/loc8r/locations.bson
2020-02-04T17:30:24.205+0000 [########################] loc8r.locations 8.21KB/8.21KB (100.0%)
2020-02-04T17:30:24.888+0000 [########################] loc8r.locations 8.21KB/8.21KB (100.0%)
2020-02-04T17:30:24.888+0000 finished restoring loc8r.locations (0 documents, 0 failures)
2020-02-04T17:30:24.889+0000 Failed: loc8r.locations: error restoring from dump/loc8r/locations.bson: (NotMaster) not master
2020-02-04T17:30:24.889+0000 0 document(s) restored successfully. 0 document(s) failed to restore.
【问题讨论】:
-
"NotMaster" 通常意味着你连接到一个无法写入的辅助节点
-
在我连接的节点或服务器中?那我该如何连接到主节点呢?
-
指的是服务器。如果您有副本集,请使用
--host replicaSetName/hostname:port。你也可以用shell连接到节点并运行db.isMaster()来找出当前的主节点 -
成功了!
db.isMaster()成功了;原来我一直在辅助节点上。非常感谢 -
谢谢@Joe,我真的很感激;我会这样做的
标签: mongodb mongodb-atlas mongorestore