2012-08-22 28 views

回答

2

如果您有sharded environment,则应该运行一个或多个mongos服务器(通常每个应用程序服务器一个),而不是直接连接到副本集。从the MongoDB documentation

摘录:

The mongos process can be thought of as a routing and coordination process 
that makes the various components of the cluster look like a single system. 
When receiving client requests, the mongos process routes the request to the 
appropriate server(s) and merges any results to be sent back to the client. 

connectionmongos服务器(S)应指定一样的,你会连接到服务器mongod,如:

<?php 

    $m = new Mongo("mongodb://mymongos1:27017"); 

?> 
+0

嗯。感谢Stennie!该文档没有详细说明如何使用客户端连接到mongos。 –

+1

@ Salocin.TEN:正确..我向Jira问题跟踪器添加了一个文档建议:[https://jira.mongodb.org/browse/PHP-460](https://jira.mongodb.org/browse/ PHP-460)。 – Stennie

+0

我猜测它没有被添加,因为尝试执行某些findOne()调用时抛出了一些套接字异常。 –