개성있는 개발자 되기

Debezium Connector for MySQL 본문

Open Source/Kafka

Debezium Connector for MySQL

정몽실이 2020. 3. 25. 19:30

Debezium 이란

 

MySql 데이터 변경을 카프카로 전송해주는 오픈소스로 Debezium이 있다.

공식홈페이지 : https://debezium.io/documentation/reference/1.1/connectors/mysql.html

 

Debezium Connector for MySQL :: Debezium Documentation

Version: Select --> |

debezium.io

 

 

MySQL은 데이터베이스에 커밋된 모든 내용을 기록하는 bin log가 있다. 테이블 스키마 변경 내역도 로깅한다. 주로 데이터 복구나, 복제를 위해 활용된다.

 

Debezium MySQL 커넥터는 이 빈로그를 읽어들여 row-level 인 INSERT, UPDATE, DELETE 오퍼레이션에 대한 변경이벤트를 생산하고 이를 카프카 토픽으로 전송한다.

 

As MySQL is typically set up to purge binlogs after a specified period of time, the MySQL connector performs and initial consistent snapshot of each of your databases. The MySQL connector reads the binlog from the point at which the snapshot was made.

 

MySQL은 전형적으로 특정 시간 이후로 퍼지가 되기 때문에 MySQL 커넥터는 데이터베이스의 스냅샵을 기준으로 작동한다. 

 


Debezium MySQL 커넥터를 사용하기 위한 MySql 설정

 

| 연동하는 MySql Server의 log_bin이 활성화 되어 있어야 한다.

mysql> show variables like 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | ON    |
+---------------+-------+

 

| 연동하는 MySql Server의 Binlog 가 row-level 이어야 한다.

mysql> show variables like 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | MIXED |
+---------------+-------+

mysql> show variables like 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW |
+---------------+-------+

 

| Connector가 MySql Server에 접속하는 계정 권한

-- RELOAD 권한
org.apache.kafka.connect.errors.ConnectException: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
-- SUPER, REPLICATION CLIENT 권한
org.apache.kafka.connect.errors.ConnectException: Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation Error code: 1227; SQLSTATE: 42000.
-- REPLICATION SLAVE 권한
org.apache.kafka.connect.errors.ConnectException: Access denied; you need (at least one of) the REPLICATION SLAVE privilege(s) for this operation Error code: 1227; SQLSTATE: 42000.
mysql> SHOW GRANTS FOR CURRENT_USER;
+------------------------------------------------------------------------------------------+
| Grants for kafka@%                                                                       |
+------------------------------------------------------------------------------------------+
| GRANT SELECT, RELOAD, SUPER, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'kafka'@'%' |
+------------------------------------------------------------------------------------------+

 

 

Comments