MySQL을 소스로 사용하면 AWS DMS CDC 작업이 실패하고 1236 오류가 발생하는데 그 이유가 무엇인가요?

7분 분량
0

AWS Database Migration Service(AWS DMS)를 사용하여 데이터를 소스 MySQL 데이터베이스 엔진에서 대상 엔진으로 마이그레이션하고 있습니다. 그런데 작업이 실패하고 1236 오류가 발생합니다. 이 문제를 해결하려면 어떻게 해야 하나요?

간략한 설명

AWS DMS를 사용하면 일회성 마이그레이션을 수행할 수 있고, 지속적으로 발생하는 변경 사항을 복제하여 소스와 대상이 동기화된 상태를 유지할 수 있습니다. AWS DMS는 소스 데이터베이스에서 진행 중인 변경 사항을 읽기 위해 엔진별 API 작업을 사용해 소스 엔진의 트랜잭션 로그에서 변경 사항을 읽어 옵니다. MySQL을 소스로 사용하는 경우, AWS DMS는 행 기반 이진 로그(binlog)에서 변경 사항을 읽습니다. 그런 다음 AWS DMS가 그러한 변경 사항을 대상으로 마이그레이션합니다.

오류 1236이 발생하는 이유는 이진 로그에 문제가 있기 때문입니다. 따라서 문제를 해결하기 전에 우선 모든 이진 로깅 파라미터가 AWS DMS CDC를 지원하도록 올바로 구성되었는지 확인해야 합니다. 자세한 정보는 AWS DMS에 자체 관리형 MySQL 호환 데이터베이스를 소스로 사용AWS DMS에 AWS 관리형 MySQL 호환 데이터베이스를 소스로 사용을 참조하세요.

해결 방법

오류의 근본 원인에 따라 아래와 같은 단계를 따릅니다.

binlog를 읽던 중 오류 1236 발생(이진 로그 인덱스 파일에서 첫 번째 로그 파일 이름을 찾을 수 없음)

작업 로그에서 오류 발생

[SOURCE_CAPTURE  ]I: Setting position in binlog 'mysql-bin-changelog.014448' at 119624570  (mysql_endpoint_capture.c:886)
[SOURCE_CAPTURE  ]I: Position was set in binlog 'mysql-bin-changelog.014448' at 119624570  (mysql_endpoint_capture.c:922)
[SOURCE_CAPTURE  ]E: Error 1236 (Could not find first log file name in binary log index file) reading binlog [1020493] 
[TASK_MANAGER    ]I: Task - ABCDXXXXXXXXXXXXXX is in ERROR state, updating starting status to AR_NOT_APPLICABLE

이 오류가 발생하면 AWS DMS가 대상에 데이터 변경 사항을 복제하는 데 쓰는 이진 로그가 소스 MySQL 데이터베이스에서 제거되었다는 뜻입니다. 이 오류는 다음의 두 가지 이유로 발생합니다.

  • 이진 로그의 보존 기간이 너무 짧습니다.
  • 문제가 생겨서 AWS DMS 작업이 멈추거나 중지되었습니다.

이진 로그를 이용할 수 있는지 아닌지 확인하려면 다음과 같은 명령을 실행합니다.

모든 이진 로그 파일 나열:

mysql> SHOW BINARY LOGS;

현재 이진 로그 파일 및 위치 나열:

mysql> SHOW MASTER STATUS;

이 오류를 해결하려면 우선 소스 MySQL 데이터베이스에서 이진 로그 보존 기간을 검토해야 합니다. 필요한 경우, 보존 기간을 늘립니다. AWS DMS 작업을 다시 시작하여 전체 로드 단계를 다시 실행합니다.

사용 중인 인스턴스의 유형에 따라 다음과 같은 단계를 따르세요.

자체 관리형 MySQL 데이터베이스 - 온프레미스 또는 Amazon Ealstic Compute Cloud(Amazon EC2)

expire_logs_days 값을 보고 이진 로그 보존 기간을 확인합니다. 이 파라미터는 전역 수준에서 값을 1 이상으로 설정하는 것이 가장 좋습니다.

AWS 관리형 MySQL 데이터베이스 - MySQL용 Amazon Relational Database Service(RDS) 또는 Amazon Aurora MySQL 호환 에디션

