주:

OCI를 사용하여 온프레미스 MySQL Database를 Oracle HeatWave MySQL 관리 인스턴스로 마이그레이션 GoldenGate

소개

Oracle Cloud Infrastructure GoldenGate(OCI GoldenGate)는 데이터 엔지니어가 하나 이상의 데이터 관리 시스템에서 OCI 데이터베이스로 데이터를 실시간으로 대규모로 이동할 수 있도록 지원하는 완전 관리형 서비스입니다. 컴퓨팅 환경을 할당하거나 관리할 필요 없이 단일 인터페이스에서 데이터 복제 작업을 설계, 실행, 통합관리 및 모니터링할 수 있습니다. OCI GoldenGate는 MySQL 및 Oracle HeatWave MySQL 데이터베이스 서비스를 포함한 여러 소스 및 대상을 지원합니다.

이 자습서에서는 OCI GoldenGate를 사용하여 온프레미스 MySQL 데이터베이스를 Oracle HeatWave MySQL 관리 인스턴스로 마이그레이션하는 방법을 안내합니다.

목표

필요 조건

제한

작업 1: 소스 및 대상 MySQL 인스턴스 생성

작업 2: 배스천, 온프레미스 및 Oracle Heatwave MySQL 인스턴스 간 연결 테스트

  1. OCI 배스천 호스트에 MySQL 클라이언트 및 MySQL Shell 유틸리티를 설치합니다.

  2. OCI 배스천에서 소스 온프레미스 MySQL 인스턴스로의 접속을 테스트합니다.

    [root@bastion ~]#  mysql --host <sourceIP> -uadmin -p
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 15
    Server version: 5.7.44 MySQL Community Server (GPL)
    
    Copyright (c) 2000, 2025, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+
    4 rows in set (0.00 sec)
    
    mysql> select @@version;
    +-----------+
    | @@version |
    +-----------+
    | 5.7.44    |
    +-----------+
    1 row in set (0.00 sec)
    
  3. 소스 온프레미스 MySQL에서 Oracle Heatwave MySQL 관리 인스턴스로의 연결을 테스트합니다.

    [root@mysqlci57 ~]# mysql --host <targetIP> -u admin -p
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 108
    Server version: 8.4.4-u5-cloud MySQL Enterprise - Cloud
    
    Copyright (c) 2000, 2023, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> select @@version;
    +----------------+
    | @@version      |
    +----------------+
    | 8.4.4-u5-cloud |
    +----------------+
    1 row in set (0.01 sec)
    

작업 3: OCI에 대한 사용자 생성 GoldenGate

작업 4: OCI에 대한 소스 데이터베이스에서 필수 매개변수 설정 GoldenGate

