|
| 1 | +--- |
| 2 | +title: 'Debezium connector for PlanetScale' |
| 3 | +subtitle: 'Learn how to set up the Debezium connector for PlanetScale.' |
| 4 | +date: '2024-10-28' |
| 5 | +--- |
| 6 | + |
| 7 | +The Debezium connector for PlanetScale is a connector for [Debezium](https://debezium.io/), an open-source distributed platform for change data capture. This connector is a fork of the 2.4.x release of the [Debezium connector for Vitess](https://debezium.io/documentation/reference/stable/connectors/vitess.html). |
| 8 | + |
| 9 | +This documentation shows you how to set up the Debezium connector for PlanetScale. This will allow you to get the `debezium-server` running on your machine, connect to PlanetScale, and send messages to a webhook endpoint. |
| 10 | + |
| 11 | +## Install Java |
| 12 | + |
| 13 | +1. First, you’ll need the Java Development SDK installed on your machine. You can find this at [https://www.oracle.com/java/technologies/downloads/\#jdk22-mac](https://www.oracle.com/java/technologies/downloads/#jdk22-mac). |
| 14 | + |
| 15 | +## Running standalone in Debezium Server |
| 16 | + |
| 17 | +[Debezium Server](https://debezium.io/documentation/reference/stable/operations/debezium-server.html) is a standalone application that can test a Debezium connector end-to-end by hosting the Debezium core as an in-process library and pass data from the source to the sink. |
| 18 | + |
| 19 | +1. Download Debezium Server from the [distribution link](https://repo1.maven.org/maven2/io/debezium/debezium-server-dist/2.4.1.Final/debezium-server-dist-2.4.1.Final.tar.gz). |
| 20 | +2. Create a directory on your machine where you want to run it. |
| 21 | +3. Move the download to that directory. |
| 22 | +4. Extract it by running `tar -xvf <path to file>` |
| 23 | +5. You’ll now have a `debezium-server` directory. |
| 24 | +6. `cd debezium-server` |
| 25 | +7. Create a `data` folder. |
| 26 | +8. Download the JAR with dependencies for the `debezium-vitess-planetscale` from [GitHub](https://github.com/planetscale/debezium-connector-planetscale/releases/download/v2.4.0.Final.PS20241031.1/debezium-connector-planetscale-2.4.0.Final-jar-with-dependencies.jar), and place in `lib/`. |
| 27 | + |
| 28 | +### Configure the Debezium connector for PlanetScale |
| 29 | + |
| 30 | +Create a file `conf/application.properties`. This is where your config will go. |
| 31 | + |
| 32 | +In this example config, we are going to have the sink send HTTP requests to `webhook.site`. |
| 33 | + |
| 34 | +Go to [`http://webhook.site`](http://webhook.site) to get your own endpoint. |
| 35 | + |
| 36 | +Place the sample config below in `conf/application.properties`, replacing the following placeholders: |
| 37 | + |
| 38 | +- `<webhook>` with your webhook.site endpoint. |
| 39 | +- `<planetscale-database-name>` with your PlanetScale database name. |
| 40 | +- `<planetscale-hostname>` with your PlanetScale connection string hostname. |
| 41 | +- `<planetscale-username>` with your PlanetScale connection string username. |
| 42 | +- `<planetscale-password>` with your PlanetScale connection string password. |
| 43 | + |
| 44 | +```java |
| 45 | +debezium.sink.type=http |
| 46 | +quarkus.log.level=DEBUG |
| 47 | +debezium.format.value=json |
| 48 | +debezium.sink.http.url=<webhook> |
| 49 | +log4j.logger.io.debezium.relational.history=DEBUG, stdout |
| 50 | +debezium.source.offset.storage.file.filename=data/offsets.dat |
| 51 | +debezium.source.offset.flush.interval.ms=0 |
| 52 | +debezium.source.schema.history.internal=io.debezium.storage.file.history.FileSchemaHistory |
| 53 | +debezium.source.schema.history.internal.file.filename=data/schema_history.dat |
| 54 | +debezium.source.connector.class=io.debezium.connector.planetscale.PlanetScaleConnector |
| 55 | +debezium.source.vitess.keyspace=<planetscale-database-name> |
| 56 | +debezium.source.vitess.tablet.type=MASTER |
| 57 | +debezium.source.database.hostname=<planetscale-hostname> |
| 58 | +debezium.source.database.port=443 |
| 59 | +debezium.source.database.user=<planetscale-username> |
| 60 | +debezium.source.database.password=<planetscale-password> |
| 61 | +debezium.source.topic.prefix=connector-test |
| 62 | +``` |
| 63 | + |
| 64 | +## Run it |
| 65 | + |
| 66 | +Once the config is set, you can start it by running `./run.sh` |
| 67 | + |
| 68 | +Any existing rows in any table of `<planetscale-database-name>` will show up as events in your `webhook.site` endpoint. Adding/modifying/deleting rows will also show up as events in your endpoint. |
0 commit comments