Create shard local user

Hey guys, i’ve been given a mongodb cluster to manage, currently implementing PBM for backup/restore strategy. It turns out that guys dont have the admin user for the mongod shard local instances, so, i’m trying to create the shard local user for pbm but i dont have the permissions and apparently someone created a admin user they dont have the username/password… I tried Localhost Exception but it’s not working…anyone been throught this?

It won’t work once the first user is created.

You’re going to need access to start and stop mongod on the host.
A change of primary is required during this process.

  1. Verify your replicaset is healthy to begin with. Without a local user you may have to db.hello() each node.
  2. Start with the current secondaries, one at a time.
  3. Stop mongod:
    sudo systemctl stop mongod
  4. Start mongod on a different port with no authentication(assuming mongodb defaults):
    sudo -u mongodb mongod --port 55555 --fork --syslog
  5. Connect and set password:
    mongo --port 55555 admin
    Or Create a new user:
  6. It is worth testing the credential at this point:
  7. Stop mongod
  8. Start mongod with it’s regular configuation
    sudo systemctl start mongod
  9. Do the next secondary until they are all done.
  10. Stop the current primary - this is now referred to as old primary.
  11. Connect to the replicaset and change the password.
    mongo --host replicasetName/hostname --port 27018 admin
  12. Start the old primary.
1 Like