대상이 HA가 아닌 독립형인 경우 소스에서 GTID를 설정할 필요가 없습니다. 그러나 대상이 HA인 경우 소스에서 GTID를 설정하는 것이 좋습니다. binlog 모드를 켜야 합니다.

  1. /etc/my.cnf 파일을 편집하고 다음 행을 추가합니다.

    server-id=1
    log-bin=/var/log/mysql/mysql-bin.log
    max_binlog_size=100M
    binlog_format=ROW
    expire_logs_days=10
    -- binlog_row_metadata=FULL <-- this is not supported in Version 5.7.44. So DDL replication will not be possible if source is on v5.7.44.
    gtid_mode=ON
    enforce_gtid_consistency=ON
    
  2. MySQL 서버를 다시 시작합니다.

    Systemctl stop mysqld
    Systemctl start mysqld
    Systemctl status mysqld
    

    전체 목록 또는 매개변수는 트랜잭션 로그 설정 및 요구사항을 확인하십시오. 자세한 내용은 옵션 B: OCI 컴퓨트에서 자체 배스천 사용을 참조하십시오.

  3. 다음 명령을 실행하여 지금 이진 로그가 사용으로 설정되었는지 확인합니다.

    mysql> show binary logs;
    +------------------+-----------+
    | Log_name         | File_size |
    +------------------+-----------+
    | mysql-bin.000001 |       154 |
    +------------------+-----------+
    1 row in set (0.00 sec)
    
    mysql> show variables like 'bin%';
    +--------------------------------------------+--------------+
    | Variable_name                              | Value        |
    +--------------------------------------------+--------------+
    | bind_address                               | *            |
    | binlog_cache_size                          | 32768        |
    | binlog_checksum                            | CRC32        |
    | binlog_direct_non_transactional_updates    | OFF          |
    | binlog_error_action                        | ABORT_SERVER |
    | binlog_format                              | ROW          |
    | binlog_group_commit_sync_delay             | 0            |
    | binlog_group_commit_sync_no_delay_count    | 0            |
    | binlog_gtid_simple_recovery                | ON           |
    | binlog_max_flush_queue_time                | 0            |
    | binlog_order_commits                       | ON           |
    | binlog_row_image                           | FULL         |
    | binlog_rows_query_log_events               | OFF          |
    | binlog_stmt_cache_size                     | 32768        |
    | binlog_transaction_dependency_history_size | 25000        |
    | binlog_transaction_dependency_tracking     | COMMIT_ORDER |
    +--------------------------------------------+--------------+
    16 rows in set (0.01 sec)
    
  4. 다음 명령을 실행하여 GTID 모드(gtid_mode)가 켜져 있는지 확인합니다.

    mysql> show variables like 'gtid%';
    +----------------------------------+-----------+
    | Variable_name                    | Value     |
    +----------------------------------+-----------+
    | gtid_executed_compression_period | 1000      |
    | gtid_mode                        | ON        |   <--- it is now showing ON
    | gtid_next                        | AUTOMATIC |
    | gtid_owned                       |           |
    | gtid_purged                      |           |
    +----------------------------------+-----------+
    5 rows in set (0.00 sec)
    
    mysql> select @@gtid_executed, @@gtid_purged\G
    *************************** 1. row ***************************
    @@gtid_executed:
      @@gtid_purged:
    1 row in set, 1 warning (0.00 sec)
    
    mysql> select * from mysql.gtid_executed;
    Empty set (0.00 sec)   <--- this is empty because we just turned it ON. As transactions occur this will get populated
    

주: 첫번째 query는 GTID에 대해 NULL 값을 표시하는 것이 일반적입니다. 이는 MySQL versions 5.7에서 GTID 값이 mysql.gtid_executed 테이블에만 저장되기 때문입니다.

작업 5: 대상 데이터베이스에서 airportdb 스키마(메타 데이터만 해당) 생성

  1. 소스 데이터베이스에서 스키마 메타 데이터를 추출합니다.

    [root@bastion airport-db]# mysqldump --host <SourceIP> -u admin -p --no-data --routines --events airportdb > airportdb.sql
    mysqldump: [Warning] Using a password on the command line interface can be insecure.
    -- Warning: column statistics not supported by the server.
    
  2. 스키마 메타 데이터를 Target Database로 임포트합니다.

    [root@bastion opc]#  mysql --host <TargetIP> -u admin -p
    mysql: [Warning] Using a password on the command line interface can be insecure.
    Welcome to the MySQL monitor.  Commands end with ; or \g.
    Your MySQL connection id is 581
    Server version: 8.4.4-u5-cloud MySQL Enterprise - Cloud
    
    Copyright (c) 2000, 2025, Oracle and/or its affiliates.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
    
    mysql> create database airportdb;
    Query OK, 1 row affected (0.01 sec)
    
    mysql> use airportdb;
    Database changed
    mysql> source airportdb.sql
    

작업 6: OCI GoldenGate 배치 설정 및 접속 추가

몇 가지 블로그, OCI GoldenGate 배포 설정 방법에 대한 자습서가 있으므로 몇 가지 단계를 보여드리겠습니다.

  1. OCI 콘솔에 로그인하고 GoldenGate Deployments를 선택합니다.

  2. 배포 생성을 누르고 다음 이미지에 표시된 대로 필요한 정보를 입력합니다.

    Golden Gate 배치 생성 방법을 보여주는 이미지

  3. 배포 생성 페이지에서 소스 및 대상 접속 세부정보를 추가합니다.

    소스에 대한 Golden Gate 접속을 생성하는 방법을 보여주는 이미지

    대상에 대한 골든 게이트 접속을 생성하는 방법을 보여주는 이미지

    GG에 추가된 두 연결을 보여주는 이미지

  4. OCI GoldenGate 배포에 연결을 지정합니다. 접속 이름을 누른 다음 배포 지정을 누릅니다.

    접속에 배치를 지정하는 방법을 보여주는 이미지

    배포에 지정된 소스 연결을 보여주는 이미지

    배치에 지정된 대상 접속을 보여주는 이미지

  5. OCI 배스천 서비스를 사용하여 포트 443에 대한 포트 전달을 설정한 다음 OCI GoldenGate 콘솔에 로그인합니다.

    goldengate 홈 페이지 URL을 보여주는 이미지

  6. OCI GoldenGate 콘솔에서 데이터베이스 접속을 검증합니다.

    1. 햄버거 메뉴를 누르면 작업 6.4에서 배치에 추가된 두 개의 연결이 표시됩니다.

    2. 연결을 눌러 접속을 검증합니다. 접속이 성공하면 체크포인트 +를 눌러 체크포인트 테이블을 생성하는 옵션이 표시됩니다.

      OCI에서 OCI GoldenGate 배치를 사용하여 접속을 추가하는 것이 좋습니다. 그러면 IP 주소에 DNS가 자동으로 추가되므로, 이러한 DNS가 없으면 테스트 접속이 실패합니다.

      Goldengate 연결 및 테스트 연결을 보여주는 이미지