1.    mysql.rds_show_configuration 명령을 실행하여 MySQL 데이터베이스에 설정된 binlog 보존 시간을 확인합니다.

mysql> call mysql.rds_show_configuration;

2.    보존 기간을 24시간으로 늘리려면 mysql.rds_set_configuration 명령 실행을 실행합니다.

mysql> call mysql.rds_set_configuration('binlog retention hours', 24);

오류 1236(로그 이벤트 항목이 max_allowed_packet 초과, 마스터에서 max_allowed_packet 증가 등)

작업 로그에서 오류 발생

[SOURCE_CAPTURE  ]I:  Position was set in binlog 'mysql-bin.056367' at 787323674  (mysql_endpoint_capture.c:922)
[SOURCE_CAPTURE  ]D:  net_safe_read error 1236 (log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the first event 'mysql-bin.056367' at 787323674, the last event read from '/mnt/data/logs/mysql-bin.056367' at 123, the last byte read from '/mnt/data/logs/mysql-bin.056367' at 787323693.)  (mysql_endpoint_capture.c:1119)
[SOURCE_CAPTURE  ]I:  Error 1236 (log event entry exceeded max_allowed_packet; Increase max_allowed_packet on master; the first event 'mysql-bin.056367' at 787323674, the last event read from '/mnt/data/logs/mysql-bin.056367' at 123, the last byte read from '/mnt/data/logs/mysql-bin.056367' at 787323693.) reading binlog. Try reconnect  (mysql_endpoint_capture.c:1123)

이 오류는 두 가지 원인으로 발생할 수 있습니다.

  1. 소스의 max_allowed_packet 값이 소스의 binlog 이벤트 크기보다 작습니다.
  2. 소스 데이터베이스의 binlog가 손상되었습니다.

이러한 문제를 해결하려면 다음과 같은 단계를 따릅니다.

1.    소스에서 max_allowed_packet을 더 큰 값으로 설정합니다. 이렇게 하면 binlog 이벤트 크기 때문에 오류가 발생할 가능성을 배제할 수 있습니다. 이 파라미터의 값은 최대 1GB까지 가능합니다.

  1. max_allowed_packet 값을 더 크게 설정해도 문제가 해결되지 않는 경우, 소스의 binlog가 손상되었을 수 있습니다. 오류 메시지에 이런 텍스트가 포함됩니다.

"the first event '/mnt/data/logs/mysql-bin.056367' at 123, the last event read from '/mnt/data/logs/mysql-bin.056367' at 787323693"

그렇다면 다음 명령을 실행하여 mysql-bin.056367이 손상되었는지 확인해야 합니다.

1.    binlog가 있는지 확인

mysql> SHOW BINARY LOGS;

2.    해당 이진 로그의 이벤트 조회

mysql> SHOW BINLOG EVENTS IN '<binlog file>' FROM <position>;

3.    이진 로그 다운로드

mysql> MYSQLBINLOG;

오류 1236(binlog가 이벤트 중간에 잘림, 마스터에 디스크 공간이 부족할 수 있음 등)

작업 로그에서 오류 발생

[SOURCE_CAPTURE ]I: Read next binary log event failed; net_safe_read error 1236 (binlog truncated in the middle of event; consider out of disk space on master; the first event 'mysql-bin-changelog.017672' at 486, the last event read from '/rdsdbdata/log/binlog/mysql-bin-changelog.017672' at 125, the last byte read from '/rdsdbdata/log/binlog/mysql-bin-changelog.017672' at 4756.) (mysql_endpoint_capture.c:1069)
[SORTER ]I: Transaction consistency reached (sorter_transaction.c:347)
[TASK_MANAGER ]I: Starting replication now (replicationtask.c:2774)
[TASK_MANAGER ]I: Task - MGLVRIRUJH6FE2GP6F7SW46BPBW6YKF2JUJPSVY is in RUNNING state, updating starting status to AR_RUNNING (repository.c:5110)

이 오류의 주요 원인은 두 가지 입니다.

  1. 기본 서버에 sync_binlog != 1이 있습니다. 이는 디스크에서 이진 로그 이벤트가 동기화되지 않았을 수 있다는 뜻입니다.
  2. 소스 데이터베이스의 binlog가 손상되었습니다.

