Red Hatã®é æ±ã§ãã
æ¬è¨äºã¯èµ¤å¸½ã¨ã³ã¸ãã¢Advent Calendar 2018ã®6æ¥ç®ã§ãã (åä¾ã®å¯ããã¤ãã§ä¸ç·ã«å¯è½ã¡ãã¦æ¥ä»ãå¤ãã£ã¦ãã¾ãã¾ããã12/6åã§ãããã)
Debeziumã¨ã¯?
Debeziumã¯DBã«å¯¾ãããã¼ã¿æä½ããã£ããã£ãã¦ã¤ãã³ãã¹ããªã¼ã ã«å¤æãã¦ãããåæ£ãã©ãããã©ã¼ã ã§ããApache Kafkaããã¼ã¹ã«å®è£ ããã¦ãããKafka Connectãã¼ã¹ã®ã³ãã¯ã¿ãå©ç¨ãã¦DBãã¢ãã¿ã¼ãããã¨ãã§ãã¾ãã æ¢åDBã«å¯¾ãããã¼ã¿æä½ãKafkaã®ã¡ãã»ã¼ã¸ã«å¤æãããã¨ãã§ãã¾ãã®ã§ãã¬ã¬ã·ã¼ã·ã¹ãã ãªã©ã§ã¢ããªã±ã¼ã·ã§ã³ã«æãå ¥ããããªããã©ãã¼ã¿ã ãæãåºãã¦ãªã¢ã«ã¿ã¤ã å¦çãããã¨ããå¥ã·ã¹ãã ã«ãã¼ã¿ãæµç¨ãããã¨ããå ´åã«ä¾¿å©ãªã½ããã¦ã§ã¢ã§ãã ã¾ããã¤ãã³ããã°ã¯Kafkaãä¿æãã¦ããã¦ããã®ã§ããã¼ã¿ãå©ç¨ããå´(consumer)ãæ¢ã¾ã£ã¦ãã¤ãã³ããã°ã失ããããã¨ã¯ãªããconsumerã復æ§ãããã°å¦çãåéãããã¨ãå¯è½ã§ãã
詳細æ å ±
Debeziumãã¥ã¼ããªã¢ã«
Debeziumã使ãã«ã¯ Zookeeper / Kafka / Debezium Connectorã®ï¼ã¤ã®ã³ã³ãã¼ãã³ããåããå¿ è¦ãããã¾ã(Zookeeperã¯Kafkaãåããããã«å¿ è¦)ã ãããã¯ã·ã§ã³ç°å¢ã§ããã°å ¨ã³ã³ãã¼ãã³ããè¤æ°ããã»ã¹ã§æ§æãã¦åæ£å¦çãè¡ãããã«ãã¾ãããåä½ãç解ããããã«ã¾ãã¯ãã¹ã¦ã®ã³ã³ãã¼ãã³ããã·ã³ã°ã«ããã»ã¹ã§åããã¦ã¿ã¾ãããã 詳ããæé ã¨è§£èª¬ã¯å ¬å¼ãµã¤ãã®ãã¥ã¼ããªã¢ã«ãåç §ãã¦ã¿ã¦ãã ããã
ç°å¢æ§æ
ãã¹ã¦ã®ããã»ã¹ãDockerã³ã³ããã¨ãã¦èµ·åãã¾ãã æçµçã«ã¯æ¬¡ã®ãããªæãã«ãªãã¾ãã
Dockerã¯é©å½ã«ç¨æãã¦ãã ãããèªåã®ç°å¢ã¯ä»¥ä¸ã®éãã§ããã
$ docker version Client: Docker Engine - Community Version: 18.09.0 API version: 1.39 Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:47:43 2018 OS/Arch: darwin/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 18.09.0 API version: 1.39 (minimum version 1.12) Go version: go1.10.4 Git commit: 4d60db4 Built: Wed Nov 7 00:55:00 2018 OS/Arch: linux/amd64 Experimental: true
ã»ããã¢ãã
å¿ è¦ãªã³ã³ãããé 次起åãã¦ããConnectorã®è¨å®ãè¡ãã¾ãã ãã°ã確èªãããããããããã³ã³ããæ¯ã«ã¿ã¼ããã«ã¦ã£ã³ãã¦ãéãããã©ã¢ã°ã©ã¦ã³ãã§åããã¾ãã
(1)Zookeeperèµ·å
docker run -it --rm --name zookeeper -p 2181:2181 -p 2888:2888 -p 3888:3888 debezium/zookeeper:0.8
(2)Kafkaèµ·å
docker run -it --rm --name kafka -p 9092:9092 --link zookeeper:zookeeper debezium/kafka:0.8
(3)MySQLèµ·å
å¤æ´ãç£è¦ãã対象ã¨ãã¦MySQLãèµ·åãã¦ããã¾ãã
docker run -it --rm --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=debezium -e MYSQL_USER=mysqluser -e MYSQL_PASSWORD=mysqlpw debezium/example-mysql:0.8
(4)MySQL CLIãèµ·å
MySQLãæä½ããããã«CLIãèµ·åãã¦ããã¾ãã
docker run -it --rm --name mysqlterm --link mysql --rm mysql:5.7 sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
åæç¶æ ã§ã¯ä»¥ä¸ã®ããã«ãªã£ã¦ãã¾ãã
mysql> show tables; +---------------------+ | Tables_in_inventory | +---------------------+ | addresses | | customers | | orders | | products | | products_on_hand | +---------------------+ 5 rows in set (0.00 sec) mysql> SELECT * FROM customers; +------+------------+-----------+-----------------------+ | id | first_name | last_name | email | +------+------------+-----------+-----------------------+ | 1001 | Sally | Thomas | [email protected] | | 1002 | George | Bailey | [email protected] | | 1003 | Edward | Walker | [email protected] | | 1004 | Anne | Kretchmar | [email protected] | +------+------------+-----------+-----------------------+ 4 rows in set (0.00 sec)
(5)Kafka Connectèµ·å
MySQLãç£è¦ããConnectorãèµ·åãã¾ãã8083çªãã¼ããéãã¦ããã®ã¯REST APIã§æä½ãè¡ãããã§ãã
docker run -it --rm --name connect -p 8083:8083 -e GROUP_ID=1 -e CONFIG_STORAGE_TOPIC=my_connect_configs -e OFFSET_STORAGE_TOPIC=my_connect_offsets --link zookeeper:zookeeper --link kafka:kafka --link mysql:mysql debezium/connect:0.8
以ä¸ãå®è¡ãã¦ãKafka Connectã®REST APIãåä½ããã確èªãã¦ããã¾ãã
$ curl -H "Accept:application/json" localhost:8083/ {"version":"1.1.0","commit":"fdcf75ea326b8e07","kafka_cluster_id":"UPPe8OIjQfCL3e9W51MGZw"} $ curl -H "Accept:application/json" localhost:8083/connectors/ []
MySQLã®ã¢ãã¿ãªã³ã°è¨å®
Connectorã®REST APIããDBãKafkaã«æ¥ç¶ããããã«å¿ è¦ãªæ å ±ãè¨å®ãã¾ãã
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" localhost:8083/connectors/ -d '{ "name": "inventory-connector", "config": { "connector.class": "io.debezium.connector.mysql.MySqlConnector", "tasks.max": "1", "database.hostname": "mysql", "database.port": "3306", "database.user": "debezium", "database.password": "dbz", "database.server.id": "184054", "database.server.name": "dbserver1", "database.whitelist": "inventory", "database.history.kafka.bootstrap.servers": "kafka:9092", "database.history.kafka.topic": "dbhistory.inventory" } }'
以ä¸ã®ãããªã¬ã¹ãã³ã¹ãè¿ã£ã¦ããã°ç¡äºè¨å®ã§ãã¦ãã¾ãã(JSONã¯æ´å½¢ãã¦ãã¾ãã以ä¸åæ§)
HTTP/1.1 201 Created Date: Thu, 06 Dec 2018 10:41:15 GMT Location: http://localhost:8083/connectors/inventory-connector Content-Type: application/json Content-Length: 483 Server: Jetty(9.2.24.v20180105) { "name": "inventory-connector", "config": { "connector.class": "io.debezium.connector.mysql.MySqlConnector", "tasks.max": "1", "database.hostname": "mysql", "database.port": "3306", "database.user": "debezium", "database.password": "dbz", "database.server.id": "184054", "database.server.name": "dbserver1", "database.whitelist": "inventory", "database.history.kafka.bootstrap.servers": "kafka:9092", "database.history.kafka.topic": "dbhistory.inventory", "name": "inventory-connector" }, "tasks": [], "type": null }
念ã®çºãæ£ããè¨å®ããã¦ããã確èªãã¦ã¿ã¾ãã
$ curl -H "Accept:application/json" localhost:8083/connectors/ ["inventory-connector"] $ curl -i -X GET -H "Accept:application/json" localhost:8083/connectors/inventory-connector HTTP/1.1 200 OK Date: Thu, 06 Dec 2018 10:43:31 GMT Content-Type: application/json Content-Length: 531 Server: Jetty(9.2.24.v20180105) { "name": "inventory-connector", "config": { "connector.class": "io.debezium.connector.mysql.MySqlConnector", "database.user": "debezium", "database.server.id": "184054", "tasks.max": "1", "database.hostname": "mysql", "database.password": "dbz", "database.history.kafka.bootstrap.servers": "kafka:9092", "database.history.kafka.topic": "dbhistory.inventory", "name": "inventory-connector", "database.server.name": "dbserver1", "database.whitelist": "inventory", "database.port": "3306" }, "tasks": [ { "connector": "inventory-connector", "task": 0 } ], "type": "source" }
OKã§ãã!
ãã®ã¨ããconnectorã³ã³ããå´ã«ã¯ãç»é²ã§ããã!ãã¨ãããã°ãåºã¦ããã¯ããªã®ã§ãèå³ã®ããæ¹ã¯ç¢ºèªãã¦ã¿ã¦ãã ããã
Debeziumã®åä½ã確èª
ã»ããã¢ãã大å¤ã§ãããããããã®å¾ã¯ç°¡åã§ãã
(6)Watcherèµ·å
Kafkaã«ã¡ãã»ã¼ã¸ãæå
¥ããããã¨ã確èªããããã«watcher(console consumer)ãèµ·åãã¦ããã¾ãã
Debeziumã®ããã©ã«ãã§ã¯ DBå.ã¹ãã¼ãå.ãã¼ãã«å
ã¨ããtopicã«ã¡ãã»ã¼ã¸ãæå
¥ãããããã«ãªã£ã¦ãã¾ãã®ã§ãããã§ã¯ customers
ãã¼ãã«ã«å¯¾ããå¤æ´ãç£è¦ããããã«ãã¦ãã¾ãã
docker run -it --name watcher --rm --link zookeeper:zookeeper --link kafka:kafka debezium/kafka:0.8 watch-topic -a -k dbserver1.inventory.customers
watcherãèµ·åããã¨ãæ¢ã«ããã¤ãã¡ãã»ã¼ã¸ãæå ¥ããã¦ãããã¨ã確èªã§ãã¾ãã
WARNING: Using default BROKER_ID=1, which is valid only for non-clustered installations. Using ZOOKEEPER_CONNECT=172.17.0.2:2181 Using KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://172.17.0.7:9092 Contents of topic dbserver1.inventory.customers: Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper]. {"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"id"}],"optional":false,"name":"dbserver1.inventory.customers.Key"},"payload":{"id":1001}} {"schema":{"type":"struct","fields":[{"type":"struct","fields":[{"type":"int32","optional":false,"field":"id"},{"type":"string","optional":false,"field":"first_name"},{"type":"string","optional":false,"field":"last_name"},{"type":"string","optional":false,"field":"email"}],"optional":true,"name":"dbserver1.inventory.customers.Value","field":"before"},{"type":"struct","fields":[{"type":"int32","optional":false,"field":"id"},{"type":"string","optional":false,"field":"first_name"},{"type":"string","optional":false,"field":"last_name"},{"type":"string","optional":false,"field":"email"}],"optional":true,"name":"dbserver1.inventory.customers.Value","field":"after"},{"type":"struct","fields":[{"type":"string","optional":true,"field":"version"},{"type":"string","optional":false,"field":"name"},{"type":"int64","optional":false,"field":"server_id"},{"type":"int64","optional":false,"field":"ts_sec"},{"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":"boolean","optional":true,"default":false,"field":"snapshot"},{"type":"int64","optional":true,"field":"thread"},{"type":"string","optional":true,"field":"db"},{"type":"string","optional":true,"field":"table"},{"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"}],"optional":false,"name":"dbserver1.inventory.customers.Envelope"},"payload":{"before":null,"after":{"id":1001,"first_name":"Sally","last_name":"Thomas","email":"[email protected]"},"source":{"version":"0.8.3.Final","name":"dbserver1","server_id":0,"ts_sec":0,"gtid":null,"file":"mysql-bin.000003","pos":154,"row":0,"snapshot":true,"thread":null,"db":"inventory","table":"customers","query":null},"op":"c","ts_ms":1544092878919}}
MySQL Connectorã¯binlogã解æãã¦ã¤ãã³ãã«å¤æããããã«å®è£ ããã¦ãã¾ãããåææ¥ç¶æã«ã¯ãã¼ãã«ä½ææããã®ãã¹ã¦ã®å¤æ´ãèªã¿åãããããã®ãããªåä½ããã¾ãã Connectorãåèµ·åãããªã©ãã¦åæ¥ç¶ããå ´åãååèªã¿åãæ¸ã¿ã®ãã°ã®ç¶ãããèªã¿åãããã«ãªã£ã¦ãã¾ãã
èå³ã®ããæ¹ã¯SnapshotReaderã®ã½ã¼ã¹ãèªã¿è§£ãã¦ã¿ã¦ä¸ããã https://github.com/debezium/debezium/blob/master/debezium-connector-mysql/src/main/java/io/debezium/connector/mysql/SnapshotReader.java
ãã¼ã¿ãæ´æ°ãã¦ã¿ã
UPDATEãå®è¡ãã¦ãã¼ã¿ãæ´æ°ãã¦ã¿ã¾ãã
mysql> UPDATE customers SET first_name='Anne Marie' WHERE id=1004; Query OK, 1 row affected (0.01 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> SELECT * FROM customers; +------+------------+-----------+-----------------------+ | id | first_name | last_name | email | +------+------------+-----------+-----------------------+ | 1001 | Sally | Thomas | [email protected] | | 1002 | George | Bailey | [email protected] | | 1003 | Edward | Walker | [email protected] | | 1004 | Anne Marie | Kretchmar | [email protected] | +------+------------+-----------+-----------------------+ 4 rows in set (0.00 sec)
ããã¨ãwatcherå´ã§ä»¥ä¸ã®ã¤ãã³ããã°ã観測ã§ããã¯ãã§ãã
{ "schema": { "type": "struct", "fields": [ { "type": "int32", "optional": false, "field": "id" } ], "optional": false, "name": "dbserver1.inventory.customers.Key" }, "payload": { "id": 1004 } } { "schema": { "type": "struct", "fields": [ { "type": "struct", "fields": [ { "type": "int32", "optional": false, "field": "id" }, { "type": "string", "optional": false, "field": "first_name" }, { "type": "string", "optional": false, "field": "last_name" }, { "type": "string", "optional": false, "field": "email" } ], "optional": true, "name": "dbserver1.inventory.customers.Value", "field": "before" }, { "type": "struct", "fields": [ { "type": "int32", "optional": false, "field": "id" }, { "type": "string", "optional": false, "field": "first_name" }, { "type": "string", "optional": false, "field": "last_name" }, { "type": "string", "optional": false, "field": "email" } ], "optional": true, "name": "dbserver1.inventory.customers.Value", "field": "after" }, { "type": "struct", "fields": [ { "type": "string", "optional": true, "field": "version" }, { "type": "string", "optional": false, "field": "name" }, { "type": "int64", "optional": false, "field": "server_id" }, { "type": "int64", "optional": false, "field": "ts_sec" }, { "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": "boolean", "optional": true, "default": false, "field": "snapshot" }, { "type": "int64", "optional": true, "field": "thread" }, { "type": "string", "optional": true, "field": "db" }, { "type": "string", "optional": true, "field": "table" }, { "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" } ], "optional": false, "name": "dbserver1.inventory.customers.Envelope" }, "payload": { "before": { "id": 1004, "first_name": "Anne", "last_name": "Kretchmar", "email": "[email protected]" }, "after": { "id": 1004, "first_name": "Anne Marie", "last_name": "Kretchmar", "email": "[email protected]" }, "source": { "version": "0.8.3.Final", "name": "dbserver1", "server_id": 223344, "ts_sec": 1544093538, "gtid": null, "file": "mysql-bin.000003", "pos": 364, "row": 0, "snapshot": false, "thread": 2, "db": "inventory", "table": "customers", "query": null }, "op": "u", "ts_ms": 1544093538316 } }
payloadã®beforeã¨afterãè¦ãã¨ã確ãã«UPDATEåã¨å¾ã®å¤ã確èªã§ãã¾ãã ä»åã¯åã«ã³ã³ã½ã¼ã«è¡¨ç¤ºããã ãã§ããããã¼ã¿å¤æ´ã®å ¨å®¹ãããã«å«ã¾ãã¦ãã¾ãã®ã§ããã®æ å ±ãå¥ã¢ããªã±ã¼ã·ã§ã³ã§åå©ç¨ãããã¨ãå¯è½ã§ãã
Connectorãæ¢ãã¦ã¿ã
Connectorãåèµ·åãã¦ãããã®éã®å¤æ´ããã¹ãããªããã¨ã確èªãã¦ã¿ã¾ãã
ä¸æ¦Connectorãåæ¢ãã¾ãã
docker stop connect
Connectorãåæ¢ããç¶æ ã§ãã¼ã¿ãINSERTãã¾ãã
mysql> INSERT INTO customers VALUES (default, "Sarah", "Thompson", "[email protected]"); Query OK, 1 row affected (0.01 sec) mysql> INSERT INTO customers VALUES (default, "Kenneth", "Anderson", "[email protected]"); Query OK, 1 row affected (0.01 sec)
Watcherã«ã¯ãã°ãåºã¦ããªãã¯ãã§ãã (Kafkaã«ã¡ãã»ã¼ã¸ãå±ãã¦ããªãã®ã§å½ç¶ã§ãããã)
ã§ã¯ãConnectorãããããã«èµ·åãã¾ãã
docker run -it --rm --name connect -p 8083:8083 -e GROUP_ID=1 -e CONFIG_STORAGE_TOPIC=my_connect_configs -e OFFSET_STORAGE_TOPIC=my_connect_offsets --link zookeeper:zookeeper --link kafka:kafka --link mysql:mysql debezium/connect:0.8
ããã¨ãå¤æ´ç£è¦ãåéãããWatcherã«ä»¥ä¸ãã°ãåºåããã¾ãã
{ "schema": { "type": "struct", "fields": [ { "type": "int32", "optional": false, "field": "id" } ], "optional": false, "name": "dbserver1.inventory.customers.Key" }, "payload": { "id": 1005 } } { "schema": { "type": "struct", "fields": [ { "type": "struct", "fields": [ { "type": "int32", "optional": false, "field": "id" }, { "type": "string", "optional": false, "field": "first_name" }, { "type": "string", "optional": false, "field": "last_name" }, { "type": "string", "optional": false, "field": "email" } ], "optional": true, "name": "dbserver1.inventory.customers.Value", "field": "before" }, { "type": "struct", "fields": [ { "type": "int32", "optional": false, "field": "id" }, { "type": "string", "optional": false, "field": "first_name" }, { "type": "string", "optional": false, "field": "last_name" }, { "type": "string", "optional": false, "field": "email" } ], "optional": true, "name": "dbserver1.inventory.customers.Value", "field": "after" }, { "type": "struct", "fields": [ { "type": "string", "optional": true, "field": "version" }, { "type": "string", "optional": false, "field": "name" }, { "type": "int64", "optional": false, "field": "server_id" }, { "type": "int64", "optional": false, "field": "ts_sec" }, { "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": "boolean", "optional": true, "default": false, "field": "snapshot" }, { "type": "int64", "optional": true, "field": "thread" }, { "type": "string", "optional": true, "field": "db" }, { "type": "string", "optional": true, "field": "table" }, { "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" } ], "optional": false, "name": "dbserver1.inventory.customers.Envelope" }, "payload": { "before": null, "after": { "id": 1005, "first_name": "Sarah", "last_name": "Thompson", "email": "[email protected]" }, "source": { "version": "0.8.3.Final", "name": "dbserver1", "server_id": 223344, "ts_sec": 1544093884, "gtid": null, "file": "mysql-bin.000003", "pos": 725, "row": 0, "snapshot": false, "thread": 2, "db": "inventory", "table": "customers", "query": null }, "op": "c", "ts_ms": 1544093957590 } } { "schema": { "type": "struct", "fields": [ { "type": "int32", "optional": false, "field": "id" } ], "optional": false, "name": "dbserver1.inventory.customers.Key" }, "payload": { "id": 1006 } } { "schema": { "type": "struct", "fields": [ { "type": "struct", "fields": [ { "type": "int32", "optional": false, "field": "id" }, { "type": "string", "optional": false, "field": "first_name" }, { "type": "string", "optional": false, "field": "last_name" }, { "type": "string", "optional": false, "field": "email" } ], "optional": true, "name": "dbserver1.inventory.customers.Value", "field": "before" }, { "type": "struct", "fields": [ { "type": "int32", "optional": false, "field": "id" }, { "type": "string", "optional": false, "field": "first_name" }, { "type": "string", "optional": false, "field": "last_name" }, { "type": "string", "optional": false, "field": "email" } ], "optional": true, "name": "dbserver1.inventory.customers.Value", "field": "after" }, { "type": "struct", "fields": [ { "type": "string", "optional": true, "field": "version" }, { "type": "string", "optional": false, "field": "name" }, { "type": "int64", "optional": false, "field": "server_id" }, { "type": "int64", "optional": false, "field": "ts_sec" }, { "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": "boolean", "optional": true, "default": false, "field": "snapshot" }, { "type": "int64", "optional": true, "field": "thread" }, { "type": "string", "optional": true, "field": "db" }, { "type": "string", "optional": true, "field": "table" }, { "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" } ], "optional": false, "name": "dbserver1.inventory.customers.Envelope" }, "payload": { "before": null, "after": { "id": 1006, "first_name": "Kenneth", "last_name": "Anderson", "email": "[email protected]" }, "source": { "version": "0.8.3.Final", "name": "dbserver1", "server_id": 223344, "ts_sec": 1544093890, "gtid": null, "file": "mysql-bin.000003", "pos": 1035, "row": 0, "snapshot": false, "thread": 2, "db": "inventory", "table": "customers", "query": null }, "op": "c", "ts_ms": 1544093957599 } }
ã¡ããã¨INSERT2件ãææããã¦ãã¾ãã!
ä»ã«ããããããªãã¿ã¼ã³ã§è©¦ãã¦ã¿ã¦ä¸ããã
å¾å§æ«
以ä¸ã³ãã³ãã§å ¨ã³ã³ãããåæ¢ãã¾ãã(é¢ä¿ãªãã³ã³ãããå·»ãè¾¼ã¾ããªãããã«æ³¨æãã¦ãã ããã)
docker stop $(docker ps -aq)
ãã¥ã¼ããªã¢ã«ã®ã·ã§ã¼ãã«ãã
ã¡ã¾ã¡ã¾ã³ãã³ããæã¤ã®ãé¢åãªæ¹åãã«ãDocker Composeã§ä¸çºèµ·åã§ãããµã³ãã«ãæä¾ããã¦ãã¾ãã®ã§ãå©ç¨ä¸ããã
https://github.com/debezium/debezium-examples/tree/master/tutorial
ã¾ã¨ã
Debeziumã¨Kafkaã®çµã¿åããã«ãã£ã¦ãã¢ããªã±ã¼ã·ã§ã³ã«ã»ã¼å½±é¿ãªãã§ãDBã«å¯¾ããæ´æ°ã横åããã¦åå©ç¨ãããã¨ãã§ãããã¨ã確èªãã¾ããã Kafkaã¨ããæ±ç¨çãªã¡ãã»ã¼ã¸ãã¹ã«ä¹ãããã¨ã§ãåç´ãªãã¼ã¿ã¬ããªã±ã¼ã·ã§ã³ã ãã§ãªããåãã¡ãã»ã¼ã¸ã¹ããªã¼ã ãè¤æ°ã®ç®çã§åå©ç¨ãããã¨ãã§ãã¾ãã ã¬ã¬ã·ã¼ãã¤ã°ã¬ã¼ã·ã§ã³ã®æ段ã®ä¸ã¤ã¨ãã¦ããããã使ãæãããããã§ããã