added replica pair example, ws

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@296083 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Kristina Chodorow 2010-03-11 17:44:33 +00:00
parent 0cc3ec8215
commit 0eb20fdb1f
2 changed files with 58 additions and 0 deletions

View file

@ -65,7 +65,9 @@ $ sudo pecl install mongo
Add the following line to your php.ini file:
<programlisting>
<![CDATA[
extension=mongo.so
]]>
</programlisting>
</para>
@ -85,11 +87,13 @@ extension=mongo.so
<programlisting>
<![CDATA[
$ tar zxvf mongodb-mongodb-php-driver-<commit_id>.tar.gz
$ cd mongodb-mongodb-php-driver-<commit_id>
$ phpize
$ ./configure
$ sudo make install
]]>
</programlisting>
</para>
@ -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:
<programlisting>
<![CDATA[
Installing '/usr/lib/php/extensions/no-debug-zts-20060613/mongo.so'
]]>
</programlisting>
@ -111,9 +117,11 @@ $ sudo make install
<programlisting>
<![CDATA[
$ php -i | grep extension_dir
extension_dir => /usr/lib/php/extensions/no-debug-zts-20060613 =>
/usr/lib/php/extensions/no-debug-zts-20060613
]]>
</programlisting>
@ -126,7 +134,9 @@ $ sudo make install
<programlisting>
<![CDATA[
extension=mongo.so
]]>
</programlisting>
@ -147,7 +157,9 @@ $ sudo make install
following command:
<programlisting>
<![CDATA[
sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo
]]>
</programlisting>
</para>
@ -161,7 +173,9 @@ sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo
extension directory. Add
<programlisting>
<![CDATA[
extension=mongo.so
]]>
</programlisting>
to the php.ini file being used and restart the server.
@ -175,7 +189,9 @@ sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo
<programlisting>
<![CDATA[
$ phpize && aclocal && autoconf && ./configure && make && make install
]]>
</programlisting>
@ -191,9 +207,11 @@ $ phpize && aclocal && autoconf && ./configure && make && make install
mongo.ini file. Put the following in your mongo.ini file:
<programlisting>
<![CDATA[
extension=mongo.so
; any other mongo options you'd like (see the Runtime Configuration section)
]]>
</programlisting>
</para>
@ -271,7 +289,9 @@ extension=mongo.so
Add the following line to your php.ini file:
<programlisting>
<![CDATA[
extension=php_mongo.dll
]]>
</programlisting>
</para>

View file

@ -70,4 +70,42 @@ $m = new Mongo("mongodb://${username}:${password}@localhost/blog");
</programlisting>
</section>
<section>
<title>Replica Pairs</title>
<para>
To connect to a replica pair, specify both sides of the pair.
</para>
<programlisting role="php">
<![CDATA[
<?php
$m = new Mongo("mongodb://localhost:27017,localhost:27018");
?>
]]>
</programlisting>
<para>
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
<classname>MongoConnectionException</classname> will be thrown.
</para>
<para>
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.
</para>
<para>
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.
</para>
<para>
For more information on replica pairs, see the
<link xlink:href="&url.mongodb.replica;">core documentation</link>.
</para>
</section>
</section>