다운타임 없이 MongoDB를 Oracle AI Database로 마이그레이션
다운타임 없이 OCI GoldenGate to MongoDB to Oracle AI Database를 사용하는 방법을 확인해 보세요.
OCI GoldenGate Big Data는 다운타임 없이 MongoDB 및 MongoDB Atlas에서 다음 대상으로의 마이그레이션을 지원합니다.
-
Oracle 자율운영 AI JSON 데이터베이스
-
Oracle 자율운영 AI 데이터베이스
-
Oracle AI Database
자율운영 AI JSON 데이터베이스 및 자율운영 AI 데이터베이스에는 OCI GoldenGate가 대상 Oracle AI Database 시스템에 연결하는 데 사용하는 MongoDB용 사전 구성된 Oracle API 연결 문자열이 제공됩니다. 자세한 내용은 Using Oracle AI Database API for MongoDB을 참조하십시오.
대상이 온프레미스 Oracle AI Database인 경우 Oracle Rest Data Services를 사용하여 온프레미스 Oracle AI Database에서 MongoDB용 Oracle AI Database API를 사용으로 설정할 수 있습니다.
시작하기 전에
이 빠른 시작을 성공적으로 완료하려면 다음이 있는지 확인하십시오.
-
MongoDB 소스, 버전 5 이상
-
OCI GoldenGate Big Data 배치, 버전 23.7 이상을 생성
-
MongoDB 데이터베이스 도구(몽고 덤프 및 몽고스토어 포함), 설치 및 PATH 환경 변수에 추가된 각각의 디렉토리 경로
이전 설정 및 실행
-
소스 MongoDB에서 MongoDB 덤프 유틸리티를 실행합니다.
-
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를 만듭니다. -
oplog.bson파일(이진 형식)의 내용을 검사하려면 bsondump 유틸리티를 사용하여 JSON으로 변환할 수 있습니다.$ ./bin/bsondump --pretty --outFile /path/to/oplog.json dump/oplog.bson이 명령은 다음을 반환합니다.
<date+timestamp> 7 objects found
-
-
oplong.bson에서 첫번째 및 마지막 작업 시간 기록을 추출합니다.-
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 -
Oplog 항목을 검사합니다. 덤프 중 들어오는 작업이 있는 경우
oplog.bson파일에는 각 작업에 대한 항목이 시간 기록이 포함된 항목이 포함됩니다.OplogLSN.sh를 사용하여 첫 번째 및 마지막 작업 시간 기록을 캡처하거나 이전 단계에 표시된 것처럼 수동 검사를 위해 JSON 파일로 변환할 수 있습니다.
-
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입니다.
-
MongoDB용 소스 Big Data 배치에서 CDC(변경 데이터 캡처) 추출을 생성 및 실행합니다. 2b단계에서 얻은 첫번째 작업 시간 기록(첫번째 LSN)에서 MongoDB CDC Extract를 시작합니다. 이렇게 하면 CDC Extract가 덤프 프로세스 시작 후 발생하는 작업을 캡처합니다.
-
-
4단계에서 생성된 CDC 추적 파일을 사용합니다.
-
oplongReplayLastLsn를 2b단계에서 얻은 마지막 작업 시간 기록(마지막 LSN)으로 설정하거나oplog.bson및 마지막 LSN에 대한 경로를 자동으로 가져옵니다. 이렇게 하면 Replicat가oplong-replay모드로 실행되어 충돌을 방지하고 데이터 손실이나 복제 없이 정확한 시작을 보장합니다. 마지막 시간 기록이 처리된 후 Replicat는 일반 모드로 계속됩니다.
-
권고 사항
다음은 원활한 마이그레이션을 위한 몇 가지 팁입니다.
-
mongodb-database-tools버전 100.10.0 이하를 사용하는 것이 좋습니다. -
mongodump를 실행하기 전에 기존 덤프 폴더를 정리하여 불일치 데이터를 삭제합니다. -
MongoDB 복원:
mongorestore명령에서 여러--nsInclude옵션을 사용하여 여러 데이터베이스 모음을 복제할 수 있습니다. 그러나 여러--nsInclude명령을 사용하여 ORDS 다중 데이터베이스를 복원할 수는 없습니다. 복원할 각 데이터베이스에 대해 하나씩 여러 개의 복원 명령을 사용해야 합니다.