From 0eb20fdb1fa8fa9f22581997e46d8ad03c9c8914 Mon Sep 17 00:00:00 2001 From: Kristina Chodorow Date: Thu, 11 Mar 2010 17:44:33 +0000 Subject: [PATCH] added replica pair example, ws git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@296083 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/configure.xml | 20 ++++++++++++++++++ reference/mongo/connecting.xml | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/reference/mongo/configure.xml b/reference/mongo/configure.xml index 3104ab62d1..a5242bd217 100644 --- a/reference/mongo/configure.xml +++ b/reference/mongo/configure.xml @@ -65,7 +65,9 @@ $ sudo pecl install mongo Add the following line to your php.ini file: @@ -85,11 +87,13 @@ extension=mongo.so .tar.gz $ cd mongodb-mongodb-php-driver- $ phpize $ ./configure $ sudo make install + ]]> @@ -103,7 +107,9 @@ $ sudo make install 1. The build will display where it is installing the PHP driver with output that looks something like: @@ -111,9 +117,11 @@ $ sudo make install /usr/lib/php/extensions/no-debug-zts-20060613 => /usr/lib/php/extensions/no-debug-zts-20060613 + ]]> @@ -126,7 +134,9 @@ $ sudo make install @@ -147,7 +157,9 @@ $ sudo make install following command: @@ -161,7 +173,9 @@ sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo extension directory. Add to the php.ini file being used and restart the server. @@ -175,7 +189,9 @@ sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo @@ -191,9 +207,11 @@ $ phpize && aclocal && autoconf && ./configure && make && make install mongo.ini file. Put the following in your mongo.ini file: @@ -271,7 +289,9 @@ extension=mongo.so Add the following line to your php.ini file: diff --git a/reference/mongo/connecting.xml b/reference/mongo/connecting.xml index 5ecaaabe6e..2f7247846f 100644 --- a/reference/mongo/connecting.xml +++ b/reference/mongo/connecting.xml @@ -70,4 +70,42 @@ $m = new Mongo("mongodb://${username}:${password}@localhost/blog"); +
+ Replica Pairs + + To connect to a replica pair, specify both sides of the pair. + + + +]]> + + + Order is irrelevant, the PHP driver will query the database servers to figure + out which one is master. So long as one of them is up and master, the + connection will succeed. If neither is up or there is no master, a + MongoConnectionException will be thrown. + + + If the master becomes unavailable, the slave will not become master for a few + seconds. During that time, the driver will not be able to perform any + database operations because the master database is gone and the other + database is a slave. Thus, if you attempt to do any sort of query (including + "safe" operations) they will throw exceptions. + + + The slave will eventually realize that the master is gone and become master + itself. At this point, the driver will make this its primary database + connection and continue operating normally. + + + For more information on replica pairs, see the + core documentation. + +
+