I'm trying to perform a full backup of mongodb using the following command:
mongodump --uri="mongodb://mongo.database.svc:27017/?replicaSet=rs0" --oplog --out=/mnt/k8sMount/mongodb-dump/
Note: Here the uri
specified is a mongodb headless service in kubernetes.
But this command after few minutes results in error:
2021-10-08T02:55:19.021+0000 Failed: error counting admin.system.version: not master and slaveOk=false
I have gone through multiple forums regarding this error, but did not find relevant solution. Any suggestions would be helpful.
Note:
When i exec to the mongodb primary pod and run the command(here i dont specify the uri
parameter), it works fine without any issues.
Mongodb version: 4