Questions tagged [mongodb]

All versions of MongoDB - a scalable, high-performance, open source, document-oriented database.

Filter by
Sorted by
Tagged with
1
vote
1answer
230 views

MongoDB Shard distribution issue

I am facing an issue in the shard distribution. MongoDB Version: 3.0.15 I have a collection that is sharded. I have two shards. Output of db.getCollection('event').stats() { "sharded" : true, "...
1
vote
1answer
3k views

MongoDB merge two collections and drop documents with same value in field

In my database I have two collections, but some documents were added (possibly) at different times to both collections. I could use mongodump and then mongorestore for merging. But then I have the ...
-1
votes
0answers
7 views

connection string for mongodb from perl script

Connection string for mongodb having 3 node replica set from perl script with ssl true and sslAllowInvalidCertificates Can someone share connection string if you are using it ?
0
votes
1answer
116 views

Why does a query on a sparse index perform much faster than a query on a partial index in MongoDB?

I created a sparse index in my MongoDB Atlas like so: db.detection_events.createIndex({"emp_id": 1}, {sparse: true}) When I performed this operation: db.detection_events.count({"emp_id": {$exists: ...
3
votes
2answers
994 views

How to promote hidden mongo node to primary?

We are trying to implement DR setup for our mongodb replica set and currently three nodes in DR are configured to run as hidden nodes. We are trying to test failover to DR which will require promoting ...
-1
votes
0answers
217 views

MongoDB MongoError: Out of memory

I have a newly installed MongoDB server running on an AWS Ubuntu EC2. The server has nothing else installed on it. The DB currently contains 35 documents of 3 MB each, meaning less than 110 MB of data....
1
vote
1answer
318 views

Why findOne() hangs on a sharded collection?

A MongoDB v3.6.4 database with a large sharded collection and WiredTiger engine hangs when issuing a findOne() or find() command without any parameters. The collection has only the default index on ...
0
votes
1answer
17 views

How do I restore a database using MongoDB 5.0 CLI?

I've just installed the MongoDB version 5.0 CLI tools on my workstation. But now when I go to restore a database like I've always done I get an error: mongorestore mongorestore : The term '...
1
vote
1answer
138 views

create mongodb user to only read in replica set (not in master)

We have a Mongodb with ReplicaSet and a readonly user. This user can read from both Master and Replica Set. Some of the developers might accidentally run heavy queries from Master with this readonly ...
0
votes
1answer
107 views

The reading with secondaryPreferred when chunk migration occurred often fail

We have some problems regarding balancer configuration. Our application which is set up with secondaryPreferred often fails to read documents from the secondary when balancer( chunk migration ) is ...
1
vote
1answer
484 views

mongodump: fact.bson: input/output error

We are trying to export 1.5TB database into mongodb. But its fail after 100gb and giving us below error. As we notice root mount point got 100% space. We are using below command: mongodump -u admin -...
0
votes
1answer
174 views

using mongorestore for a db present in my computer

I just started using mongodb so my question might be a little basic. I have a folder with the collections I want to restore(this was a zip file I downloaded from my email). How do I use mongorestore ...
0
votes
0answers
24 views

How to convert array objects with object ids as one of key value pair to string?

I have the following JSON, How to convert an array of objects with object ids to string in MongoDB using aggregation query? { "_id": ObjectId("60e41eb7335412757cc6cb9a"), "...
0
votes
0answers
12 views

How can i convert all object Ids to string using query in MongoDB, note the structure is complex, So can't use $toString in $addFields and $project?

I have a really deep-nested JSON object generated by aggregation query, but I want to convert all the object ids to string format. Tried $toString in $addFields and $project. Since the object is ...
0
votes
0answers
18 views

mongodb connections from secondary node reaching max connections allowed

I've noticed connections count from 2 of the secondary nodes in a 3 node replica set reaching max connections allowed on primary and hence mongodb instance not responding for any queries and becomes ...
0
votes
1answer
150 views

MongoDB is not using the index I created for this specific query

MongoDB 4.0. I have a simple query: db.product.find({ modifiedOn: { $gte: ISODate("2019-08-02T03:00:00.000Z") } }) .limit(10) And a simple index on modifiedOn....
0
votes
1answer
27 views

Obtain user and host who inserted data MongoDB

I am facing a problem with some data in my current database. There is a collection which is being populated and update through a NodeJS application. This collection possess a children which is an ...
0
votes
1answer
213 views

Mongostat display size / res

I would like to have your opinion and of course an explanation on the following. My configuration : mongodb version 3.4.4 1 replicaset with three identical servers( 4 cpu / 32 Go RAM under linux ...
0
votes
1answer
27 views

mongodb - chained replication related questions

In case of default replication which is chained replication in mongodb. Say for example in a 3 NODE replica set : NODE1 is primary and NODE2 is immediate next to NODE1 and catches up all oplog to ...
0
votes
2answers
110 views

MongoDB covered query needs to fetch and examine documents when exists operator is used

I need to execute following query on mongo db: db.testCollection.find({ dataType: { $exists: true } }, { _id: 0, date: 1 }) .sort({ date: -1 }) .limit(1) so basically only I need to do is to ...
0
votes
1answer
732 views

Is it possible to retrieve a history of the remote connections to the MongoDB including the IP addresses and the executed commands?

For some reasons I disabled the user access control and somehow all collections have been wiped out. So I want an activity log to find out how this happened I need a list like this: | Date/Time ...
0
votes
1answer
9k views

Can't solve MongoParseError: Invalid connection string

I'm not able to solve MongoParseError. First my I tried this mongoose.connect(`mongodb://${process.env.DB_USER}:${process.env.DB_PASSWORD}@db:27017/${process.env.DB_NAME}`, {useNewUrlParser: true}); ...
0
votes
1answer
31 views

mongodb query or JS to print health state of a replica node

If I've to get something like analogous to SQL statement from rs.status output to print specific value of an attribute in mongoDB - Something like print health of specific node of a replica set from ...
8
votes
2answers
3k views

verify that mongos server is connected to config servers

I've been writing a backup script for sharded replica-sets and it's almost done. Except I can't seem to get it to successfully start the balancer backup after everything's all said and done. Here's ...
0
votes
1answer
486 views

Mongo: how to covert a string to decimal?

I have written millions of documents with $CURRENT_CASH_BALANCE as strings instead of decimals. How can I convert them all to decimals?
0
votes
0answers
14 views

How to interpret results of mongo explain and improve geo spatial query?

I have a collection in MongoDB where the documents have a structure like this: { "vechicleDetails": { "location": { "type": "Point", ...
0
votes
1answer
38 views

Update priorities on mongo based on host name using JS

Is there a way to adjust priorities of the nodes based on hostname instead of sequence. Using sequence - cfg=rs.conf() cfg.members[0].priority=100 cfg.members[1].priority=10 cfg.members[2].priority=...
0
votes
1answer
2k views

Change in bind_ip value is not reflecting

I have mongo installed on Centos instance in AWS and I am connecting to the mongoDB server from my system. To connect from remote system we need to change bind_ip value to 0.0.0.0 in /etc/mongod.conf ...
1
vote
2answers
423 views

RHEL 7.4, heavy workload(s) and SWAP usage

This might not be the correct board for this, but since I'm a DBA and I'll ask here. I have several RHEL 7.4 servers, running a mix of MariaDB (10.1, 10.2) and MongoDB (3.4). The problem was ...
0
votes
1answer
117 views

MongoDB Aggregate Poor Index Usage

I've been trying to understand the MongoDB Aggregate process so I can better optimize my queries and I'm confused by usage and $match and $sort together. Sample DB has only one collection people [{ ...
0
votes
1answer
102 views

How do I import the _id index from a MongoDB collection as a hash index for a PostgreSQL table (from a CSV export from MongoDB)?

I want to be able to keep track of the _id index values that get the MongoDB collection uses when I export the MongoDB collection (via CSV) and import the data into a PostgreSQL DB table (basically ...
1
vote
0answers
24 views

Stroring field name instead of referencing using objectId [duplicate]

This is my first question here For example: I have a post document which contains list of people who like it and my question is Should i store each person in the array using objectId or username(it's ...
1
vote
1answer
50 views

Shell Script to kill slow running Mongo Queries

I need to create a shell script that finds and kills long running mongo queries more than a specified threshold e.g. 15sec I plan to use db.currentOp(); and db.killOp(); to find and kill queries but I ...
5
votes
3answers
8k views

Creating mongodb database with ansible playbook

How i can create MongoDB database with Ansible? is it possible? If not, can i do this with bash script? I tried to use mongodb_user module for Ansible, but it cant work without existing table.
2
votes
1answer
891 views

Mongodb replica set primary and secondary node conf fail when one slave is down

In my env, I had created MongoDB replica set conf for high availability so one server fails should be handled by other also in my conf I have 3 DB server and 1 arbiter too but, my slave's server ...
0
votes
1answer
672 views

Expand a date range in mongodb

I have a document structure like { "startDate": ISODate("2015-01-01T00:00:00Z"), "endDate" : ISODate("2015-01-10T00:00:00Z"), "foo" : "bar" } Is it possible to expand the date range like this?...
0
votes
1answer
239 views

MongoDB cannot be started after moving the server

I had a happy MongoDB 3.0.5 installed on a VM on a Windows 2012R2 Server, for light use. I moved the VM to a new physical server without any major changes, and to my surprise it cannot be started; and ...
1
vote
1answer
149 views

MongoDB + Compass exporting strings and numbers “columns” with value of 1 as “true”(boolean) and 2 or null as “false” to CSV

When I export my MongoDB collection to a CSV, the String and Number "column" data types values are converted to "true" for 1 and "false" for 2 and null - how do I retain ...
0
votes
1answer
663 views

Mongodb - Error after turning fork mode on

I am working on installing mongodb on remote server I managed to install everything and tested it. But when I tried to enable fork mode to make it run in the background via the command mongod --...
8
votes
5answers
33k views

MongoDB — Failed global initialization: Failed to open “/var/log/mongodb/mongod-config.log”

I'm trying to setup the config servers for mongodb sharding. I created a specific config file that is set to log to /var/log/mongodb/mongod-config.log. When I run mongod --config <path-to-config-...
2
votes
1answer
193 views

lat, long based search with $near shutdown my mongodb on Linux server

Hey guys i am stuck on critical problem & unable to resolve it. I have a project where there is a collection of UK postcodes having 18,00,000 sample postcode records. I have a search query where i ...
1
vote
1answer
240 views

Sharded Mongodb stalls randomly

I have setup Sharded MongoDB cluster using hashed sharding in kuberenetes.I first created the config server Replicaset and then created 2 shard replicasets. Finally created mongos to connect to the ...
0
votes
1answer
15 views

Mongo - How to update a property of a document using a nested value of the same document

I want to update a document using a nested value from that same document. So if I have an document that looks like this: { _id: ObjectId("60b002d490b01b63eee5d4b7"), title: 'foo', ...
1
vote
1answer
254 views

Reset mongo cache memory for test perfomance - windows

recently i'm working on mongo db and I'm trying to check the performance of mongodb with 2 million record. I need to clear cache every time I start the test. I don't want to restart the computer/...
2
votes
1answer
621 views

MongoDB sharding by monotonic id with zones for archiving

Situation: I have an ever-growing collection of documents which do have monotonically increasing unique id. All queries are direct lookup for documents with specified _id (no range queries nor ...
2
votes
2answers
15k views

Our replica set config is invalid or we are not a member of it - MongoDB

I have started the mongodb server with replica set name 'rs01' enabled on port 27001. Then started another command window to start the mongo db on the same port. The status says the 'rs0' is not a ...
0
votes
2answers
220 views

for mongo, not able to create users other than admin with error command createUser requires authentication :

This is the script I am using to create user accounts in MongoDB: mongo <<EOF use admin; db.createUser({user:ram", pwd: "ram123!", roles:['root']}); db.createUser({user:"sam&...
0
votes
1answer
15 views

Error on adding an arbiter

Adding 5th node getting an error "Our replica set configuration is invalid or does not include us Presently all 4 nodes are healthy. node arb1 arb2 rs1 m1,m2,m2 a1 when I try to add a2 both ...
0
votes
1answer
32 views

Relational or non-relational when dealing with highly relational, big data [closed]

I'm working on a project (in Java) that will be processing a large event stream (GBs every minute). This data is heavily processed to find relationships between events. This is done through a ...
0
votes
1answer
111 views

Mongo Database - Dirty Shutdown

We have a major issues on our MongoDB and I've attached the latest logs and files. In previous forumns I've seen this get fixed by your team. Can you please help as soon as possible please, we are a ...

1
2 3 4 5
45