それぞれ独自のシャードに 3 つのレプリカ セットがあります。各レプリカ セットには 2 つの Mongo サーバー (マスターとスレーブ) があります。
Mongo() の接続文字列を使用する場合、どのサーバーに接続する必要がありますか?
ありがとう!
シャード環境の場合は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");
?>