From ce2287e205d508183da5526520b79509a8ece5cb Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Thu, 29 Nov 2012 05:03:19 +0000 Subject: [PATCH] Adding seealso/changelogs and best practices and such things git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328553 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mongo/connecting.xml | 122 ++++++++++++++++++++++++++++++--- reference/mongo/queries.xml | 19 ----- 2 files changed, 113 insertions(+), 28 deletions(-) diff --git a/reference/mongo/connecting.xml b/reference/mongo/connecting.xml index a407f05fca..b032f63b08 100644 --- a/reference/mongo/connecting.xml +++ b/reference/mongo/connecting.xml @@ -23,6 +23,7 @@ MongoClient::__construct. + Authenticating against the "admin" database $username, "pass MongoClient::__construct. + Authenticating against normal databases + ReplicaSet seedlist - - Version 1.0.9+ of the driver is required to connect to a replica set. Earlier - versions of the driver will not auto-detect the primary or reconnect - correctly. - The PHP driver will query the database server(s) listed to determine the primary. So long as it can connect to at least one host listed and find a @@ -95,6 +93,13 @@ $m = new MongoClient("mongodb://rs1.example.com:27017,rs2.example.com:27017", ar servers listed or cannot find a primary, a MongoConnectionException will be thrown. + + + You should always provide a seedlist with more then one member of the + ReplicaSet. For highest availability you should seed with at least one + server from each of your datacenters. + + If the primary becomes unavailable, an election will take place and a secondary will be promoted to the role of primary (unless a majority vote @@ -104,15 +109,81 @@ $m = new MongoClient("mongodb://rs1.example.com:27017,rs2.example.com:27017", ar do so will result in an exception. Connections to secondaries will still be able to perform reads. + + + The default Read Preference + is to only read from the primary. During the election process there is no + primary, and all read will therefore fail. + + + It is recommended to use + MongoClient::RP_PRIMARY_PREFERRED Read Preference for + applications that require high availability for reads, as reads will only + be executed on the secondaries when there simply isn't a primary + available. + + Once a primary is elected, attempting to perform a read or write will allow the driver to detect the new primary. The driver will make this its primary database connection and continue operating normally. + + The health and state of a secondary is checked every 5 seconds + (configurable with + mongo.ping_interval) + or when the next operation occurs after 5 seconds. It will also recheck + the configuration when the driver has a problem reaching a server. + + + ReplicaSet failovers are checked every 60seconds (configurable with + mongo.is_master_interval), + and whenever a write operation fails when using acknowledged writes. + + + + + Secondaries may be behind the primary in operations, so + your application must be okay with getting out-of-date data when using + Read Preferences other then MongoClient::RP_PRIMARY. + + + For more information on replica sets, see the core documentation. + + + &reftitle.seealso; + + + + + + + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 1.0.9 + + Added support for connecting to ReplicaSet and automatic failover. + + + + + + +
@@ -152,9 +223,8 @@ $m = new MongoClient("mongodb://mongos1.example.com:27017,mongos2.example.com:27 Domain Socket Support - If you are running MongoDB locally and using version 1.0.9+ of the driver, - you can connect to the database via a socket file. MongoDB automatically - opens a socket file on startup: /tmp/mongodb-<port>.sock. + MongoDB has built-in support for via Unix Domain Sockets and will open the + socket on startup, by default located in /tmp/mongodb-<port>.sock.. @@ -187,12 +257,46 @@ $m = new MongoClient("mongodb://username:password@/tmp/mongo-27017.sock:0/foo"); ?> ]]> - + + + + &reftitle.changelog; + + + + + &Version; + &Description; + + + + + 1.0.9 + + Added support for Unix Domain Sockets. + + + + + +
Connection Pooling (version 1.2.0-1.2.12 *only*) + + + This section is no longer relevant as of the 1.3.0 release of the driver + and only serves as a historical information on how the pooling used to + work. + + + The latest versions of the driver have no concept of pooling anymore and + will maintain only one connection per process, for each connection type + (ReplicaSet/standalone/mongos), for each credentials combination. + + Creating connections is one of the most heavyweight things that the driver does. It can take hundreds of milliseconds to set up a connection correctly, diff --git a/reference/mongo/queries.xml b/reference/mongo/queries.xml index 32024066e5..14c3fa7b04 100644 --- a/reference/mongo/queries.xml +++ b/reference/mongo/queries.xml @@ -135,25 +135,6 @@ Reading from: europeanHost All other commands are always sent to the primary. - - - The health and state of a secondary is checked every 5 seconds - (configurable with - mongo.ping_interval) - or when the next operation occurs after 5 seconds. It will also recheck - the configuration when the driver has a problem reaching a server. - - - ReplicaSet failovers are checked every 60seconds (configurable with - mongo.is_master_interval), - and whenever a write operation fails when using acknowledged writes. - - - - Note that secondaries may be behind the primary in operations, so - your application must be okay with getting out-of-date data when using - Read Preferences other then MongoClient::RP_PRIMARY. -