The mongosync program uses change streams to synchronize data between source and destination clusters. mongosync does not access the oplog directly, but when a change stream returns events from the past, the events must be within the oplog time range.
mongosync oplogは、コレクションコピー フェーズの後に、ソースクラスターの の操作を宛先クラスターのデータに適用します。mongosync が適用していなかった操作がソースクラスターの oplog をロールオフすると、同期は失敗し、mongosync は終了します。
注意
mongosync does not replicate applyOps operations made on the source cluster during sync to the destination cluster.
If you anticipate syncing a large data set, or if you plan to pause synchronization for an extended period of time, you might exceed the oplog window. Use the oplogSizeMB setting to increase the size of the oplog on the source cluster.
Considerations
宛先クラスターには、移行される論理データ サイズと最初の同期の宛先oplogエントリーに十分対応できるディスクストレージが必要です。 例、10 GBのデータを移行するには、宛先クラスターでデータには少なくとも 10 GBが使用可能であり、最初の同期からの挿入oplogエントリ用にはさらに 10 GB が必要です。
埋め込み検証 を使用するには、宛先のoplogがより大きくなければなりません。埋め込み検証子を有効にして宛先oplogのサイズを減らすと、埋め込み検証子が追いつけない可能性があり、mongosync がエラーを発生させる可能性があります。
宛先oplogエントリのオーバーヘッドを減らす必要があり、埋め込み検証子が無効になっている場合は、次の操作を実行できます。
Use the
oplogSizeMBsetting to lower the destination cluster's oplog size.Use to
oplogMinRetentionHourssetting to lower or remove the destination cluster's minimum oplog retention period.
最初の同期に必要な oplog サイズを監視する
oplog window の決定
To get the difference in seconds between the first and last entry in the oplog run db.getReplicationInfo(). If you are replicating a sharded cluster, run the command on each shard.
db.getReplicationInfo().timeDiff
返される値は、クラスターの最小oplogウィンドウです。 シャードが複数ある場合、最小の数は最小のoplogウィンドウです。
mongosync レプリケーションラグの決定
lagTimeSeconds値を取得するには、 /progressコマンドを実行します。 ラグタイムは、 mongosyncによって適用された最後のイベントとソースクラスター上の現在の最新イベントの時間までの時間(秒単位)です。
これは、ソースクラスターmongosyncがどれだけ遅れているかを測定します。
oplog サイズの検証
ラグ時間が最小oplogウィンドウに近づく場合は、次のいずれかを変更します。
Increase the
oplogwindow. UsereplSetResizeOplogto setminRetentionHoursgreater than the currentoplogwindow.注意
replSetResizeOplogis unsupported in Atlas. To resize the oplog in Atlas, see Set Minimum Oplog Window.mongosyncインスタンスをスケールアップします。 CPU またはメモリを追加してmongosyncノードをスケールアップし、コピー率を高めます。
注意
レプリケーションラグのoplog window と変化率は、同期中に変化する可能性があります。 移行中にこれらの手順を繰り返し、進行状況を監視します。