2.4. 배포 확인
커넥터가 시작되면 구성된 데이터베이스의 스냅샷을 수행하고 사용자가 지정하는 각 테이블에 대한 주제를 만듭니다.
사전 요구 사항
2.3절. “Red Hat Enterprise Linux에서 AMQ Streams를 사용하여 Debezium 배포” 의 지침에 따라 Red Hat Enterprise Linux에 커넥터를 배포했습니다. .Procedure
호스트의 터미널 창에서 다음 명령을 입력하여 Kafka Connect API에서 커넥터 목록을 요청합니다.
curl -H "Accept:application/json" localhost:8083/connectors/
$ curl -H "Accept:application/json" localhost:8083/connectors/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 쿼리는 배포된 커넥터의 이름을 반환합니다. 예를 들면 다음과 같습니다.
["inventory-connector"]
["inventory-connector"]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 호스트의 터미널 창에서 다음 명령을 입력하여 커넥터가 실행 중인 작업을 확인합니다.
curl -i -X GET -H "Accept:application/json" localhost:8083/connectors/inventory-connector
$ curl -i -X GET -H "Accept:application/json" localhost:8083/connectors/inventory-connector
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 이 명령은 다음 예와 유사한 출력을 반환합니다.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Kafka 클러스터의 주제 목록을 표시합니다.
터미널 창에서/opt/kafka/bin/
로 이동하여 다음 쉘 스크립트를 실행합니다../kafka-topics.sh --bootstrap-server=localhost:9092 --list
./kafka-topics.sh --bootstrap-server=localhost:9092 --list
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Kafka 브로커는 커넥터가 생성하는 주제 목록을 반환합니다. 사용 가능한 항목은 커넥터의
snapshot.mode
,snapshot.include.collection.list
및table.include.list
구성 속성의 설정에 따라 다릅니다. 기본적으로 커넥터는 데이터베이스의 각 비 시스템 테이블에 대한 주제를 만듭니다.주제의 콘텐츠를 확인합니다.
터미널 창에서/opt/kafka/bin/
로 이동하여kafka-console-consumer.sh
쉘 스크립트를 실행하여 이전 명령에서 반환된 주제 중 하나의 내용을 표시합니다.
예를 들면 다음과 같습니다.
./kafka-console-consumer.sh \ > --bootstrap-server localhost:9092 \ > --from-beginning \ > --property print.key=true \ > --topic=dbserver1.inventory.products_on_hand
./kafka-console-consumer.sh \ > --bootstrap-server localhost:9092 \ > --from-beginning \ > --property print.key=true \ > --topic=dbserver1.inventory.products_on_hand
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 주제의 각 이벤트에 대해 명령은 다음 출력과 유사한 정보를 반환합니다.
예 2.1. 통합 변경 이벤트의 내용
{"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"product_id"}],"optional":false,"name":"dbserver1.inventory.products_on_hand.Key"},"payload":{"product_id":101}} {"schema":{"type":"struct","fields":[{"type":"struct","fields":[{"type":"int32","optional":false,"field":"product_id"},{"type":"int32","optional":false,"field":"quantity"}],"optional":true,"name":"dbserver1.inventory.products_on_hand.Value","field":"before"},{"type":"struct","fields":[{"type":"int32","optional":false,"field":"product_id"},{"type":"int32","optional":false,"field":"quantity"}],"optional":true,"name":"dbserver1.inventory.products_on_hand.Value","field":"after"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"version"},{"type":"string","optional":false,"field":"connector"},{"type":"string","optional":false,"field":"name"},{"type":"int64","optional":false,"field":"ts_ms"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"true,last,false"},"default":"false","field":"snapshot"},{"type":"string","optional":false,"field":"db"},{"type":"string","optional":true,"field":"sequence"},{"type":"string","optional":true,"field":"table"},{"type":"int64","optional":false,"field":"server_id"},{"type":"string","optional":true,"field":"gtid"},{"type":"string","optional":false,"field":"file"},{"type":"int64","optional":false,"field":"pos"},{"type":"int32","optional":false,"field":"row"},{"type":"int64","optional":true,"field":"thread"},{"type":"string","optional":true,"field":"query"}],"optional":false,"name":"io.debezium.connector.mysql.Source","field":"source"},{"type":"string","optional":false,"field":"op"},{"type":"int64","optional":true,"field":"ts_ms"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"id"},{"type":"int64","optional":false,"field":"total_order"},{"type":"int64","optional":false,"field":"data_collection_order"}],"optional":true,"field":"transaction"}],"optional":false,"name":"dbserver1.inventory.products_on_hand.Envelope"},"payload":{"before":null,"after":{"product_id":101,"quantity":3},"source":{"version":"2.3.4.Final-redhat-00001","connector":"mysql","name":"inventory_connector_mysql","ts_ms":1638985247805,"snapshot":"true","db":"inventory","sequence":null,"table":"products_on_hand","server_id":0,"gtid":null,"file":"mysql-bin.000003","pos":156,"row":0,"thread":null,"query":null},"op":"r","ts_ms":1638985247805,"transaction":null}}
{"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"product_id"}],"optional":false,"name":"dbserver1.inventory.products_on_hand.Key"},"payload":{"product_id":101}} {"schema":{"type":"struct","fields":[{"type":"struct","fields":[{"type":"int32","optional":false,"field":"product_id"},{"type":"int32","optional":false,"field":"quantity"}],"optional":true,"name":"dbserver1.inventory.products_on_hand.Value","field":"before"},{"type":"struct","fields":[{"type":"int32","optional":false,"field":"product_id"},{"type":"int32","optional":false,"field":"quantity"}],"optional":true,"name":"dbserver1.inventory.products_on_hand.Value","field":"after"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"version"},{"type":"string","optional":false,"field":"connector"},{"type":"string","optional":false,"field":"name"},{"type":"int64","optional":false,"field":"ts_ms"},{"type":"string","optional":true,"name":"io.debezium.data.Enum","version":1,"parameters":{"allowed":"true,last,false"},"default":"false","field":"snapshot"},{"type":"string","optional":false,"field":"db"},{"type":"string","optional":true,"field":"sequence"},{"type":"string","optional":true,"field":"table"},{"type":"int64","optional":false,"field":"server_id"},{"type":"string","optional":true,"field":"gtid"},{"type":"string","optional":false,"field":"file"},{"type":"int64","optional":false,"field":"pos"},{"type":"int32","optional":false,"field":"row"},{"type":"int64","optional":true,"field":"thread"},{"type":"string","optional":true,"field":"query"}],"optional":false,"name":"io.debezium.connector.mysql.Source","field":"source"},{"type":"string","optional":false,"field":"op"},{"type":"int64","optional":true,"field":"ts_ms"},{"type":"struct","fields":[{"type":"string","optional":false,"field":"id"},{"type":"int64","optional":false,"field":"total_order"},{"type":"int64","optional":false,"field":"data_collection_order"}],"optional":true,"field":"transaction"}],"optional":false,"name":"dbserver1.inventory.products_on_hand.Envelope"},"payload":{"before":null,"after":{"product_id":101,"quantity":3},"source":{"version":"2.3.4.Final-redhat-00001","connector":"mysql","name":"inventory_connector_mysql","ts_ms":1638985247805,"snapshot":"true","db":"inventory","sequence":null,"table":"products_on_hand","server_id":0,"gtid":null,"file":"mysql-bin.000003","pos":156,"row":0,"thread":null,"query":null},"op":"r","ts_ms":1638985247805,"transaction":null}}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 이전 예에서
페이로드
값은 테이블inventory.products_on_hand
에서 커넥터 스냅샷이 읽기("op" ="r
") 이벤트를 생성했음을 보여줍니다.product_id
레코드의"이전"
상태는null
이며 레코드에 대해 이전 값이 없음을 나타냅니다."after"
상태는product_id
101
가 있는 항목에 대해3
의수량을
보여줍니다.
다음 단계
각 커넥터에 사용할 수 있는 구성 설정에 대한 정보와 변경 데이터 캡처를 사용하도록 소스 데이터베이스를 구성하는 방법에 대한 자세한 내용은 Debezium 사용자 가이드를 참조하십시오.