Hi all,
I have a sharded clustes with authentication (keyfile + users to access to mongos). I've seen that mongostats can get information from all the nodes of the cluster with --discover option.
The user I am working with has readAnyDatabase and clusterAdmin permissions (maybe they could be reduced) and I am running mongostats in the mongos client like this:
mongostat --port mongos_port -u user -p --authenticationDatabase admin --discover
I can retrieve information from the client, but auth fails when trying to connect to the members of the replicasets (shards):
serverThread (node.:27017) fatal error : { code: 18, ok: 0.0, errmsg: "auth fails" }
Do I need to add the same user to the admin database of all the replica sets? If this is the case, which permissions should it have? Because, as far as I know, clusterAdmin is not directly related to shards (replica sets in my case).
I've tried creating a userAdminAnyDatabase in just one RS with
use admin
db.addUser( {user:"username", pwd: "password", roles: ["userAdminAnyDatabase"] } )
and after accessing mongod with
mongo --port 27017 -u username -p --authenticationDatabase admin
I could not read data from the system.users collection of the user’s database! I restored the admin database information (in fact, I removed the db files: .ns .0 and .1) and it is working again but I still have no access to the nodes with mongostats.
Thank you,
Antònia