작업 7: Extract 및 Replicat 프로세스 생성

  1. 추출 프로세스를 생성하기 전에 소스 데이터베이스(특히 대상이 HA인 경우)에서 gtid_modeON인지 확인합니다.

    다음 두 가지 방법으로 Extract를 추가할 수 있습니다.

    • 방법 1: 초기 로드(복사 또는 덤프 인스턴스)가 완료된 후 Extract를 추가하고 정확한 인스턴스화 방법을 사용할 수 있습니다. 자세한 내용은 Precise Instantiation for MySQL to MySQL Using MySQL Shell Utilities and Oracle GoldenGate을 참조하십시오.

      Extract를 추가하고 시작하려면 다음 이미지와 같이 특정 GTID 또는 binlog에서 데이터 캡처를 수행합니다. Oracle은 이 방법을 사용할 것을 권장합니다.

      goldengate Extract 설정을 보여주는 이미지

      주: 여기서 GTID 세트는 dumpInstance의 JSON 파일 또는 copyInstance 명령의 출력에서 가져옵니다.

    • 방법 2: 초기 데이터 로드를 시작하기 전에 처음부터 Extract를 추가한 후 나중에 dumpInstance()의 JSON 파일 또는 copyInstance()의 출력에 표시되는 특정 gtidexecuted/binlog# 및 binlog 위치로 시작하도록 Replicat를 변경할 수 있습니다.

      데이터 중복 문제를 방지하려면 이 메소드에 HANDLECOLLISION 매개변수를 사용하십시오.

      주: 이 POC의 경우 메소드 2가 사용되었습니다.

      추출 매개변수 파일 편집:

      EXTRACT ext1
      USERIDALIAS  MySQLCI57, DOMAIN OracleGoldenGate
      EXTTRAIL e1
      --DDL INCLUDE MAPPED  (needed for DDL replication, also need to set  binlog_row_metadata to FULL in mysql config file on source db). But not supported for MySQL V5.7
      TRANLOGOPTIONS FETCHPARTIALJSON       (for JSON replication, also need to set binlog_row_value_options to empty string in the mysql config)
      TABLE airportdb.*;
      

      주: Extract 매개변수 파일에 DDL INCLUDE MAPPED을 추가하면 MySQL version 5.7.4에 대해 DDL 복제가 지원되지 않는다는 오류가 표시됩니다.

  2. Extract 프로세스를 시작합니다.

    goldengate Extract 실행을 보여주는 이미지

  3. Extract가 실행 중이며 트레일 파일을 생성하고 있습니다. 이제 Replicat를 생성하십시오.

    1. 먼저 체크포인트 테이블을 생성합니다. 구성 섹션으로 이동하여 대상 데이터베이스를 선택하고 체크포인트 +를 눌러 체크포인트 테이블을 생성합니다.

      GoldenGate 체크포인트 테이블 생성을 보여주는 이미지

    2. Replicat 프로세스를 생성합니다. 단방향 복제이므로 성능 향상을 위해 병렬 Replicat를 사용할 수 있습니다. 양방향 복제의 경우 클래식 Replicat만 지원됩니다.

      Replicat 프로세스를 시작하지 말고 생성만 하면 됩니다. 데이터를 가져온 후에 시작합니다.

      goldengate 복제본 생성을 보여주는 이미지

    3. 파라미터 파일을 편집합니다. PARALLEL 매개변수를 추가하거나 기본 병렬화가 사용될 수도 있습니다.

      REPLICAT rep1
      USERIDALIAS  MySQLGG1, DOMAIN OracleGoldenGate
      MAP airportdb.*, TARGET airportdb.*;
      

