1
votes

I just setup a 3 node MongdoDB cluster with replicasets and made a novice mistake. I setup the replica set etc first and then was being fancy and setup the default admin user as below:

show users { "_id" : ObjectId("blah"), "user" : "admin", "pwd" : "blah", "roles" : [ "userAdminAnyDatabase" ] }

This is fine for basic admin but I cannot do any replica set commands as the role is not cluster admin:

rs.status() { "ok" : 0, "errmsg" : "unauthorized" }

I tried a few things

  • adding a new user with a different set of roles but that did not work either.
  • tried to use the update role for admin role - that did not work

    db.users.update({'user':'admin'}, {$addToSet: {'roles' :'clusterAdmin'}}) not authorized for update on admin.users

Any other thoughts on this one - outside of redoing the setup for mongo?
1

1 Answers

1
votes

You'll need to add "clusterAdmin" role to your admin user, more doc can be found here