Amir
Amir

Reputation: 6176

php access to mongodb master/slave access

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?

Upvotes: 0

Views: 661

Answers (1)

ceejayoz
ceejayoz

Reputation: 179994

According to the docs, you'd do:

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

Upvotes: 1

Related Questions