首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用PHP Mongo连接到哪个Mongo服务器?

使用PHP Mongo连接到哪个Mongo服务器?
EN

Stack Overflow用户
提问于 2012-08-22 15:21:17
回答 1查看 793关注 0票数 1

我有3个副本集,每个副本集都在自己的分片中。每个副本集有2台Mongo服务器(主备)。

使用Mongo()的连接字符串时,我应该连接到哪台服务器?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-22 15:31:17

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

摘自the MongoDB documentation

代码语言:javascript
运行
复制
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服务器的方式相同,例如:

代码语言:javascript
运行
复制
<?php

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

?>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12068128

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档