동일한 리전의 클라우드 데이터베이스 간에 데이터 복제

두 자율운영 데이터베이스 간에 데이터를 복제하도록 Oracle Cloud Infrastructure GoldenGate를 설정하는 방법을 알아봅니다.

개요

Oracle Cloud Infrastructure GoldenGate를 사용하면 동일한 리전 내에서 지원되는 데이터베이스를 복제할 수 있습니다. 다음 단계에서는 Oracle Data Pump를 사용하여 Target Database를 instantiate하고 소스에서 대상으로 데이터를 복제하는 방법을 설명합니다.

이 빠른 시작은 LiveLab으로도 제공됩니다. 워크샵 보기

다음은 same-region.png에 대한 설명입니다.
그림 same-region.png에 대한 설명

시작하기 전에

계속하려면 다음이 있어야 합니다.

작업 1: 환경 설정

  1. 데이터 복제 배치를 생성합니다.
  2. 소스 Oracle Autonomous Transaction Processing(ATP) 접속을 생성합니다.
  3. 대상 ADW(Autonomous Data Warehouse) 연결을 생성합니다.
  4. 배포에 대한 접속을 지정합니다.
  5. Autonomous Database SQL 도구를 사용하여 보완 로깅 활성화:
    ALTER DATABASE ADD SUPPLEMENTAL LOG DATA
  6. SQL 툴에서 다음 query를 실행하여 원본 데이터베이스의 모든 테이블에 대해 support_mode=FULL를 확인합니다.
    
    select * from DBA_GOLDENGATE_SUPPORT_MODE where owner = 'SRC_OCIGGLL';

작업 2: 통합 추출 생성

통합 Extract는 소스 데이터베이스에 대한 지속적인 변경사항을 캡처합니다.

  1. 배포 세부정보 페이지에서 콘솔 실행을 누릅니다.
  2. 필요한 경우 사용자 이름에 oggadmin을 입력하고 배치를 생성할 때 사용한 비밀번호를 입력한 다음 사인인을 누릅니다.
  3. 트랜잭션 데이터 및 체크포인트 테이블 추가:
    1. 탐색 메뉴를 열고 DB 접속을 누릅니다.
    2. 데이터베이스에 접속 SourceATP을 누릅니다.
    3. 탐색 메뉴에서 Trandata를 누른 다음 Trandata 추가(더하기 아이콘)를 누릅니다.
    4. 스키마 이름에 대해 SRC_OCIGGLL을 입력한 다음 제출을 누릅니다.
    5. 확인하려면 검색 필드에 SRC_OCIGGLL을 입력하고 검색을 누릅니다.
    6. 탐색 메뉴를 열고 DB 접속을 누릅니다.
    7. 데이터베이스에 접속 TargetADW을 누릅니다.
    8. 탐색 메뉴에서 체크포인트를 누른 다음 체크포인트 추가(더하기 아이콘)를 누릅니다.
    9. 체크포인트 테이블에 대해 "SRCMIRROR_OCIGGLL"."CHECKTABLE"을 입력한 다음 제출을 누릅니다.
  4. 추출 추가.

    주:

    소스 테이블을 지정하는 데 사용할 수 있는 매개변수에 대한 자세한 내용은 추가 추출 매개변수 옵션을 참조하십시오.
    [매개변수 추출] 페이지에서 EXTTRAIL <trail-name> 아래에 다음 행을 추가합니다.
    -- Capture DDL operations for listed schema tables
    ddl include mapped
    
    -- Add step-by-step history of 
    -- to the report file. Very useful when troubleshooting.
    ddloptions report 
    
    -- Write capture stats per table to the report file daily.
    report at 00:01 
    
    -- Rollover the report file weekly. Useful when IE runs
    -- without being stopped/started for long periods of time to
    -- keep the report files from becoming too large.
    reportrollover at 00:01 on Sunday 
    
    -- Report total operations captured, and operations per second
    -- every 10 minutes.
    reportcount every 10 minutes, rate 
    
    -- Table list for capture
    table SRC_OCIGGLL.*;
  5. 장기 실행 중인 트랜잭션을 확인합니다. 소스 데이터베이스에서 다음 스크립트를 실행합니다.
    select start_scn, start_time from gv$transaction where start_scn < (select max(start_scn) from dba_capture);

    query가 행을 반환하면 트랜잭션의 SCN을 찾은 다음 트랜잭션을 커밋하거나 롤백해야 합니다.

