Search code examples
mongodbreplicaset

Connection with the same user on multiple replicaset instance mongodb


I am new to mongodb and I am working on a sharded cluster.

I have a problem to connect to replica Set :

I have a user with readonly rights, exactly it is cluster monitor and read Any Database. This user have been created on a mongos instance.

When i try to connect to replicaset with this user, i cant authenticate myself and I get an error like im not register.

So my question is is this normal? Maybe the user are not connected and depend of the instance you are using.

If someone know the answer please tell me it, and sorry for my english, I am still a studient.

Thank you.


Solution

  • You can't connect directly to a shard replica set member mongod using an user created on mongos. To connect to a shard cluster mongod, you will need to create an user on that local mongod. This user should usually be created for admin purpose, so should have the admin right.

    Ref: Authentication on Sharded Clusters