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.

シャーディングされたクラスターの場合は、 インスタンスではなく、mongos mongodインスタンスのホスト名を指定します。

注意

mongosync does not require the replicaSet option.

mongosync では、ソースクラスターと宛先クラスターに接続するには、 読み込み設定 (readprimary preference)が必要です。詳しくは、「 読み込み設定(read preference)オプション 」を参照してください。

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

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

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

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

ユーザー権限を更新するには、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"

mongodb+srvmongosyncでは 接続文字列を使用することもできます。tls=true オプションをmongodb+srv 接続文字列に追加する必要はありません。 (例: )。

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

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