이 오류를 해결하려면 다음을 수행하세요.

1.    소스에서 sync_binlog 파라미터 값을 확인합니다.

2.    sync_binlog 값을 수정하여 1로 설정합니다.

3.    작업을 다시 시작합니다.

참고: sync_binlog 파라미터가 이미 1로 설정되어 있는 경우, 이전에 오류 1236(로그 이벤트 항목이 max_allowed_packet 초과, 마스터에서 max_allowed_packet 증가 등)에 관해 상세히 설명한 단계를 사용하여 이진 로그를 검토하세요.

오류 1236(클라이언트가 마스터에 불가능한 위치에서 복제를 시작하도록 요청)

작업 로그에서 오류 발생

[SOURCE_CAPTURE  ]I:  Position was set in binlog 'mysql-bin-changelog.007989' at 1631  (mysql_endpoint_capture.c:922)
[SOURCE_CAPTURE  ]I:  Read next binary log event failed; net_safe_read error 1236 (Client requested master to start replication from impossible position; the first event 'mysql-bin-changelog.007989' at 1631, the last event read from 'mysql-bin-changelog.007989' at 4, the last byte read from 'mysql-bin-changelog.007989' at 4.)  (mysql_endpoint_capture.c:1053)
[SOURCE_CAPTURE  ]D:  Error reading binary log. [1020493]  (mysql_endpoint_capture.c:3995)
[SOURCE_CAPTURE  ]E:  Error 1236 (Client requested master to start replication from impossible position; the first event 'mysql-bin-changelog.007989' at 1631, the last event read from 'mysql-bin-changelog.007989' at 4, the last byte read from 'mysql-bin-changelog.007989' at 4.) reading binlog events [1020493]  (mysql_endpoint_capture.c:1074)

이 오류는 보통 소스 MySQL 데이터베이스 서버가 예기치 못하게 중지되는 경우 발생합니다. 디스크 오류나 정전 같은 하드웨어 장애 때문에 생긴 결과일 수 있습니다.

이 오류를 해결하려면, AWS DMS 작업 유형에 따라 다음과 같은 단계를 따릅니다.

  • 전체 로드 및 CDC 작업 - AWS DMS 작업을 다시 시작합니다.
  • CDC 한정 작업 - 다음 이진 로그 위치에서 AWS DMS 작업 시작

오류 1236(클라이언트가 마스터에 파일 크기보다 큰 위치에서 복제를 시작하도록 요청)

작업 로그에서 오류 발생

[SOURCE_CAPTURE  ]I:  Position was set in binlog 'binlog.000012' at 2179  (mysql_endpoint_capture.c:922)
[SOURCE_CAPTURE  ]I:  Read next binary log event failed; net_safe_read error 1236 (Client requested master to start replication from position > file size)  (mysql_endpoint_capture.c:1052

이 오류는 이진 로그가 암호화되었기 때문에 발생했을 수 있습니다. 소스 MySQL 데이터베이스가 MySQL 버전 8.0을 실행하고 이진 로그가 암호화된 경우, AWS DMS가 작업을 초기화할 때 로그를 읽을 수 없습니다. 그 결과 AWS DMS가 이 오류를 기록하게 됩니다. AWS DMS는 이진 로그 암호화가 설정되어 있을 때 MySQL 8.0을 소스로 사용한 CDC 복제를 지원하지 않습니다.

1.    MySQL 버전 확인

mysql> SELECT VERSION();

2.    binlog_encryption이 ON인지 확인

mysql> SELECT * FROM performance_schema.global_variables WHERE VARIABLE_NAME = 'binlog_encryption';

3.    binlog 암호화 해제

mysql> SET GLOBAL binlog_encryption = OFF;

-또는-

binlog_encryption을 해제한 상태로 AWS DMS 작업을 시작한 다음, binlog_encryption 활성화

mysql> SET GLOBAL binlog_encryption = ON;

관련 정보

AWS DMS를 Aurora MySQL과 함께 소스로 사용할 때 받은 이진 로깅 오류를 해결하려면 어떻게 해야 하나요?

AWS 공식
AWS 공식업데이트됨 2년 전
댓글 없음