The Stack Overflow podcast is back! Listen to an interview with our new CEO.
59

Easiest way to find the storage engine being used currently. Inside mongo console type db.serverStatus().storageEngine It returns the storage engine being used currently { "name" : "wiredTiger" } Once it is confirmed that wiredTiger is being used then type db.serverStatus().wiredTiger to get all the configuration details of wiredTiger.


26

Personally, I prefer the mmapv1 storage engine as of now for three reasons. Reason 1: Maturity It isn't that WiredTiger is immature. But mmapv1 is well understood and battle tested all way up and down, back and forth and above and beyond. WiredTiger has had some serious issues (see http://jira.mongodb.com for details) fairly recently, and I am not willing ...


10

The error messages indicate the specific line and column where the YAML parser is having an issue with your configuration file, but if you're not familiar with the format it can be difficult to work out what is expected. Two sets of changes are required to make your config valid YAML: Add a "space" between the systemLog.path and storage.dbPath keys and ...


9

DISCLAIMER : Not a MongoDB Expert Check the process list in Linux WIREDTIGER_CONFIGURED=`ps -ef|grep mongod|grep -i storageengine|grep -ic wiredtiger` echo ${WIREDTIGER_CONFIGURED} 1 means it's there From the mongo shell db.serverStatus() You should see something like this "wiredTiger" : { ... "cache" : { "tracked dirty bytes in the cache" ...


6

From "BOSPROD9", try to connect with the mongoshell to the other serves: $ mongo --host 10.235.96.12 --port 27017 $ mongo --host 10.235.96.13 --port 27017 (Telnet is not the same.) If this doesn't work, it might be firewall or BindIP. Check bind_ip (should be 0.0.0.0, change in mongodb.conf is it's 127.0.0.1): $ netstat -nap | grep :27017 | grep LISTEN ...


6

To query two collections with related data the common approach (as at MongoDB 3.0) is to find a list of matching _id values from the first collection which can used with a $in query on the second. Here's an example using the mongo shell: // Find _ids for matching locations based on some criteria (eg. "abbrev") var matches = db.locations.find({ "abbrev": "...


5

