AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

2 つの自己管理型クラスターの接続

mongosync ユーティリティは、 MongoDBクラスター間の接続を作成します。mongosync は次のいずれかのクラスターに接続できます。

このページでは、 MongoDB Mongosync を使用して自己管理型クラスターを接続する手順を説明します。

注意

最高のパフォーマンスを得るには、移行の前に、ソースクラスターと宛先クラスターを最新のMongoDB Serverパッチ リリースにアップグレードしてください。詳細については、MongoDBの最新の自己管理型パッチ リリースへのアップグレード を参照してください。

mongosync は、 MongoDB URI 接続文字列を使用してクラスターを接続します。

  • SRV 接続スキームの形式は次のとおりです。

    mongodb+srv://[username:password@][host.domain.TLD][:port][/defaultauthdb][?options]
  • 標準の URI 接続スキームの形式は次のとおりです。

    mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]

Specify the hostnames of the mongod instances the same way that they are listed in your replica set configuration.

For sharded clusters, specify the hostnames of the mongos instances instead of the mongod instances.

注意

mongosync does not require the replicaSet option.

mongosync requires the primary read preference to connect to the source and destination clusters. For more information, see Read Preference Options.

ソースクラスターまたは宛先クラスターのいずれかに認証が必要な場合は、 mongosyncを呼び出すときに正しい認証情報を指定する必要があります。

mongosync接続文字列で指定されたユーザーには、ソースクラスターと宛先クラスターで必要な権限が必要です。 権限は、書込みブロック設定を変更するか、逆同期を使用するかによって、環境によって異なります。

自己管理型権限は次のとおりです。

サーバーロールの詳細については、「自己管理型配置でのロールベースのアクセス制御」を参照してください。

To update user permissions, see: grantRolesToUser.

The mongosync utility can be hosted on its own hardware close to either the source or destination cluster. It does not have to be hosted on the same server as one of the mongod or mongos instances in the cluster. This flexibility allows you to push, or pull, data to the destination cluster with minimal impact on the mongod or mongos instances running there.

mongosyncが接続すると、 IDLE状態になります。 同期を開始するには、 startコマンドを発行する必要があります。

ソースクラスターcluster0は、次のサーバーとポートでホストされています。

  • clusterOne01.fancyCorp.com:20020

  • clusterOne02.fancyCorp.com:20020

  • clusterOne03.fancyCorp.com:20020

宛先クラスターcluster1は、次のサーバーとポートでホストされています。

  • clusterTwo01.fancyCorp.com:20020

  • clusterTwo02.fancyCorp.com:20020

  • clusterTwo03.fancyCorp.com:20020

各クラスターには管理ユーザーclusterAdminが設定されており、パスワードsuperSecretが使用されます。

一般的な接続文字列の形式は次のとおりです。

mongodb://<user>:<password>@<ip-address>:<port>,<ip-address>:<port>,<ip-address>:<port>

収集した接続情報を使用して、 cluster0cluster1の接続文字列を作成します。

cluster0:
mongodb://clusterAdmin:superSecret@clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020
cluster1:
mongodb://clusterAdmin:superSecret@clusterTwo01.fancyCorp.com:20020,clusterTwo02.fancyCorp.com:20020,clusterTwo03.fancyCorp.com:20020

以下のmongosyncコマンドのレイアウトは表示用に変更されています。 mongosyncを使用してcluster0cluster1に接続するには、次のコマンドを 1 行で入力します。

mongosync \
--cluster0 "mongodb://clusterAdmin:superSecret@clusterOne01.fancyCorp.com:20020,clusterOne02.fancyCorp.com:20020,clusterOne03.fancyCorp.com:20020" \
--cluster1 "mongodb://clusterAdmin:superSecret@clusterTwo01.fancyCorp.com:20020,clusterTwo02.fancyCorp.com:20020,clusterTwo03.fancyCorp.com:20020"

You can also use mongodb+srv connection strings with mongosync. You do not need to add the tls=true option to a mongodb+srv connection string. For example:

mongosync \
--cluster0 "mongodb+srv://clusterAdmin:superSecret@clusterOne01.fancyCorp.com/" \
--cluster1 "mongodb+srv://clusterAdmin:superSecret@clusterTwo01.fancyCorp.com/"

mongodb+srv接続文字列の詳細については、 SRV 接続形式 を参照してください。