我正在尝试使用 mongo 3.0.7 中的 mongorestore 恢复一个大文件。 prod079 文件夹下的所有文件都已成功恢复,除了一个名为 system.users 的文件。用于恢复的命令是
mongorestore -u testdba -p xxxxxx -d prod079 /data/backup --batchSize=1
上面的命令从同一个文件夹中恢复了 400GB 的数据,但似乎只用这个文件就失败了。
我收到这样的错误:
error: not authorized on prod079 to execute command { insert: "system.users", documents: [ { _id: ObjectId('531e5251864fb4e84b'), pwd: "xxxxxxxx", roles: [ "dbAdmin", "readWrite", "userAdmin" ], user: "ab" } ], writeConcern: { getLastError: 1, w: 1 }, ordered: false }
2015-12-10T13:20:49.196-0500 error: not authorized on prod079 to execute command { insert: "system.users", documents: [ { _id: ObjectId('531e5251864fb4e84c'), user: "abuser", pwd: "xxxxxxxx", roles: [ "read" ] } ], writeConcern: { getLastError: 1, w: 1 }, ordered: false }
2015-12-10T13:20:49.196-0500 error: not authorized on prod079 to execute command { insert: "system.users", documents: [ { _id: ObjectId('5452840f169afa3a2'), user: "asmeta", pwd: "xxxxxxxx", roles: [ "read" ] } ], writeConcern: { getLastError: 1, w: 1 }, ordered: false }
所以基本上我会遇到很多这样的错误。我尝试在 stackoverflow 和 google 上寻找类似的错误,但我能找到的只是包含 -d 或包含 localhost。然后我发现一个帖子说我没有为 testdba 用户授予 userAdmin/userAdminAnyDatabase 权限。这次我尝试以具有 userAdmin/userAdminAnyDatabase 权限的管理员用户身份运行。我使用的命令是:
mongorestore -u admin -p xxxxx -d prod079 /data/backup --batchSize=1
这次我遇到了不同类型的错误。它说 :
2015-12-10T13:17:59.940-0500 Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.
现在我真的很困惑发生了什么以及为什么我单独面对这个文件的问题。此外,当我尝试以管理员身份恢复时,我无法理解为什么我会收到如此不同的错误。
任何建议/帮助将不胜感激。
最佳答案
我尝试了上面列出的所有方法,但都没有奏效。
我将“恢复”角色赋予管理员用户,并且它起作用了。
在 documentation 中查看有关“恢复”的更多信息。
关于mongodb - 错误 : not authorized on db to execute command,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34211219/