Posts

Showing posts with the label issue

MongoDB tips: Performance Tuning, Index creation order matters

I am hoping this post will be obsolete and noone will needs to find this. Continue from my previous post about choosing the best index for the job, that certain should still holds true as when I created the index with 1, -1 for two different date field, it's less efficient than -1, -1. Anyway, so luckily I found out about this before rolling this into production as I was planning on the production release. Under lower environment, I realized a less efficient index was used... from my previous post . I now believe it's a bug that should be fixed, in my experiments, the newer index is always preferred even when a better index is present. MongoDB query optimizer looks to be looking into only the first selective field I chose and no further. So if the latest index created matches the field this index is created, so in order for my query to serve the high frequency query, I have to make sure the best index is created last.

MongoDB tip: Apply authentication option to a replica set, issue encountered and fix

Assuming we have a replicate set started as such, please refer to article 1  or article 2 to see how to configure a replica set if you haven't already done so and still have issues. Output of ps -ef | grep mongod root     20706     1  0 15:09 ?        00:00:01 mongod --port 31111 --replSet biDemo --dbpath /data/mongodb/demo1 --logpath /data/mongodb/demolog/1.log --fork  root     20943     1  0 15:10 ?        00:00:01 mongod --port 31112 --replSet biDemo --dbpath /data/mongodb/demo2 --logpath /data/mongodb/demolog/2.log --fork root     21101     1  0 15:11 ?        00:00:01 mongod --port 31113 --replSet biDemo --dbpath /data/mongodb/demo3 --logpath /data/mongodb/demolog/3.log --fork  Log into primary and add user, you will need at least one admin user to start and administer mongod with authentication enabled MongoDB Ente...

MongoDB tip: issue with specifying localhost in replica set configuration

Often time when we want to quickly spin up a demo mongodb replica set, we would simply use the localhost:port to specify the nodes assuming all members are on the same server. Here is an quick example why that's not a good practice Here is the output of my current rs.status() MongoDB Enterprise biDemo:PRIMARY> conf= rs.conf() {         "_id" : "biDemo",         "version" : 5,         "protocolVersion" : NumberLong(1),         "members" : [                 {                         "_id" : 0,                         "host" : "localhost:31111",                         "arbiterOnly" : false,                         "b...