ダウンタイムなしでMongoDBをOracle AI Databaseに移行

ダウンタイムなしでOCI GoldenGateをMongoDBからOracle AI Databaseに使用する方法をご覧ください。

OCI GoldenGate Big Dataは、MongoDBおよびMongoDB Atlasからダウンタイムなしで次のターゲットへの移行をサポートします。

Autonomous AI JSON DatabaseおよびAutonomous AI Databaseには、OCI GoldenGateがターゲットOracle AI Databaseシステムへの接続に使用する、事前構成されたOracle API for MongoDB接続文字列が付属しています。詳細は、「Oracle AI Database API for MongoDBの使用」を参照してください。

ターゲットがオンプレミスのOracle AI Databaseの場合は、Oracle Rest Data Servicesを使用して、オンプレミスのOracle AI DatabaseでOracle AI Database API for MongoDBを有効にできます。

開始する前に

このクイックスタートを正常に完了するには、次のものがあることを確認します。

移行の設定と実行

  1. ソースMongoDBで、MongoDBダンプ・ユーティリティを実行します。

    1. --oplogオプションを指定してmongodumpを実行し、ソースMongoDBデータベースのスナップショットを作成します:

      $ ./bin/mongodump --uri="mongodb://localhost:27021" --oplog -v

      コマンドによって、次のメッセージが返されます。

      <date+timestamp>    getting most recent oplog timestamp
      <date+timestamp>    writing admin.system.version to dump/admin/system.version.bson
      <date+timestamp>    done dumping admin.system.version (1 document)
      <date+timestamp>    dumping up to 4 collections in parallel
      <date+timestamp>    writing testDB.coll1 to dump/testDB/coll1.bson
      <date+timestamp>    writing testDB.coll2 to dump/testDB/coll2.bson
      <date+timestamp>    writing testDB.coll3 to dump/testDB/coll3.bson
      <date+timestamp>    done dumping testDB.coll3 (10000 documents)
      <date+timestamp>    done dumping testDB.coll1 (10000 documents)
      <date+timestamp>    done dumping testDB.coll2 (10000 documents)
      <date+timestamp>    writing captured oplog to
      <date+timestamp>    dumped 7 oplog entries

      これにより、すべてのデータベースおよびコレクションのバイナリ・アーカイブ・データファイルを含むダンプ・フォルダが次の場所に生成されます。

      dump/database-name/collection-name/collection-name.bson

      また、ダンプ・フォルダの下にoplog.bsonも直接作成されます。

    2. oplog.bsonファイルの内容(バイナリ形式)を調べるには、bsondumpユーティリティを使用してJSONに変換できます。

      $ ./bin/bsondump --pretty --outFile /path/to/oplog.json dump/oplog.bson

      コマンドによって、次のメッセージが返されます。

      <date+timestamp>    7 objects found
  2. oplong.bsonから最初と最後の操作のタイムスタンプを抽出します。

    1. OplogLSN.shスクリプトのダウンロード

    2. ソースMongoDBのOplongLSN.shスクリプトを、mongodumpがある同じディレクトリで実行し、次のようにoplog.bsonに引数として場所を渡します。

      $./oplogLSN.sh /path/to/dump/oplog.bson

      コマンドによって、次のメッセージが返されます。

      <date+timestamp> 1 objects found
      First LSN: 1740663867.1
      Last LSN: 1740663946.211
    3. Oplogエントリを調べます。ダンプ中に受信操作があった場合、oplog.bsonファイルにはそれらの操作のエントリが含まれ、それぞれにタイムスタンプが付きます。前のステップに示すように、OplogLSN.shを使用して、最初と最後の操作のタイムスタンプを取得したり、手動検査のためにJSONファイルに変換したりできます。

  3. MongoDBリストア・ユーティリティを実行します。mongorestoreユーティリティを使用して、選択したコレクションをダンプからターゲットのMongoDBインスタンスにリストアします。

    $ ./mongorestore --uri="mongodb://localhost:27021" --nsInclude=testDB.coll1 --nsInclude=testDB.coll2 /path/to/dump -v

    コマンドによって、次のメッセージが返されます。

    <date+timestamp>    using write concern: &{majority <nil> 0s}
    <date+timestamp>    using default 'dump' directory
    <date+timestamp>    preparing collections to restore from
    <date+timestamp>    found collection admin.system.version bson to restore to admin.system.version
    <date+timestamp>    found collection metadata from admin.system.version to restore to admin.system.version
    <date+timestamp>    don't know what to do with file "dump/oplog.json", skipping...
    <date+timestamp>    found collection testDB.coll1 bson to restore to testDB.coll1
    <date+timestamp>    found collection metadata from testDB.coll1 to restore to testDB.coll1
    <date+timestamp>    found collection testDB.coll2 bson to restore to testDB.coll2
    <date+timestamp>    found collection metadata from testDB.coll2 to restore to testDB.coll2
    <date+timestamp>    reading metadata for testDB.coll1 from dump/testDB/coll1.metadata.json
    <date+timestamp>    reading metadata for testDB.coll2 from dump/testDB/coll2.metadata.json
    <date+timestamp>    creating collection testDB.coll1 with no metadata
    <date+timestamp>    creating collection testDB.coll2 with no metadata
    <date+timestamp>    restoring testDB.coll1 from dump/testDB/coll1.bson
    <date+timestamp>    restoring testDB.coll2 from dump/testDB/coll2.bson
    <date+timestamp>    finished restoring testDB.coll1 (10000 documents, 0 failures)
    <date+timestamp>    finished restoring testDB.coll2 (10000 documents, 0 failures)
    <date+timestamp>    no indexes to restore for collection testDB.coll1
    <date+timestamp>    no indexes to restore for collection testDB.coll2
    <date+timestamp>    20000 document(s) restored successfully. 0 document(s) failed to restore.

    このコマンドは、指定されたコレクションのデータ、メタデータおよび索引定義をターゲットMongoDB/ORDSインスタンスにリストアします。たとえば、上の出力に示すように、データベースtestDBのcoll1とcoll2です。

  4. MongoDBのソース・ビッグ・データ・デプロイメントでチェンジ・データ・キャプチャ(CDC)抽出を作成および実行します。ステップ2bで取得した最初の操作タイムスタンプ(最初のLSN)からMongoDB CDC Extractを起動します。これにより、ダンプ・プロセスの開始後に発生する操作がCDC Extractによって確実に取得されます。

  5. MongoDB Replicatを作成して実行します

    1. ステップ4で生成されたCDC証跡ファイルを使用します。

    2. oplongReplayLastLsnを、ステップ2bで取得した最後の操作タイムスタンプ(Last LSN)に設定するか、oplog.bsonへのパスと最後のLSNが自動的に取得されます。これにより、Replicatは確実にoplong-replayモードで実行されるため、競合を回避し、データの損失や重複のない正確な開始を保証できます。最後のタイムスタンプが処理された後、Replicatは通常のモードで続行されます。

ヒント

移行を円滑に進めるためのヒントをいくつか示します。