다운타임 없이 MongoDB을 Oracle Database로 마이그레이션

다운타임 없이 OCI GoldenGate에서 MongoDB까지 Oracle Database로 전환하는 방법을 살펴보세요.

OCI GoldenGate Big Data는 다운타임 없이 MongoDBMongoDB Atlas에서 Oracle Autonomous JSON Database, Oracle Autonomous Database 및 Oracle Database로의 마이그레이션을 지원합니다. 자율운영 JSON 데이터베이스 및 Oracle Autonomous Database에는 OCI GoldenGate이 대상 Oracle Database 시스템에 연결하는 데 사용하는 사전 구성된 Oracle API for MongoDB 연결 문자열이 함께 제공됩니다. 자세한 내용은 Using Oracle Database API for MongoDB을 참조하십시오. 대상이 온프레미스 Oracle Database인 경우 Oracle Rest Data Services를 사용하여 온프레미스 Oracle Database에서 Oracle Database API for MongoDB를 사용으로 설정할 수 있습니다.

시작하기 전에

이 빠른 시작을 성공적으로 완료하려면 다음이 있는지 확인하십시오.

  • MongoDB 소스, 버전 5 이상
  • OCI GoldenGate Big Data 배포 버전 23.7 이상을 생성
  • MongoDB Mongodump 및 Mongostore, 설치 및 PATH 환경 변수에 추가된 각 디렉토리 경로를 포함한 데이터베이스 도구

이전 설정 및 실행

  1. 소스 MongoDB에서 MongoDB 덤프 유틸리티를 실행합니다.
    1. mongodump--oplog 옵션과 함께 실행하여 소스 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. mongodump가 있는 동일한 디렉토리에서 소스 MongoDB의 OplongLSN.sh 스크립트를 실행하여 다음과 같이 위치를 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단계에서 얻은 마지막 작업 시간 기록(마지막 LSN)으로 설정하거나 oplog.bson 및 마지막 LSN에 대한 경로를 자동으로 가져옵니다. 이렇게 하면 Replicat가 oplong-replay 모드로 실행되어 충돌을 방지하고 데이터 손실이나 복제 없이 정확한 시작을 보장합니다. 마지막 시간 기록이 처리된 후 Replicat는 일반 모드로 계속됩니다.

권고 사항

다음은 원활한 마이그레이션을 보장하기 위한 몇 가지 팁입니다.

  • mongodb-database-tools 버전 100.10.0 이하를 사용하는 것이 좋습니다.
  • mongodump를 실행하기 전에 기존 덤프 폴더를 정리하여 불일치 데이터를 삭제합니다.
  • MongoDB 복원: mongorestore 명령의 여러 --nsInclude 옵션을 사용하여 여러 데이터베이스 모음을 복제할 수 있습니다. 그러나 ORDS 다중 데이터베이스는 다중 --nsInclude 명령을 사용하여 복원할 수 없습니다. 복원할 각 데이터베이스에 대해 하나씩 여러 개의 복원 명령을 사용해야 합니다.