2015-12-10 41 views
1

我试图在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和谷歌,但我可以找到包括-d或包括本地主机。然后我发现一篇文章说我没有为testdba用户授予userAdmin/userAdminAnyDatabase权限。这次我尝试以拥有userAdmin/userAdminAnyDatabase特权的admin用户身份运行。我使用的命令是:

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.

现在我真的很困惑,到底发生了什么,为什么我只面对这个文件的问题。另外,我无法理解当我试图以管理员身份进行还原时,为什么会出现如此不同的错误。

任何建议/帮助将不胜感激。

+0

毕竟这个失败了,我也尝试通过禁用auth = true来运行命令“mongorestore -u testdba -p xxxxxx -d prod079/data/backup --batchSize = 1”。这仍然没有锻炼。 – Manny

+1

尝试添加--authenticationDatabase管理作为额外的参数mongorestore命令 –

+0

我仍然得到这个:错误:没有授权prod079执行命令{插入:“system.users”,文件:[{_id:ObjectId('531e5251864fb4e84b '),pwd:“xxxxxxxx”,角色:[“dbAdmin”,“readWrite”,“userAdmin”],用户:“ab”}],writeConcern:{getLastError:1,w:1},ordered:false} – Manny

回答

2

我尝试了上面列出的所有方法,但都没有工作。

我将角色'恢复'给了管理员用户,它工作。

查看更多有关'恢复'在documentation信息。

相关问题