found the solution by myself. use db.printCollectionStats() in the output you will find the mentioned algorithm in the "wiredTiger.creationString" section. "wiredTiger" : { "metadata" : { "formatVersion" : 1 }, "creationString" : "allocation_size=4KB,app_metadata=(formatVersion=1),block_allocation=...


5

From FAQ: MongoDB Storage: MongoDB preallocates its data files to avoid filesystem fragmentation, and because of this, the size of these files do not necessarily reflect the size of your data. The database sizes you are seeing when you execute show dbs reflect the sizes of corresponding data files on your hard drive. When you create a new database, a new ...


5

My two cents: Journaling in WiredTiger can lose updates in hard shutdowns because it uses in-memory buffering for storing the journal records. In between write operations, while the journal records remain in the WiredTiger buffers, updates can be lost following a hard shutdown of mongod. Journaling in MMAPv1 writes changes in on-disk journal files. ...


5

Typically, you don't. Thinking of your nodes in terms of primary or secondary is the wrong way to approach it. Since standard data bearing nodes should have the same dimensions, it is better to think of them as replica set members, one of which gets elected to primary. Since the drivers are replica set aware and know which the current primary is and you are ...


4

There are a number of system command equivalents available: ls() mkdir() hostname() pwd() sleep() (not a system command, but similar functionality) It should be noted that these are all executed on the client (local) machine, not the server. There is no general construct for executing arbitrary system commands that I know of in the shell. To be honest, I ...


4

MongoDB 2.6+ will consider index intersection in cases where multiple indexes might improve the query performance, however for sorting the index has to have keys in common with the query predicate. In your scenario, this means an index on {price:1} cannot be used for index intersection unless price is included in the query. So it scans through all the ...


4

We shifted to WiredTiger from MMAPv1 on the lure of 7x to 10x performance gain. We had to revert back to MMAPv1 as MongoDB would lock up when the WiredTiger cache would hit 100%. We've documented our experience here - https://blog.clevertap.com/sleepless-nights-with-mongodb-wiredtiger-and-our-return-to-mmapv1/


3

That error implies there is already data in TestDataBase.testCollections. You might consider using the --drop option: Before restoring the collections from the dumped backup, drops the collections from the target database. --drop does not drop collections that are not in the backup. When the restore includes the admin database, mongorestore with --...


3

MongoDB doesn't have an automatic backup feature built-in -- you have to choose an appropriate backup strategy using command-line or third party tools. The backup procedure will vary depending on your deployment type (standalone, replica set, sharded cluster), disk/dbpath configuration, and backup requirements. Unless you are using a third party tool, it'...


3

The rsync process will also apply a de-fragmentation for the MongoDB data files on the crashed primary replica. That's why you see the data file reduced in size on the primary after crashed. This effect is the same if you run the compact command on your secondary to reclaim the fragmented storage caused by data CRUD operations over time.


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.


2

To migrate data between different storage engines in MongoDB 3.0 you will need to perform an initial sync to the new replica set node or use mongorestore to seed a new replica set with your data. If you want to add a node with a new storage engine to a live production replica set, rs.add() is the correct approach. To ensure a smooth upgrade I would also ...


2

Your hostname must be an alias for 127.0.0.1 in your /etc/hosts file to make it work. aldwin@myhostname~$ cat /etc/hostname myhostname aldwin@myhostname:~$ hostname myhostname aldwin@myhostname:~$ cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 myhostname


2

Ok so a bit of egg on my face - I was overlooking the fact that my shiny new /etc/mongod.conf.yml contained processManagement.fork: true. Setting this to false allows start-stop-daemon to capture the appropriate PID.


2

On your indices Ok, first things first. Assuming some structure like this { _id: new ObjectId(), date: new ISODate(), message: "Hello, Multikey Indices!", tags: ["MongoDB","Indices","Multikey"] } indexing tags would result in a multikey index. For the document above, the index would have three entries: "MongoDB", "Indices" and "Multikey", all ...


2

MongoDB Ops Manager 3.4.0 (released November, 2016) includes monitoring for hardware metrics (cpu, disk usage, and I/O utilization) via the Automation agent. For more information, see: System and Disk Alerts. Prior versions of Ops Manager did not include hardware monitoring and required the use of an external tool (munin-node) for CPU & disk metrics. If ...


2

You created the user correctly, but you missed a parameter when connecting to mongod. By default, the authentication process assumes that the user is stored in the database you connect to, which in your case simply isn't true. You need to specify the autheticationDatabase option: mongo yourMongodIpAddress:27000/targetDb \ --authenticationDatabase admin -u ...


2

Yes. OPlog is kind of the same as MySQL binary logs as both are used to sync data to secondary and point in time recovery. You can use mongodump without --oplog option. You will only loose current writes in your backup. As you have a 10 hour window it wouldn't be an issue. In this scenario I recommend you to use one of your replica set with slaveDelay.


2

For minor versions its not an issue, although i would suggest to keep the same minor version across all nodes to avoid different behavior (due to different bugs and optimization patches between versions) after a stepdown. For major versions is fine when the primary is one major version behind the secondaries. Its not a good idea to have a primary on ...


2

RAM, mainly. Every connection gets a stack allocated, at the size of 1MB. The more connections you have, the more RAM is needed for them and the less RAM is available for keeping indices or the working set of data in RAM. So with your 19314 connections, roughly 19GB of RAM is used for connections. That's roughly a third of your available RAM – which is too ...


2

yaml do NOT accept tab, you must use space instead of tab systemLog: destination: file path: c:\data\log\mongod.log storage: dbPath: c:\data\db security: authorization: enabled net: bindIp: 127.0.0.1 port: 27017 above is my mongod.cfg file, for example between security: and authorization, must be space, tab is invalid will give you ...


2

As per my original question, my solution was as follows: My resolution I deleted the mongod.lock file in each member directory, boot up the members, and a connection was established and a vote took place. Thank you to Dmytro Shevchenko for assisting with clarification via his link, explaining that deleting the mongod.lock files are OK.


2

MongoDB can efficiently store these images provided their total size does not exceed the 16MB document limit. If you are likely going to this, you should consider redesigning your schema, otherwise your schema design will be fine.


2

had the same issue and the thing is everywhere it's written that you have to bind them like this bindIp : 127.0.0.1,192.168.0.50 but that doesn't work. The MongoDB version 3.2.x have the following configuration and its working for me. bindIp : [127.0.0.1,192.168.0.50] example : # network interfaces net: port: 27017 bindIp : [127.0.0....


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