I have a MongoDB replica set of 3 servers (1 primary, 1 secondary, 1 arbiter; this is the default replica set created by Google Cloud 1-click install). The 2 config files (mongod.conf) of primary server and secondary server have been changed with security.authorization: enabled added.
Root user is added with the following MongoDB shell command:
use admin db.createUser({user:"root",pwd:"root",roles:["root"]}) After restarting MongoDB services on the primary and secondary servers with "sudo service mongod restart", connection to the replica set turns unstable.
rs.status() sometimes give the result as
- 1 primary, 1 unreachable, 1 arbiter
- 1 secondary, 1 secondary, 1 arbiter
- 1 secondary, 1 unreachable, 1 arbiter
How to setup basic password authentication (not using keyfile) for MongoDB replica set the correct way?
Error: couldn't add user: not authorized on admin to execute command. You can also find my question here stackoverflow.com/questions/41783700/… . It would be a lot much easier if you could tell me from which url(source) you have done this whole password authentication thing, please help me i have searched everywhere but didn't find anything ??