작업 8: copyInstance()를 사용하여 소스에서 대상으로 데이터 복사

  1. copyInstance()dryRun:"true" 옵션을 사용하여 dry run을 수행합니다.

    Type '\help' or '\?' for help; '\quit' to exit.
    MySQL  SQL > \connect admin@<Source IP>
    Creating a session to 'admin@<Source IP>'
    Fetching global names for auto-completion... Press ^C to stop.
    Your MySQL connection id is 37
    Server version: 5.7.44-log MySQL Community Server (GPL)
    No default schema selected; type \use <schema> to set one.
     MySQL  <Source IP>:3306 ssl  SQL > \js
    Switching to JavaScript mode...
     MySQL  <Source IP>:3306 ssl  JS > util.copyInstance('mysql://admin@<Target IP>', {"compatibility":["skip_invalid_accounts","strip_definers","strip_restricted_grants","strip_tablespaces","ignore_wildcard_grants","strip_invalid_grants","create_invisible_pks"], users:"true", threads:2, dryRun:"true"});
    Please provide the password for 'admin@<target IP': *******************
    Save password for 'admin@<target IP>'? [Y]es/[N]o/Ne[v]er (default No):
    
  2. 오류가 없는 경우 dryRun 옵션을 제거하고 다시 실행하여 데이터 로드를 수행합니다. 최종 출력은 No errors reported와 같아야 합니다.

    SRC: Starting data dump
    100% (59.50M rows / ~59.36M rows), 142.25K rows/s, 9.68 MB/s
    SRC: Dump duration: 00:07:50s
    SRC: Total duration: 00:07:50s
    SRC: Schemas dumped: 2
    SRC: Tables dumped: 15
    SRC: Data size: 2.03 GB
    SRC: Rows written: 59502422
    SRC: Bytes written: 2.03 GB
    SRC: Average throughput: 4.33 MB/s
    1 thds indexing \ 100% (2.03 GB / 2.03 GB), 7.47 MB/s (161.06K rows/s), 15 / 15 tables done
    Building indexes - done
    Executing common postamble SQL - done
    TGT: 53 chunks (59.50M rows, 2.03 GB) for 15 tables in 2 schemas were loaded in 7 min 51 sec (avg throughput 4.32 MB/s, 126.29K rows/s)
    TGT: 17 DDL files were executed in 0 sec.
    TGT: 0 accounts were loaded, 3 accounts failed to load due to unsupported authentication plugin errors
    TGT: Data load duration: 7 min 51 sec
    TGT: 1 indexes were built in 0 sec.
    TGT: Total duration: 7 min 51 sec
    TGT: 0 warnings were reported during the load.
    ..
    ..
    Dump_metadata:
    Binlog_file: mysql-bin.000006
    Binlog_position: 626
    Executed_GTID_set: 7ee61c32-16eb-11f0-b3fc-02001702dcb5:1-3
    

주: copyInstance()의 출력에 표시된 실행된 GTID를 기록하고 이를 사용하여 Replicat를 변경합니다.

작업 9: Replicat 변경 및 시작

작업 8의 copyInstance() 출력에 표시된 대로 로그 파일 번호(000006)와 로그 위치 번호(626)를 사용합니다. 이 로그 파일 및 로그 위치는 CSN 000006:000000000000626을 생성하는 형식으로 사용해야 합니다.

Replicat를 변경하고 시작을 눌러 시작합니다. 복제 변경 방법을 보여주는 이미지

실행 중으로 표시되는 Replicat 상태입니다.

복제 상태를 보여주는 이미지

주: 태스크 7에 표시된 대로 Extract를 추가하는 데 메소드 1을 사용한 경우 Replicat를 변경할 필요가 없습니다. 이 POC에서는 방법 2를 사용하여 Extract를 추가했습니다. 두 방법 모두 잘 작동합니다.

작업 10: DML 테스트 실행

소스에서 DML 작업을 수행하여 복제를 테스트합니다.

승인

추가 학습 자원

docs.oracle.com/learn에서 다른 랩을 탐색하거나 Oracle Learning YouTube 채널에서 더 많은 무료 학습 콘텐츠에 액세스하세요. 또한 education.oracle.com/learning-explorer를 방문하여 Oracle Learning Explorer가 되십시오.

제품 설명서는 Oracle Help Center를 참조하십시오.