php access to mongodb master/slave access

Go To StackoverFlow.com

0

Having a two mongodb servers as master and slave, i wonder what is the best way of using php new mongo(dbaddress) so I can switch between them once one of the servers is down.

I have tested

  new Mongo('10.10.10.10:27019', array("replicaSet" => "set"));

where 10.10.10.10 is the master and .11 is the slave. but it didn't work.

I do not want to have two huge block of try and for one server and then repeat the whole thing to catch the connection exception (it really looks stupid).

Can you please help?

2012-04-03 21:39
by Amir


1

According to the docs, you'd do:

new Mongo('mongodb://10.10.10.10:27019,10.10.10.11:27019', array("replicaSet" => "set"));
2012-04-03 21:48
by ceejayoz
Ads