Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top