I am running my website with Laravel 5 + MongoDB.
I am using mongo cluster to speed up data read and write, and to lower CPU usage of the mongo server.
I have set up the replica like this: 10.0.1.111 is primary replica set, and 10.0.1.112 & 10.0.1.113 is the secondary replica set.
Config::set('database.connections.'.$schemaName, array( 'host' => array('10.0.1.111','10.0.1.112','10.0.1.113'), 'driver' => 'mongodb', 'port' => 27017, 'database' => $schemaName, 'prefix' => '', 'options' => array( 'replicaSet' => 'replset-name', 'readPreference' => \MongoClient::RP_SECONDARY_PREFERRED ) ));
When I use this, it shows a "No candidate servers found" error. When I use a single host 10.0.1.111 it works well. It will be highly appreciated if you can give a solution to this problem.