我正在尝试运行以下命令来获取我的副本集状态。但我得到了以下错误:
db.adminCommand({replSetGetStatus: 1})
{
"ok" : 0,
"errmsg" : "not authorized on admin to execute command { replSetGetStatus: 1.0 }",
"code" : 13
}
这是db.system.users集合中的用户文档
{
"_id" : "admin.prodDb",
"user" : "prodDb",
"db" : "admin",
"credentials" : {
"SCRAM-SHA-1" : {
"iterationCount" : 10000,
"salt" : "okdfd74YA3/mTiSad2+zjS4Ag==",
"storedKey" : "aoCDvsdfh+asvbGajSinnUvXaqc08=",
"serverKey" : "kdc6B3LgvrNE4gT1CsBEzEvDCadms="
}
},
"roles" : [
{
"role" : "readWrite",
"db" : "XXXX"
},
{
"role" : "readWrite",
"db" : "XXXX"
},
{
"role" : "readWrite",
"db" : "XXXX"
},
{
"role" : "readWrite",
"db" : "XXXX"
}
]
}
然后我尝试通过执行此操作来提供对admin db的读访问权限 -
db.system.users.update({'user': 'prodDb'}, {$push: {"roles": {"role": "read", "db": "admin"}}})
我还将角色从read
更改为readWrite
,但同样的问题仍然存在。我不想向此用户提供admin
权限。我该怎么办。
答案 0 :(得分:1)
用户应具有clusterManager
角色:https://docs.mongodb.com/manual/reference/built-in-roles/#clusterManager