我有3个副本集,每个副本集都在自己的分片中。每个副本集有2台Mongo服务器(主备)。
使用Mongo()的连接字符串时,我应该连接到哪台服务器?
谢谢!
发布于 2012-08-22 15:31:17
如果您有一个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.
指定mongos
服务器的connection应与连接到mongod
服务器的方式相同,例如:
<?php
$m = new Mongo("mongodb://mymongos1:27017");
?>
https://stackoverflow.com/questions/12068128
复制相似问题