Sample Header Ad - 728x90

Database Administrators

Q&A for database professionals who wish to improve their database skills

Latest Questions

1 votes
1 answers
204 views
How do you create an atlas user in a non-admin db?
There doesn't seem to be an option in mongo atlas UI to create a user in any database other than admin.
There doesn't seem to be an option in mongo atlas UI to create a user in any database other than admin.
Sudh33ra (111 rep)
Oct 5, 2022, 06:27 AM • Last activity: Jun 16, 2025, 04:01 PM
0 votes
0 answers
28 views
Mongorestore DocumentValidationFailure Error while restoring oplog
I am trying to restore my oplogs from one database to another using mongodump & mongorestore utility. During dump I have faced no issue and overall dump was extracted but while restoring that dump I was facing follwing issue. I have attached all information along with this Topic. **Error:** > Failed...
I am trying to restore my oplogs from one database to another using mongodump & mongorestore utility. During dump I have faced no issue and overall dump was extracted but while restoring that dump I was facing follwing issue. I have attached all information along with this Topic. **Error:** > Failed: restore error: error applying oplog: applyOps: > (DocumentValidationFailure) Document failed validation **Mongodump command:** > nohup mongodump --uri="source-db-connection-uri/local" --collection=oplog.rs --out=/path/to/mongdump-folder/oplog/oplog-04-03-2025 --query '{"ts": {"$gte": {"$timestamp": {"t": 1741190170, "i": 5953}}, "$lt": {"$timestamp": {"t": 1741234631, "i": 2452}}}}' --gzip &> /path/to/mongdump-folder/oplog/logs/oplog-04-03-2025.log **Mongorestore command:** > mongorestore --gzip --uri "target-db-connection-uri/?authSource=admin" --oplogReplay --dir /path/to/mongdump-folder/oplog/oplog-04-03-2025 **Source-DB Information**: MongoDB Atlas with mongod 7 installed **Target-DB Information**: MongoDB Community Edition with mongod 8 installed Neither of my databases have any kind of validations setting on Please review the details and let me know if any additional information is needed. ***Note**:* I have also tried this with MongoDB 7 Community Edition but facing same issue.
Mehul Sanghvi (1 rep)
Mar 12, 2025, 06:43 AM • Last activity: Mar 12, 2025, 06:44 AM
6 votes
1 answers
14935 views
"Replication Oplog Window has gone below 1 hours"
I'm working with MongoDB Atlas and I have a 3 node M30 cluster with 100GB of storage. My current use case is the following: - A user dispatches one search in my platform - The platform dispatches this search to other providers (12) - I get like 2k documents per provider for this search I want to mak...
I'm working with MongoDB Atlas and I have a 3 node M30 cluster with 100GB of storage. My current use case is the following: - A user dispatches one search in my platform - The platform dispatches this search to other providers (12) - I get like 2k documents per provider for this search I want to make sure I understand the "Replication Oplog Window has gone below 1 hours" alert I'm seeing. If I've got this correct, the OpLog Window is how long the master node can continue receiving data before the slave nodes get out of sync. How can I tune the setting for the size of the OpLog Window?
Tzn (103 rep)
May 19, 2020, 10:35 AM • Last activity: Jan 24, 2025, 05:09 PM
1 votes
2 answers
2554 views
how to run mongo export on macbook?
I am using mongodb Atlas (M0), which does not provide db backup feature. I am creating a nodejs script that will export all the collections automatically periodically. So far I have done the following: - created a programmatic api from my login. - whitelisted my ip - installed mongocli - created a d...
I am using mongodb Atlas (M0), which does not provide db backup feature. I am creating a nodejs script that will export all the collections automatically periodically. So far I have done the following: - created a programmatic api from my login. - whitelisted my ip - installed mongocli - created a default profile using public and private api keys. And command looks like this: mongoexport --uri mongodb+srv://${mongoUser}:${mongoPass}@mongoprojectname.lok0l.mongodb.net/${database} --collection ${collection} --type ${fileType} --out ${fileName} --profile default I am not able to figure out how to run this command. If I run this command in my terminal I get this error: /bin/sh: mongoexport: command not found\n
Jasmohan Singh (21 rep)
Feb 22, 2021, 08:16 AM • Last activity: Jan 22, 2025, 08:00 AM
0 votes
1 answers
2218 views
How to do a mongo restore with Atlas URI
I am trying to do a `mongorestore` of a few collections . I am trying to use the Atlas URI to do this and it throws an error saying that positional arguments not allowed: [mongodb+srv://hostname.mongodb.net] When I try to connect with a `mongo` client it works fine. However not the `mongorestore` or...
I am trying to do a mongorestore of a few collections . I am trying to use the Atlas URI to do this and it throws an error saying that positional arguments not allowed: [mongodb+srv://hostname.mongodb.net] When I try to connect with a mongo client it works fine. However not the mongorestore or mongo import. In short mongorestore -d dbname --username foo --password bar "mongodb+srv://hostname.mongodb.net" /folderwithbsons/ doesn't work while the below works mongo -d dbname --username foo --password bar "mongodb+srv://hostname.mongodb.net"
Suresh C Nair (1 rep)
Dec 13, 2021, 06:15 PM • Last activity: Dec 29, 2024, 06:00 AM
0 votes
0 answers
29 views
How to read the fully replicated data using the atlas search aggregation pipeline?
I want to read the fully replicated data using the atlas search aggregation pipeline. But, Atlas search is not allowing me to read with concern "majority". Error Message: =============== ``` Command aggregate does not support { readConcern: { level: "majority", provenance: "clientSupplied" } } :: ca...
I want to read the fully replicated data using the atlas search aggregation pipeline. But, Atlas search is not allowing me to read with concern "majority". Error Message: ===============
Command aggregate does not support { readConcern: { level: "majority", provenance: "clientSupplied" } } :: caused by :: Aggregation stage $search cannot run with a readConcern other than 'local'. Current readConcern: majority'.
So, How can we ensure the consistency in the search result? I've read the documentation and understood that the $search stage is performed by the mongot service and it won't work with non-local read concern. I don't know why and how can MongoDB guarantee the consistency in search results. ![Response of the AI bot from the MongoDB documentation page](https://i.sstatic.net/WxHXA5Kw.png) ![enter image description here](https://i.sstatic.net/8rNiRMTK.png) - **Cluster tier** : Dedicated M10 - **Node Type** : electable - **cluster** : 3 node replicaSet - **Mongodb version** : 7.0.14 - **pymongo** : 4.10.1 - **writeConcern** : majority - **readConcern** : majority - **read preference** : secondary I have not enabled workload-isolation; So,mongot and mongod services are running in each nodes of the replicaSet cluster. I think i need a help to understand the atlas search setup. Thanks in advance.
KR32 (101 rep)
Oct 22, 2024, 05:16 PM • Last activity: Oct 22, 2024, 05:24 PM
0 votes
0 answers
11 views
how can i do this $find in RStudio for a collection of a database that is in the free MongoDB atlas cluster?
I created a shiny application on RStudio and to manage the database I linked them to mongodb compass. Co,,e I wanted to put my application on shinyapps, I found it wise to put the database on mongodb atls. And to link mongodb atlas to RStudio I put this in the code # Connection to the MongoDB databa...
I created a shiny application on RStudio and to manage the database I linked them to mongodb compass. Co,,e I wanted to put my application on shinyapps, I found it wise to put the database on mongodb atls. And to link mongodb atlas to RStudio I put this in the code # Connection to the MongoDB database mongo_db_user <- "wambejordan13" mongo_db_password <- "hPJdzfQA54fhkH6A" mongo_database <- "élection" mongo_collection <- "mycollection" mongo_clustername <- "cluster0.s4gje.mongodb.net" # the following is the connection string for an Atlas online MongoDB cluster url_path = sprintf("mongodb+srv://%s:%s@%s/admin", mongo_db_user, mongo_db_password, mongo_clustername) votants <- mongo(collection = "votant", url = url_path) candidats <- mongo(collection = "candidat", url = url_path, options = ssl_options(weak_cert_validation = TRUE)) electeurs <- mongo(collection = "électeur", url = url_path, options = ssl_options(weak_cert_validation = TRUE)) candidat_delegue <- mongo(collection = "candidatDélégué", url = url_path) electeurs23 <- mongo(collection = "électeurDélégué", url = url_path) But this error appears when I run the code Error in : (Unauthorized) not authorized on admin to execute command { find: "candidat", filter: { }, projection: { _id: 0 }, sort: { }, skip: 0, limit: 0, noCursorTimeout: false, $db: "admin", lsid: { id: {4 [123 30 43 183 43 234 79 157 153 244 216 50 3 40 204 106]} }, $clusterTime: { clusterTime: {1727183562 2}, signature: { hash: {0 [206 172 38 240 70 44 96 154 49 112 242 104 8 13 139 227 99 180 206 249]}, keyId: 7354479715932962816.000000 } } } I already had to modify the user privileges at the mongodb atlas level and I put readWrite but it did not change.
valere (1 rep)
Sep 26, 2024, 10:59 AM
0 votes
0 answers
32 views
migrate from Bitnami to Atlas
I have to migrate from **MongoDB packaged with Bitnami** (sharded helm chart with 0 shard) to **MongoDB Atlas** (replicaset or sharded cluster) Do you know if there is a way to do that ? Does that mean downtime application ? Is there a way to take advantage of the Live Migration functionality offere...
I have to migrate from **MongoDB packaged with Bitnami** (sharded helm chart with 0 shard) to **MongoDB Atlas** (replicaset or sharded cluster) Do you know if there is a way to do that ? Does that mean downtime application ? Is there a way to take advantage of the Live Migration functionality offered by Atlas ?
SoA (21 rep)
Aug 16, 2024, 01:54 PM
0 votes
2 answers
318 views
mongodb atlas use secondaries to reduce cpu usage
I have M80 atlas cluster(128GB RAM and 32vCPUs) with 3 replicasets. most of the time my system use around 10% of RAM and 10% of CPU, during high load CPU spikes more than 100% leading to autoscaling of cluster evthough i have all the required indexes(I added them based on atlas performance advisor)....
I have M80 atlas cluster(128GB RAM and 32vCPUs) with 3 replicasets. most of the time my system use around 10% of RAM and 10% of CPU, during high load CPU spikes more than 100% leading to autoscaling of cluster evthough i have all the required indexes(I added them based on atlas performance advisor). I’m trying to cut the cost, i noticed only primary's CPU is shooting up, so if i start reading from secondaries, can I reduce the CPU usage or 32 vCPUs are actually shared across 3 replicas and I wont see much diffrence? as per my understandin it would not make a different if writes are causing CPU spikes, but i see a correlation between CPU usage and read operations.
mahendra (101 rep)
Nov 5, 2023, 04:06 PM • Last activity: Jan 10, 2024, 12:56 PM
1 votes
0 answers
164 views
Alert set up for TLS/SSL certificate expiration
I am looking for help with setting up alert for MongoDB Atlas cluster. Recently we saw an issue where one of clusters running on Mongo Atlas had expiration on the certs and there was an outage for the same. Looking for help if there is a way to monitor/alert if the cert expiration is going to happen...
I am looking for help with setting up alert for MongoDB Atlas cluster. Recently we saw an issue where one of clusters running on Mongo Atlas had expiration on the certs and there was an outage for the same. Looking for help if there is a way to monitor/alert if the cert expiration is going to happen in X days. Looked into https://www.mongodb.com/docs/atlas/reference/alert-conditions/ , however could not find the relevant one. Any pointers will be of great help ,Thank you.
Amar (111 rep)
Apr 4, 2023, 04:30 AM
7 votes
2 answers
7298 views
How to add userAdmin user in Mongodb Atlas
How to add a user with [userAdmin](https://docs.mongodb.com/manual/reference/built-in-roles/#userAdmin) role in Atlas? The Cluster Security "Add New User" UI https://cloud.mongodb.com/v2/.....#clusters/security/users shows only limited set of built-in roles without any option to enter role name manu...
How to add a user with [userAdmin](https://docs.mongodb.com/manual/reference/built-in-roles/#userAdmin) role in Atlas? The Cluster Security "Add New User" UI https://cloud.mongodb.com/v2/.....#clusters/security/users shows only limited set of built-in roles without any option to enter role name manually: enter image description here So I am a bit stuck here - there are no options in the UI, and non of the existing roles allow to add users in a shell. **UPDATE:** To make it crystal clear I went To "Security" tab in MongoDB Atlas cluster, from there I clicked "Add a new User", clicked "Show advanced options" and got the screenshot above. **UPDATE 2:** None of the roles in the list have userAdmin privilege. The most "powerful" [atlasAdmin](https://docs.atlas.mongodb.com/security-add-mongodb-users/#atlas-user-privileges) covers only: - readWriteAnyDatabase - readAnyDatabase - enableSharding - dbAdminAnyDatabase - clusterMonitor and doesn't have enough privilege to execute db.createUser() command.
Alex Blex (240 rep)
Dec 6, 2017, 09:58 AM • Last activity: Mar 30, 2023, 02:25 PM
0 votes
1 answers
1440 views
MongoDB Atlas M0 (Free Tier) BI capabilities
I'm using MongoDB in my server and developed BI tool using cube-js & mongosqld, which worked when mongo was running locally, however after I moved to Atlas using M0 tier I could not connect to it anymore using mongosqld, this is the error I get: > unable to load MongoDB information: failed to create...
I'm using MongoDB in my server and developed BI tool using cube-js & mongosqld, which worked when mongo was running locally, however after I moved to Atlas using M0 tier I could not connect to it anymore using mongosqld, this is the error I get: > unable to load MongoDB information: failed to create admin session for loading server cluster information: unable to execute command: server selection error: server selection timeout Checking the documentation again I realized BI Connector is not supported in M0: https://docs.atlas.mongodb.com/bi-connection/#bi-connection So I guess this error is expected ? In that case, what other options I have to develop a visualisation tool while keep using M0 tier ? Of course the preferred way for me is to keep using cube-js app which I already developed. This is the documentation I used originally and it does mention limitation for free tier but doesn't say it's not supported at all so I'm confused what's the root cause for this error message and if it should work or not: https://docs.mongodb.com/bi-connector/v2.1/tutorial/connecting-to-atlas/ I also verified I CAN connect using mongo: mongo mongodb+srv://:@/ however when I try the same uri in mongosqld: mongosqld --mongo-ssl --sslMode allowSSL --auth --sslPEMKeyFile test.pem --schema .drdl --mongo-uri mongodb+srv://:@/ I get the following error: > when authentication is enabled, admin credentials must be provided with --mongo-username and --mongo-password or in a config file at 'mongodb.net.auth' I then tried to connect using the following command: mongosqld --mongo-ssl --sslMode allowSSL --auth --sslPEMKeyFile test.pem --schema .drdl --mongo-uri mongodb+srv:/// --mongo-username --mongo-password and got this error: > error parsing uri: authsource without username is invalid then I tried without "srv": mongosqld --mongo-ssl --sslMode allowSSL --auth --sslPEMKeyFile test.pem --schema .drdl --mongo-uri mongodb:/// --mongo-username --mongo-password and got the error mentioned originally - "failed to create admin session"
Tamir (101 rep)
Dec 11, 2019, 09:04 AM • Last activity: Apr 6, 2022, 06:16 AM
18 votes
3 answers
29053 views
How to restore .wt backup file to local MongoDB?
This is a question that was asked before, but I have tried all solutions, and simply cannot get it right. I have spent quite some time researching before posting this question. I have looked at the official MongoDB documents and many other blogs. How to restore a .wt MongoDB backup file to a local M...
This is a question that was asked before, but I have tried all solutions, and simply cannot get it right. I have spent quite some time researching before posting this question. I have looked at the official MongoDB documents and many other blogs. How to restore a .wt MongoDB backup file to a local MongoDB database?
Saketh (323 rep)
Apr 20, 2018, 12:41 AM • Last activity: Mar 4, 2021, 05:42 AM
2 votes
0 answers
207 views
MongoDB - 100% CPU - recovering shard (after killing updates)
Can a recovering shard (as shown below) drive CPU to 100% for hours and hours? I have killed all the queries and updates (based on db.currentOp()) and stopped the flow of new data, but the CPU stays at 100%. I can run little queries, but deleting 200 rows (via an index) runs for hours. Inserts are g...
Can a recovering shard (as shown below) drive CPU to 100% for hours and hours? I have killed all the queries and updates (based on db.currentOp()) and stopped the flow of new data, but the CPU stays at 100%. I can run little queries, but deleting 200 rows (via an index) runs for hours. Inserts are getting backed up and not performing timely. We have a large collection (almost 200 GB) with about 5 indexes. Can the server be doing internal clean-up that runs the CPU so high that our normal flow of data bogs down? enter image description here (running cloud/Atlas) In the db.currentOps(), I see quite a few that look like the json below; these don't seem to represent any queries, inserts, updates, or deletes that we are running or started. { "type": "op", "host": "atlas-10ydpn-shard-00-04.otwxp.mongodb.net:27017", "desc": "conn1280774", "connectionId": 1280774, "client": "54.221.39.10:59692", "clientMetadata": { "driver": { "name": "PyMongo", "version": "3.11.0" }, "os": { "type": "Linux", "name": "Linux", "architecture": "x86_64", "version": "4.14.193-110.317.amzn2.x86_64" }, "platform": "CPython 3.7.9.final.0" }, "active": true, "currentOpTime": "2020-10-22T12:52:12.100+0000", "effectiveUsers": [ { "user": "pythonapp", "db": "admin" } ], "opid": 20478470, "lsid": { "id": "059e860217054269a3f30c93a7b9c9cb", "uid": null }, "secs_running": 2370, "microsecs_running": 2370403369, "op": "command", "ns": "relatixtd.$cmd", "command": { "update": "ProdPolygonIOQuotes", "ordered": true, "writeConcern": { "w": "majority" }, "lsid": { "id": "059e860217054269a3f30c93a7b9c9cb" }, "txnNumber": 1, "$clusterTime": { "clusterTime": null, "signature": { "hash": null, "keyId": 6857244042040705026 } }, "$db": "relatixtd" }, "numYields": 1, "waitingForLatch": { "timestamp": null, "captureName": "ReplicationCoordinatorImpl::_mutex" }, "locks": {}, "waitingForLock": false, "lockStats": { "ParallelBatchWriterMode": { "acquireCount": { "r": 4 } }, "ReplicationStateTransition": { "acquireCount": { "w": 6 } }, "Global": { "acquireCount": { "r": 2, "w": 3 } }, "Database": { "acquireCount": { "r": 1, "w": 3 } }, "Collection": { "acquireCount": { "r": 1, "w": 3 } }, "Mutex": { "acquireCount": { "r": 4 } } }, "waitingForFlowControl": false, "flowControlStats": { "acquireCount": 2, "timeAcquiringMicros": 1 } },
NealWalters (577 rep)
Oct 22, 2020, 01:15 PM • Last activity: Oct 22, 2020, 01:30 PM
1 votes
0 answers
646 views
How to reclaim disk space on a MongoDB Atlas replica set?
I migrated a replica set from mLab to MongoDB Atlas. mLab offered an [automated process][1] to reclaim disk space after dropping large amounts of documents from a collection. Compacting (or resyncing) basically happened with the click of a button with a rolling node replacement process that does not...
I migrated a replica set from mLab to MongoDB Atlas. mLab offered an automated process to reclaim disk space after dropping large amounts of documents from a collection. Compacting (or resyncing) basically happened with the click of a button with a rolling node replacement process that does not require downtime. I didn't find such a process in the MongoDB Atlas UI. In the mongoDB docs the steps to "automatically sync a member" require deleting data manually from the shut-down secondary, and possibly other steps that seem quite delicate. What is the easiest way to reclaim disk space on MongoDB Atlas for a replica set with 1 primary and 2 secondaries?
Manuel (121 rep)
Feb 27, 2020, 12:33 AM • Last activity: Feb 27, 2020, 12:43 AM
1 votes
1 answers
1147 views
Mongo Atlas API - Get Databases and Collections in a Cluster
So with Mongo Atlas I can easily list clusters in a project by calling the API as follows: curl -i -u " : " --digest "https://cloud.mongodb.com/api/atlas/v1.0/groups/ /clusters" I want to list all database (and if possible all nested collections) for a particular cluster. Is this possible via the AP...
So with Mongo Atlas I can easily list clusters in a project by calling the API as follows: curl -i -u ":" --digest "https://cloud.mongodb.com/api/atlas/v1.0/groups//clusters " I want to list all database (and if possible all nested collections) for a particular cluster. Is this possible via the API - I am sure it must be but I am not seeing it in the documentation. I want to avoid having to connect to each cluster and collecting this information with a query - this is for a service discovery tool I am building for inventorying purposes. Thanks
Molenpad (1814 rep)
Dec 31, 2018, 01:40 PM • Last activity: Nov 29, 2019, 12:49 AM
0 votes
1 answers
381 views
Can't migrate standalone MongoDB to Cluster
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 proce...
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"
3. Restarted mongodb with the following command: sudo mongod --config /etc/mongod.conf --fork 4. Logged into mongodb, to the admin database, with a user who has the following roles: clusterMonitor, readAnyDatabase, userAdminAnyDatabase 5. 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.
Victor Castillo Torres (271 rep)
Nov 22, 2019, 09:04 PM • Last activity: Nov 22, 2019, 09:53 PM
2 votes
3 answers
18833 views
How can you view the IP addresses of active MongoDB Atlas connections?
[Some posts][1] show you can use db.currentOp(true) to show active connections, but when I do that I get this error `{ "ok" : 0, "errmsg" : "Using $all for currentOp is disallowed in this atlas tier", "code" : 8000, "codeName" : "AtlasError" }` Is there another way to view active connections to a Mo...
Some posts show you can use db.currentOp(true) to show active connections, but when I do that I get this error `{ "ok" : 0, "errmsg" : "Using $all for currentOp is disallowed in this atlas tier", "code" : 8000, "codeName" : "AtlasError" }` Is there another way to view active connections to a MongoDB Atlas Cluster? What tier allows you to use this command?
A_toaster (145 rep)
Mar 26, 2019, 11:32 PM • Last activity: Nov 12, 2019, 06:36 PM
1 votes
1 answers
270 views
Migrating from MongoDB Atlas to self managed Mongo (EC2) server
There is an abundance of info about migrating TO Atlas but not too much I could find specifically about going the other direction. I am migrating a collection which is 250GB in size. I have tried using mongodump from the remote EC2 server connecting to the Mongo Atlas instance however presumably due...
There is an abundance of info about migrating TO Atlas but not too much I could find specifically about going the other direction. I am migrating a collection which is 250GB in size. I have tried using mongodump from the remote EC2 server connecting to the Mongo Atlas instance however presumably due to the large collection size this keeps failing. I have also read that mongodump is not great for DBs of this size but I could be wrong. I was able to download a backup .tar.gz file from Atlas and move this to the the remove server. The file contents are below. Is it possible to restore these in to a fresh mongo setup on the EC2, or will these only work for the environment they were taken from? Here are the files available in the backup: enter image description here
ronnz (9 rep)
Oct 25, 2019, 03:32 AM • Last activity: Oct 25, 2019, 10:51 PM
1 votes
1 answers
293 views
How to monitor Mongo databases and Cloud servers?
We have mongo databases installed in AWS and Azure based servers. We need to monitor the Mongo databases and Cloud servers on daily basis. Is there any way to healthcheck the databases and servers ? Thanks,
We have mongo databases installed in AWS and Azure based servers. We need to monitor the Mongo databases and Cloud servers on daily basis. Is there any way to healthcheck the databases and servers ? Thanks,
Mr Surya (11 rep)
Mar 18, 2019, 09:49 AM • Last activity: Oct 9, 2019, 06:02 PM
Showing page 1 of 20 total questions