我在服务器上部署了mongodb的分片群集。并通过提供keyFile启用身份验证。在启用身份验证之前,我已通过分配密码和角色添加了用户。之后,我通过应用密钥文件重新启动了所有集群。
但是当我的应用程序尝试使用admin数据库执行enableharding(使用mongodb c#driver)时,我收到错误消息: "Command 'enablesharding' failed: unauthorized (response: {"note":"not authorized for command: enablesharding on database admin","ok":0.0,"errmsg":"unauthorized"}) "
我给用户的角色是:"角色" :[" readWriteAnyDatabase"," userAdminAnyDatabase"," readAnyDatabase"," dbAdminAnyDatabase"," dbOwner",&#34 ; clusterAdmin"," clusterManager"," clusterMonitor"," hostManager"," backup"," restore" ]
你能否就此提出一些解决方案。
感谢。