我有3个副本集,每个副本集都有自己的分片。每个副本集都有2个Mongo服务器(主服务器和从服务器)。
使用Mongo()的连接字符串时,我应该连接哪些服务器?
谢谢!
答案 0 :(得分:2)
如果您有sharded environment,则应运行一个或多个mongos
服务器(通常每个应用程序服务器一个),而不是直接连接到副本集。
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
到mongod
服务器的connection应该与连接到<?php
$m = new Mongo("mongodb://mymongos1:27017");
?>
服务器的服务器相同,例如:
{{1}}