13

You've configured this node as a replica set member: replication: replSetName: "rs0" On startup a new MongoDB server does not have a replica set configuration yet. The server will be in an unknown replica set member state until you either add this member to an existing replica set configuration or use rs.initiate() to establish it as the first member ...


5

I have successfully upgraded a database from 2.4 to 4.0 using the following 3 step method: use 2.4 mongobackup on the 2.4 database delete all .json files from the outputted dump directory use 4.0 mongorestore on the remaining .bson files


4

You might want to consider opening an issue on MongoDB's Issue Tracker and providing the *.mdmp file in the issue. *.mdmp files are considered to be Microsoft Dump Files. Compressed file created by Windows after a program error or crash; contains data "dumped" from the program's memory space; saves information about the error, which can be used for ...


3

The solution is to use NumberInt instead of parseInt. var coll = db.getCollection('info'); var bulk = coll.initializeOrderedBulkOp(); var counter = 0; coll.find({ width_px: { $type: "string" }}).forEach(function(data) { var updoc = { "$set": {} }; updoc["$set"]["width_px"] = NumberInt(data.width_px); // queue the update bulk.find(...


3

First you download the Current Stable Release (3.6.0) from Windows Server 2008 R2 64-bit and later, with SSL support x64 with (msi) file Once you shall open the https://www.mongodb.com/download-center#community , directly it will open to first tab . which is in MongoDB download center, But you have to click on the Community Server and download (.msi) files....


3

I look like that you haven't enabled authentication (--auth) at the database. Without authentication, there is no authorization. That's why all users can do now whatever they want.


3

You can use the $jsonSchema query operator to find relevant documents. For example, using the mongo shell: // Retrieve the current validator for the "students" collection var schema = db.getCollectionInfos({ name: "students" })[0].options.validator // Find any documents not matching the schema db.students.find({ $nor: [schema] }) ...


3

I've discovered MongoShake (https://github.com/alibaba/MongoShake) which is an open source Golang application which does cluster to cluster replication and has been made by Alibaba. The documentation is focused on its internal work/behaviour, and can be discouraging but you have to look at the example configuration file instead which describe each ...


3

After an unexpected crash, I can't restart ... the mongodb database Time to exercise your Recovery Strategy, put your Recovery Plan into operation and get your database back from the Backups you've taken of it. Your database is actually remarkably resilient. Left to its own devices (and all other things being equal) it will recover from a server crash all ...


3

Just putting this here since I was struggling with the same for a while: Here is how you can do it in python3 Tested on mongo version 4.0 and pymongo version 3.11.4 import pymongo client = pymongo.MongoClient("mongodb://mongodb0.example.com:27017") admin_db = client.get_database("admin") milliseconds_running = 10000 query = [ {&...


2

I wanted to know, how can I add a reference to another collection? Relationships in MongoDB represent how various documents are logically related to each other. Relationships can be modeled via Embedded and Referenced approaches. Such relationships can be either 1:1, 1:N, N:1 or N:N. It's possible through Modeling Referenced Relationships and DBRefs. Here ...


2

As you said you are trying to import a MongoDB database, And you are using the MongoDB command such as mongorestore. And also as you said you have taken mongodump backup of MongoDB database , which MongoDB version is 2.4 & you are going to import that mongodump backup in MongoDB , which version is 3.6. As I would like to say here as per MongoDB BOL ...


2

As I am able to see you are getting the insert writeError with Error code : 121 like that "nInserted" : 0, "writeError" : { "code" : 121, "errmsg" : "Document failed validation" As per MongoDB blog documentation of @Jai Hirsch here for MongoDB document validation. Sometimes you want completely free form documents and sometimes you don’...


2

I am running the below command: sudo mongod --storageEngine wiredTiger --dbpath /data --bind_ip_all --logpath /var/log/mongodb/mongod.log --fork and everything will work just fine. Except, binding all is not secure enough. As per MongoDB BOL here there is Warning: Before you bind to other ip addresses, consider enabling access control and ...


2

This is a known issue recently discovered in the MongoDB 3.6.3 release when using WiredTiger on Windows: SERVER-33982: Unbounded growth of pre-allocated log files. This issue will be corrected in the 3.6.4 production release, so upgrading to MongoDB 3.6.4 (or newer) when available should resolve the issue. In the interim, possible workarounds are: Disable ...


2

Problem here is your replSetName: parameters. BOTH config servers must be at same replica set, f.ex. conf and then those shards (data nodes) both should have different replica set names. f.ex. rs0 and rs1. Now your config1 is rs0 and config2 is rs1.


2

Introduction The oplog has nothing very little to do with memory consumption. It is a capped collection used as sort of a write-ahead log for operations to be replicated to other replica set members. In general, MongoDB uses up to around 85% (give and take) of memory unless told otherwise. This memory is used to keep the indices and the "working set" (...


2

I have created mongouser as testuser with below roles. I want to give access for new databases for this user. what roles the user to grant access to all databases. db.createUser({ user: "testuser" , pwd: "testuser", roles: ["dbAdminAnyDatabase", "readWriteAnyDatabase", "enableSharding"]}); As per MongoDB documentation here MongoDB grants access ...


2

Since you are using a hosted database service (MongoDB Atlas), many administrative commands are limited as they are either provided via the management interface or likely to introduce performance/stability issues. The Atlas free tier has additional limitations since it is backed by a shared MongoDB instance. See: Unsupported Commands in M0/M2/M5 Clusters. ...


2

Please use the below query to create the unique partial index. The reason why your query work is, there may many fields with the value like {rss_id: null} db.getCollection('noticias').createIndex( { rss_id: 1}, { unique:true, partialFilterExpression: {rss_id: {$ne:null}}} ) Or you can use sparse index option along with unique index as shown below db....


2

Is such conversion considered a safe operation? Converting a standalone node to a replica set is a straightforward procedure, but if you do not have a backup of your deployment (and this data is important) I would definitely prioritise creating and testing a backup. If you only have a single copy of your data (the one being used!) you will have very limited ...


2

According to the following comparison chart, MongoDB Atlas and Amazon DocumentDB are not fully compatible: +====================================+=======================================================================================+==================+ | Item | DocuemntDB ...


2

When upgrading any software it's usually a good idea to check the manual first, and read something like this: To upgrade an existing MongoDB deployment to 3.6, you must be running a 3.4-series release. To upgrade from a version earlier than the 3.4-series, you must successively upgrade major releases until you have upgraded to 3.4-series. For example, if ...


1

So I found solution, --drop shoud be added in the command: mongodump -h $HOST:$PORT --ssl --sslAllowInvalidCertificates --authenticationDatabase $authdb -u $user -p $pass --drop --gzip --archive=$destination


1

Consider using Percona tool if you are using MongoDB version above 3.6. Taking dump of individual shards and trying to stitch it together while restoring is not advisable.


1

Any ideas how to avoid warning? This warning was added for some older implementations of MongoDB's WiredTiger storage engine, but is longer relevant in MongoDB 3.6. The warning has been removed in MongoDB 4.0 and the removal has been backported for the upcoming MongoDB 3.6.6 server release. See SERVER-33706 for more background. You can ignore this warning ...


1

If you're using the WiredTiger storage engine, data in the database is compressed (using snappy by default). In contrast, mongodump output is not compressed. This is why 2TB may not be enough to backup a 1.5TB database. To determine the uncompressed size of your database, you can run db.stats().dataSize in the mongo shell (see manual). To determine the ...


1

As per MongoDB blog documentation from Asya Kamsky here CPU load is almost never the bottleneck/limiting resource for MongoDB (or databases in general). Unless you are running a large number of MapReduce jobs and/or aggregation framework queries, high CPU utilization tends to indicate that you have poorly tuned queries possibly with in-memory sorts (as ...


1

You can try a configuration like the one below; server: ssl: key-store: classpath:keystore.jks key-store-password: secret key-password: another-secret data: mongodb: authentication-database: admin database: <database> host: <host> password: <password> port: <port&...


1

I created role with your db.createRole(..., I didn't "need" to use your grantPrivilegesToRole command. Then I created user db.createUser({"user":"test2",pwd:"password",roles:["master"]}) and changes to it with db.auth("test2","password") If I change to database test, command db.lock.insert({}) fails, as it should be, but if I change database to ...


Only top voted, non community-wiki answers of a minimum length are eligible