작업 3: Oracle Data Pump를 사용하여 데이터 엑스포트(ExpDP)

Oracle Data Pump(ExpDP)를 사용하여 원본 데이터베이스에서 Oracle Object Store로 데이터를 엑스포트합니다.

  1. Oracle Object Store 버킷을 생성합니다.

    Export 및 Import 스크립트에 사용할 네임스페이스와 버킷 이름을 기록해 두십시오.

  2. 인증 토큰을 생성한 다음 나중에 사용할 수 있도록 토큰 문자열을 복사하여 텍스트 편집기에 붙여 넣습니다.
  3. 소스 데이터베이스에서 <user-name><token>을 이전 단계에서 생성한 Oracle Cloud 계정 사용자 이름 및 토큰 문자열로 바꾸어 인증서를 생성합니다.
    BEGIN
      DBMS_CLOUD.CREATE_CREDENTIAL(
        credential_name => 'ADB_OBJECTSTORE', 
        username => '<user-name>',
        password => '<token>'
      );
    END;
  4. 소스 데이터베이스에서 다음 스크립트를 실행하여 데이터 익스포트 작업을 생성합니다. 그에 따라 객체 저장소 URI에서 <region>, <namespace><bucket-name>를 바꿔야 합니다. SRC_OCIGGLL.dmp은 이 스크립트를 실행할 때 생성될 파일입니다.
    DECLARE
    ind NUMBER;              -- Loop index
    h1 NUMBER;               -- Data Pump job handle
    percent_done NUMBER;     -- Percentage of job complete
    job_state VARCHAR2(30);  -- To keep track of job state
    le ku$_LogEntry;         -- For WIP and error messages
    js ku$_JobStatus;        -- The job status from get_status
    jd ku$_JobDesc;          -- The job description from get_status
    sts ku$_Status;          -- The status object returned by get_status
    
    BEGIN
    -- Create a (user-named) Data Pump job to do a schema export.
    h1 := DBMS_DATAPUMP.OPEN('EXPORT','SCHEMA',NULL,'SRC_OCIGGLL_EXPORT','LATEST');
    
    -- Specify a single dump file for the job (using the handle just returned
    -- and a directory object, which must already be defined and accessible
    -- to the user running this procedure.
    DBMS_DATAPUMP.ADD_FILE(h1,'https://objectstorage.<region>.oraclecloud.com/n/<namespace>/b/<bucket-name>/o/SRC_OCIGGLL.dmp','ADB_OBJECTSTORE','100MB',DBMS_DATAPUMP.KU$_FILE_TYPE_URIDUMP_FILE,1);
    
    -- A metadata filter is used to specify the schema that will be exported.
    DBMS_DATAPUMP.METADATA_FILTER(h1,'SCHEMA_EXPR','IN (''SRC_OCIGGLL'')');
    
    -- Start the job. An exception will be generated if something is not set up properly.
    DBMS_DATAPUMP.START_JOB(h1);
    
    -- The export job should now be running. In the following loop, the job
    -- is monitored until it completes. In the meantime, progress information is displayed.
    percent_done := 0;
    job_state := 'UNDEFINED';
    while (job_state != 'COMPLETED') and (job_state != 'STOPPED') loop
      dbms_datapump.get_status(h1,dbms_datapump.ku$_status_job_error + dbms_datapump.ku$_status_job_status + dbms_datapump.ku$_status_wip,-1,job_state,sts);
      js := sts.job_status;
    
    -- If the percentage done changed, display the new value.
    if js.percent_done != percent_done
    then
      dbms_output.put_line('*** Job percent done = ' || to_char(js.percent_done));
      percent_done := js.percent_done;
    end if;
    
    -- If any work-in-progress (WIP) or error messages were received for the job, display them.
    if (bitand(sts.mask,dbms_datapump.ku$_status_wip) != 0)
    then
      le := sts.wip;
    else
      if (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0)
      then
        le := sts.error;
      else
        le := null;
      end if;
    end if;
    if le is not null
    then
      ind := le.FIRST;
      while ind is not null loop
        dbms_output.put_line(le(ind).LogText);
        ind := le.NEXT(ind);
      end loop;
    end if;
      end loop;
    
      -- Indicate that the job finished and detach from it.
      dbms_output.put_line('Job has completed');
      dbms_output.put_line('Final job state = ' || job_state);
      dbms_datapump.detach(h1);
    END;

작업 4: Oracle Data Pump를 사용하여 Target Database 인스턴스화(ImpDP)

Oracle Data Pump(ImpDP)를 사용하여 소스 데이터베이스에서 익스포트된 SRC_OCIGGLL.dmp에서 대상 데이터베이스로 데이터를 임포트합니다.

  1. 이전 섹션의 동일한 정보를 사용하여 Oracle Object Store에 액세스할 인증서를 대상 데이터베이스에 생성합니다.
    BEGIN
      DBMS_CLOUD.CREATE_CREDENTIAL( 
        credential_name => 'ADB_OBJECTSTORE',
        username => '<user-name>',
        password => '<token>'
      );
    END;
  2. 대상 데이터베이스에서 다음 스크립트를 실행하여 SRC_OCIGGLL.dmp에서 데이터를 임포트합니다. 이에 따라 객체 저장소 URI에서 <region>, <namespace><bucket-name>를 바꿔야 합니다.
    DECLARE
    ind NUMBER;  -- Loop index
    h1 NUMBER;  -- Data Pump job handle
    percent_done NUMBER;  -- Percentage of job complete
    job_state VARCHAR2(30);  -- To keep track of job state
    le ku$_LogEntry;  -- For WIP and error messages
    js ku$_JobStatus;  -- The job status from get_status
    jd ku$_JobDesc;  -- The job description from get_status
    sts ku$_Status;  -- The status object returned by get_status
    BEGIN
    
    -- Create a (user-named) Data Pump job to do a "full" import (everything
    -- in the dump file without filtering).
    h1 := DBMS_DATAPUMP.OPEN('IMPORT','FULL',NULL,'SRCMIRROR_OCIGGLL_IMPORT');
    
    -- Specify the single dump file for the job (using the handle just returned)
    -- and directory object, which must already be defined and accessible
    -- to the user running this procedure. This is the dump file created by
    -- the export operation in the first example.
    
    DBMS_DATAPUMP.ADD_FILE(h1,'https://objectstorage.<region>.oraclecloud.com/n/<namespace>/b/<bucket-name>/o/SRC_OCIGGLL.dmp','ADB_OBJECTSTORE',null,DBMS_DATAPUMP.KU$_FILE_TYPE_URIDUMP_FILE);
    
    
    -- A metadata remap will map all schema objects from SRC_OCIGGLL to SRCMIRROR_OCIGGLL.
    DBMS_DATAPUMP.METADATA_REMAP(h1,'REMAP_SCHEMA','SRC_OCIGGLL','SRCMIRROR_OCIGGLL');
    
    -- If a table already exists in the destination schema, skip it (leave
    -- the preexisting table alone). This is the default, but it does not hurt
    -- to specify it explicitly.
    DBMS_DATAPUMP.SET_PARAMETER(h1,'TABLE_EXISTS_ACTION','SKIP');
    
    -- Start the job. An exception is returned if something is not set up properly.
    DBMS_DATAPUMP.START_JOB(h1);
    
    -- The import job should now be running. In the following loop, the job is
    -- monitored until it completes. In the meantime, progress information is
    -- displayed. Note: this is identical to the export example.
    percent_done := 0;
    job_state := 'UNDEFINED';
    while (job_state != 'COMPLETED') and (job_state != 'STOPPED') loop
      dbms_datapump.get_status(h1,
        dbms_datapump.ku$_status_job_error +
        dbms_datapump.ku$_status_job_status +
        dbms_datapump.ku$_status_wip,-1,job_state,sts);
        js := sts.job_status;
    
      -- If the percentage done changed, display the new value.
      if js.percent_done != percent_done
      then
        dbms_output.put_line('*** Job percent done = ' ||
        to_char(js.percent_done));
        percent_done := js.percent_done;
      end if;
    
      -- If any work-in-progress (WIP) or Error messages were received for the job, display them.
      if (bitand(sts.mask,dbms_datapump.ku$_status_wip) != 0)
      then
        le := sts.wip;
      else
        if (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0)
        then
          le := sts.error;
        else
          le := null;
        end if;
      end if;
      if le is not null
      then
        ind := le.FIRST;
        while ind is not null loop
          dbms_output.put_line(le(ind).LogText);
          ind := le.NEXT(ind);
        end loop;
      end if;
    end loop;
    
    -- Indicate that the job finished and gracefully detach from it.
    dbms_output.put_line('Job has completed');
    dbms_output.put_line('Final job state = ' || job_state);
    dbms_datapump.detach(h1);
    END;

작업 5: 비통합 복제 추가 및 실행

  1. Replicat 추가 및 실행.
    Parameter File 화면에서 MAP *.*, TARGET *.*;을 다음 스크립트로 바꿉니다.
    -- Capture DDL operations for listed schema tables
    --
    ddl include mapped
    --
    -- Add step-by-step history of ddl operations captured
    -- to the report file. Very useful when troubleshooting.
    --
    ddloptions report
    --
    -- Write capture stats per table to the report file daily.
    --
    report at 00:01
    --
    -- Rollover the report file weekly. Useful when PR runs
    -- without being stopped/started for long periods of time to
    -- keep the report files from becoming too large.
    --
    reportrollover at 00:01 on Sunday
    --
    -- Report total operations captured, and operations per second
    -- every 10 minutes.
    --
    reportcount every 10 minutes, rate
    --
    -- Table map list for apply
    --
    DBOPTIONS ENABLE_INSTANTIATION_FILTERING;
    MAP SRC_OCIGGLL.*, TARGET SRCMIRROR_OCIGGLL.*;

    주:

    DBOPTIONS ENABLE_INSTATIATION_FILTERING는 Oracle Data Pump를 사용하여 임포트한 테이블에 대해 CSN 필터링을 활성화합니다. 자세한 내용은 DBOPTIONS Reference를 참조하십시오.
  2. 소스 데이터베이스에 삽입 수행:
    1. Oracle Cloud 콘솔로 돌아가서 탐색 메뉴를 사용하여 Oracle Database, Autonomous Transaction Processing, SourceATP으로 돌아갑니다.
    2. 소스 ATP 세부정보 페이지에서 도구, 데이터베이스 작업 순으로 누릅니다.
    3. 워크샵 세부정보에서 소스 ATP 데이터베이스 인증서를 사용하여 데이터베이스 작업에 로그인한 다음 SQL을 누릅니다.
    4. 다음 삽입을 입력한 후 스크립트 실행을 누릅니다.
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1000,'Houston',20,743113);
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1001,'Dallas',20,822416);
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1002,'San Francisco',21,157574);
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1003,'Los Angeles',21,743878);
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1004,'San Diego',21,840689);
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1005,'Chicago',23,616472);
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1006,'Memphis',23,580075);
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1007,'New York City',22,124434);
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1008,'Boston',22,275581);
      Insert into SRC_OCIGGLL.SRC_CITY (CITY_ID,CITY,REGION_ID,POPULATION) values (1009,'Washington D.C.',22,688002);
    5. OCI GoldenGate 배치 콘솔에서 추출 이름(UAEXT)을 누른 다음 통계를 누릅니다. SRC_OCIGGLL.SRC_CITY이 10개의 삽입과 함께 나열되는지 확인합니다.
    6. Overview 화면으로 돌아가서 Replicat name (REP)을 누른 다음 Statistics를 누릅니다. SRCMIRROR_OCIGGLL.SRC_CITY이 10개의 삽입과 함께 나열되는지 확인합니다.

작업 6: 프로세스 모니터 및 유지 관리

  1. 복제 프로세스를 모니터링합니다.
  2. 추적 파일 관리.