"I can not even get a connection to a SINGLE mongo db" caught my eye.
What happens if you run:
$m = new Mongo("mongodb://cache1-zone");
print_r($m->admin->command(array("ismaster" => 1)));
On Jun 22, 2:34 pm, AllanD <
a_d...@bellsouth.net> wrote:
> Kristina,
>
> Hello, I am not sure if I need to start a new discusion or just join in
> right here.  I have read what seems like hundreds of blog post, mongo
> reports, google reports, mongo user manuals, etc... but still not solution
> to what seems to be a simple problem.
>
> My issue is with trying to connec to a replica set on
> mongodb-sunos5-x86_64-2.0.6 using php pecl driver 1.2.10 (downloaded
> yesterday).
>
> For my environment I have 3 seperate servers, a primary, secondary, and
> arbitrator.  They seem to be configured properly and everything works fine
> from the mongo prompt.  Updates to primary are replicated to secondary, and
> when one goes down the other is promoted by the arbitrator, it looks good,
> HOWEVER--- I simply can not connect from any of my web servers to the mongo
> servers.  The option of using localhost is no substitution for actual real
> servers.
>
> There are no network problem, I can ping by hostname to and from every
> server.
>
> When I submit my webpage, the console on the mongo server says it got
> connection, but the php returns "error message: couldn't determine master".
>
> I am pleading with you to take a serious look here and see why I can not
> get a connection that can determine the mongo master.  My configurations
> are as follows.
>
> THE MONGO SERVERS THEMSELVES.
>
> *MONGO SERVER 1: *
>
> db.adminCommand("getCmdLineOpts")
> PRIMARY> db.adminCommand("getCmdLineOpts")
> {
>         "argv" : [
>                 "mongod",
>                 "--replSet",
>                 "koalacache",
>                 "--port",
>                 "27017",
>                 "--dbpath",
>                 "/cache/cache1",
>                 "--directoryperdb",
>                 "--smallfiles"
>         ],
>         "parsed" : {
>                 "dbpath" : "/cache/cache1",
>                 "directoryperdb" : true,
>                 "port" : 27017,
>                 "replSet" : "koalacache",
>                 "smallfiles" : true
>         },
>         "ok" : 1}
>
> *MONGO SERVER 2: *
> SECONDARY> db.adminCommand("getCmdLineOpts")
> {
>         "argv" : [
>                 "mongod",
>                 "--replSet",
>                 "koalacache",
>                 "--port",
>                 "27017",
>                 "--dbpath",
>                 "/cache/cache2",
>                 "--directoryperdb",
>                 "--smallfiles"
>         ],
>         "parsed" : {
>                 "dbpath" : "/cache/cache2",
>                 "directoryperdb" : true,
>                 "port" : 27017,
>                 "replSet" : "koalacache",
>                 "smallfiles" : true
>         },
>         "ok" : 1}
>
> *MONGO SERVER 3 (ARBITER): *
> ARBITER>
> db.adminCommand("getCmdLineOpts")
> {
>         "argv" : [
>                 "mongod",
>                 "--replSet",
>                 "koalacache",
>                 "--port",
>                 "27017",
>                 "--dbpath",
>                 "/cache/arb",
>                 "--directoryperdb",
>                 "--smallfiles",
>                 "--oplogSize",
>                 "1"
>         ],
>         "parsed" : {
>                 "dbpath" : "/cache/arb",
>                 "directoryperdb" : true,
>                 "oplogSize" : 1,
>                 "port" : 27017,
>                 "replSet" : "koalacache",
>                 "smallfiles" : true
>         },
>         "ok" : 1}
>
> *MONGO SERVER STATUS*
> PRIMARY> rs.status()
> {
>         "set" : "koalacache",
>         "date" : ISODate("2012-06-22T18:41:49Z"),
>         "myState" : 1,
>         "members" : [
>                 {
>                         "_id" : 0,
>                         "name" : "cache1-zone:27017",
>                         "health" : 1,
>                         "state" : 1,
>                         "stateStr" : "PRIMARY",
>                         "optime" : {
>                                 "t" : 1340321540000,
>                                 "i" : 1
>                         },
>                         "optimeDate" : ISODate("2012-06-21T23:32:20Z"),
>                         "self" : true
>                 },
>                 {
>                         "_id" : 1,
>                         "name" : "cache2-zone:27017",
>                         "health" : 1,
>                         "state" : 2,
>                         "stateStr" : "SECONDARY",
>                         "uptime" : 21153,
>                         "optime" : {
>                                 "t" : 1340321540000,
>                                 "i" : 1
>                         },
>                         "optimeDate" : ISODate("2012-06-21T23:32:20Z"),
>                         "lastHeartbeat" : ISODate("2012-06-22T18:41:49Z"),
>                         "pingMs" : 0
>                 },
>                 {
>                         "_id" : 2,
>                         "name" : "cache-arb-zone:27017",
>                         "health" : 1,
>                         "state" : 7,
>                         "stateStr" : "ARBITER",
>                         "uptime" : 100,
>                         "optime" : {
>                                 "t" : 0,
>                                 "i" : 0
>                         },
>                         "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
>                         "lastHeartbeat" : ISODate("2012-06-22T18:41:49Z"),
>                         "pingMs" : 0
>                 }
>         ],
>         "ok" : 1}
>
> *THE MONGO DRIVER STATUS FROM PHPINFO()*
> php version 5.4.2
> apache 2.4.2 (unix)
> mongoMongoDB SupportenabledVersion1.2.10
> DirectiveLocal ValueMaster Valuemongo.allow_empty_keys00
> mongo.allow_persistent11mongo.auto_reconnect11mongo.chunk_size262144262144
> mongo.cmd$$mongo.default_hostlocalhostlocalhostmongo.default_port2701727017
> mongo.is_master_interval6060mongo.long_as_object00mongo.native_long00
> mongo.no_id00mongo.ping_interval55mongo.utf811
>
> **
> *THE PHP CODE I USING TO CONNECT (WHICH FAILS).*
>
> <?php
>
> try {
> $m = new Mongo("mongodb://cache1-zone,cache2-zone", array("replicaSet" =>
> true, "persist" => 'sess'));
>
> $m->connect;
> echo("we got connect = ");
> var_dump($m->connected);
>
> echo("we got status = ");
> var_dump($m->status);
>
> echo("we got server = ");
> var_dump($m->server);
>
> print_r($m->admin->command( array( "ismaster" => 1 ) ));
> $db = new MongoDB($m, "allantestdb");
> $c = $db->selectCollection("example");
> $c->setSlaveOkay(true);
>
> var_dump($c->findOne());
>
> }
>
> catch (MongoCursorException $e) {
>     echo "error message: ".$e->getMessage()."\n";
>     echo "error code: ".$e->getCode()."\n";
>
> }
>
> *THE OUTPUT SHOWING ERROR DETERMINING MASTER.*
> we got connect = bool(true)
> we got status = NULL
> we got server = object(MongoDB)#2 (2) { ["w"]=> int(1) ["wtimeout"]=>
> int(10000) }
> error message: couldn't determine master error code: 14
> ?>
>
> Please help me get a connection string to a replication set.  I can not
> even get a connection to a SINGLE mongo db.
>
> It is frustrating to see the potential of Mongo, have setting up all these
> servers, and not even be able to connect to what is suposed to be a high
> availability database solution.
>
> Sorry, your help is appreciated.
>
> Thank You,
> Allan