I’m trying to set up backups on a replica set using mongodump
, authenticating with a user that has the root
role, but I’m getting an error that suggests my root user doesn’t have permission to access the config
database:
root@mongo-db1:/srv/mongo# mongodump --username=rcroot --password="secret" --out=/var/backups/20200925
2020-09-26T05:40:20.138+0000 Failed: error counting config.system.indexBuilds: not authorized on config to execute command { count: "system.indexBuilds", query: {}, $readPreference: { mode: "secondaryPreferred" }, $db: "config" }
If I log in to the mongo
shell with that user, I find that indeed I cannot run the db.system.indexBuilds.count()
command in config
; I get an error indicating I’m not authorized. However, the user appears to have the root
role:
rs0:PRIMARY> db.getUser("rcroot")
{
"_id" : "admin.rcroot",
"userId" : UUID("81fc86ff-6d12-4d23-83ab-7fc2591516a2"),
"user" : "rcroot",
"db" : "admin",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
},
{
"role" : "root",
"db" : "admin"
}
],
"mechanisms" : [
"SCRAM-SHA-1",
"SCRAM-SHA-256"
]
}
This is mongod version 4.4, and my replica set is configured to use keyfile auth (in case that matters):
mongod --auth --replSet rs0 --keyFile /data/db/keyfile --enableMajorityReadConcern false
I’ve tried creating an entirely new user with the root
role, but I get the same results.
I’m new to MongoDB, so I’m probably missing something silly…I’d appreciate any clues as to what it is!