在PHP手册中,它有以下示例:
<?php
// pass a comma-separated list of server names to the constructor
$m1 = new Mongo("mongodb://sf2.example.com,ny1.example.com", array("replicaSet" => true));
// you only need to pass a single seed, the driver will derive the full list and
// find the master from this seed
$m2 = new Mongo("mongodb://ny1.example.com", array("replicaSet" => true));
?>发布于 2012-03-20 15:26:08
更多关于#2的内容: Mongo类自动确定主程序和次要程序是谁,然后向主程序发送写操作(如果设置了slaveOkay,则读取到次要文件)。
发布于 2011-04-06 00:33:42
1) $m1和$m2将返回Mongo (数据库连接)对象,而不是这样的值。2)您可以找到使用$m1->isMaster()的主服务器;3)不太清楚您的意思,它们必须是相同的。
https://stackoverflow.com/questions/5559474
复制相似问题