Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure RockMongo for Mongo replicaSet

Tags:

php

mongodb

ide

I recently switched to the RockMongo browser, but I am having a hard time making it work with a replicaSet.

Per the official documentation, I declared the server as:

$MONGO["servers"][$i]["mongo_name"] = "localhost";//mongo server name
$MONGO["servers"][$i]["mongo_host"] = "127.0.0.1";//mongo host
$MONGO["servers"][$i]["mongo_port"] = "27017";//mongo port
$MONGO["servers"][$i]["mongo_timeout"] = 0;//mongo connection timeout

RockMongo complains with the following:

Execute failed:not master
function (){ return db.getCollectionNames(); }

I also tried another variant which resulted in the same error:

$MONGO["servers"][$i]["mongo_host"] = "mongodb://192.168.0.2,192.168.0.3";// multiple hosts

Can RockMongo work with a replicaSet?

like image 806
Justin T. Avatar asked May 21 '12 14:05

Justin T.


1 Answers

But if you dive into the source code, you find that rockmongo can indeed connect to replicaSet using undocumented "mongo_options" key :

$MONGO["servers"][$i]["mongo_options"] = array('replicaSet' => 'REPLICA_NAME');//mongo server name
$MONGO["servers"][$i]["mongo_host"] = "mongodb://192.168.0.2,192.168.0.3";//mongo host
$MONGO["servers"][$i]["mongo_port"] = false;//mongo port

Hope this helps !

like image 151
Justin T. Avatar answered Sep 20 '22 17:09

Justin T.