First Post here!!
I have a 3 members replica-set
.
Created a testDB
db in primary
. And create a user, TestUser
with role readWrite
on testDB
.
I can authenticate with this user in primary
and when run show dbs
, it show test + size, but I can’t authenticate with this user in secondary
members.
I have used rs.printSecondaryReplicationInfo()
in primary
. It’s showing both secondary
members are 0 seconds behind the primary
. From this, I know the replica-set
is working.
I have also deleted the whole /var/lib/mongodb dir and restarted mongod. It resynced successfully.
I’ve never developed an application that connects to mongodb. From my understanding, if primary fails, one of secondary becomes primary. But I don’t know how would the application access this testDB db, if I can’t authenticate with TestUser in secondary.
Do I need to grant this TestUser
some specific roles, other than readWrite
?
Or,can client application connect and access this test db with just readWrite
access. Some explanation or useful link of how client application use replica set would be really appreciated.