1

それぞれ独自のシャードに 3 つのレプリカ セットがあります。各レプリカ セットには 2 つの Mongo サーバー (マスターとスレーブ) があります。

Mongo() の接続文字列を使用する場合、どのサーバーに接続する必要がありますか?

ありがとう!

4

1 に答える 1

2

シャード環境の場合はmongos、レプリカ セットに直接接続するのではなく、1 つ以上のサーバー (通常はアプリケーション サーバーごとに 1 つ) を実行する必要があります。

MongoDB ドキュメントからの抜粋:

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ます。例:

<?php

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

?>
于 2012-08-22T07:31:16.563 に答える