Knowing MongoDB opLog
Replication gives you hot backups, read scaling, and all sorts of other goodness. If you know how it works you can get a lot more out of it, from how it should be configured to what you should monitor to…
MongoDB graceful shutdown script.
MongoDB graceful shutdown script. [root@hostname bin]$ cat new_shutdown.sh #!/bin/bash BIN=/tmp/mongodb/bin DB=admin HOST=`hostname` cd $BIN MONGOPID=`ps -ef | egrep ‘mongod|mongos’ | grep -v egrep | awk ‘{print $2}’` if [ -z $MONGOPID ]; then echo “There are no Mongo processes are…
MongoDB Initial Sync & Sharding/Balancing timings – The influencing factors
The following factors influence the Initial sync & sharding timings i.e., the initial sync between primary and secondary for a replica set or the initial sharding/balancing for a sharded cluster 1. Document size 2. No. of documents/collections 3. No….
Full text search in MongoDB
This is a custom implementation created by the MongoDB developers as a specific index type, and is due to be launched as an experimental feature in MongoDB 2.4. It has features such as: Full text search as an index type…
MongoDB: count() inconsistency during the MongoDB Initial Sharding
We observed that inconsistent document counts of a collection when we query thru mongos during initial sharding due to newly added shard to the existing set-up. It’s expected to have inconsistent counts when we query directly on shard, but App…
MongoDB: lock/unlock users
While there are no built in commands for lock/unLock, it is possible to add them. Here are a couple of simple implementations that remove the user you want to lock from the db.system.users collection and save it in a lockedUsers…
MongoDB User creation: localhost exception
If we create a user in Mongos (router), we can authenticate Mongod’s (RS/Shard: in case of shard, user should have ‘clusterAdmin’ role) using that user. But still we can directly connect to Mongod’s with localhost exception with out any UN/PW….
MongoDB ConfigDB differ issue – Recovery procedure
We have 3 config servers ( say config1, config2 & config3 ) in production and imagine we have config db differ issue (configdb mismatch) on the config1 & config3. Then we may have to follow the following procedure to recover…
MongoDB Custom script for Monitoring
Main PHP program ( mm.php ) :- [root@MyLabBox v8]# pwd /var/www/html/mongo/v8 [root@MyLabBox v8]# cat mm.php <?php ############################################################# ############################################################# header(‘Refresh:120’); include(“mm_data.php”); $data_cfg_file = “datanode.cfg”; $fd = fopen($data_cfg_file, ‘r’); $node=fgets($fd); $count=1; echo ” <tr>”; while ( $node != “”) { $out =…
MongoDB Shrink database for cleanup space released
When documents or collections are deleted, empty record blocks within data files arise. MongoDB attempts to reuse this space when possible, but it will never return this space to the file system. This behavior explains why fileSize never decreases despite…