Skip to content

Instantly share code, notes, and snippets.

@spacemonkey
Created November 24, 2011 12:22
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save spacemonkey/1391238 to your computer and use it in GitHub Desktop.
Save spacemonkey/1391238 to your computer and use it in GitHub Desktop.
Example for connecting Lithium apps to a MongoDB replica set
/**
* Example of a production database called "db_prod" connecting to a replica set
* running on two systems, "db1" and "db2" with the replica set name of "prod_01".
*
* This setup assumes that you're running a recent version of MongoDB as well as
* the PHP extension.
**/
Connections::add('default', array(
'production' => array(
'type' => 'MongoDb',
'database' => 'db_prod',
'host' => array(
'db1.mywebsite.com',
'db2.mywebsite.com'
),
'replicaSet' => 'prod_01',
'setSlaveOkay' => true
)
)
@spacemonkey
Copy link
Author

The important part about this is the setSlaveOkay part, as you won't be able to do much but throw errors without it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment