0

I'm trying to convert a standalone MongoDB database into a cluster in order to migrate my database to MongoDB Atlas.

I've followed the following steps to try and convert it:

  1. Stop my mongodb instance
  2. Changed the configuration to the following content:
........................

#how the process runs

processManagement:   
     timeZoneInfo: /usr/share/zoneinfo

security:
   authorization: enabled

replication:  
  replSetName: "rs0"
  1. Restarted mongodb with the following command: sudo mongod --config /etc/mongod.conf --fork
  2. Logged into mongodb, to the admin database, with a user who has the following roles: clusterMonitor, readAnyDatabase, userAdminAnyDatabase
  3. Executed the command rs.initiate()

And it gave me the following error:

{
        “ok” : 0,
        “errmsg” : “not authorized on admin to execute command { replSetInitiate: undefined, $db: \“admin\” }“,
        “code” : 13,
        “codeName” : “Unauthorized”
}

I have tried the previous steps in a dev server, and everything worked fine, bun in my production environment it didn't work, any help is appreciated.

1

Logged into mongodb, to the admin database, with a user who has the following roles: clusterMonitor, readAnyDatabase, userAdminAnyDatabase

...

not authorized on admin to execute command { replSetInitiate: undefined, $db: \“admin\” }“

This error is expected since clusterMonitor is a read-only role.

To initialise or update replica set configurations when access control is enabled your user needs a cluster management role like clusterManager or clusterAdmin.

  • I will try this tonight and if it works, I'll buy you a beer. – Victor Castillo Torres Nov 22 at 22:15
  • it worked as expected, please send me your Paypal, I'm gonna buy you a beer. – Victor Castillo Torres Nov 27 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.