Skip to content

Commit 39a79bb

Browse files
committed
Updated README and cleanup
1 parent cd1e647 commit 39a79bb

9 files changed

+59
-148
lines changed

README.md

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,25 +70,43 @@ The script `01-enable-cdc.sql` enable Change Data Capture on the aforementioned
7070
All data gathered by Change Data Capture will be send to Event Hubs, so create an Azure Event Hubs in your Azure Subscription. Using the [Azure Cloud Shell](https://shell.azure.com/) Bash:
7171

7272
```bash
73+
# Set vars
74+
RESOURCE_GROUP=debezium
75+
LOCATION=eastus
76+
EVENTHUB_NAMESPACE=debezium
77+
EVENTHUB_SCHEMA_HISTORY=schemahistory
78+
7379
# create group
7480
az group create \
75-
--name debezium \
76-
--location eastus
81+
--name $RESOUCE_GROUP \
82+
--location $LOCATION
7783

78-
# create eventhuvbs with kafka enabled
84+
# create eventhub namespace with kafka enabled
7985
az eventhubs namespace create \
80-
--name debezium \
81-
--resource-group debezium \
82-
--location eastus \
86+
--name $EVENTHUB_NAMESPACE \
87+
--resource-group $RESOURCE_GROUP \
88+
--location $LOCATION \
8389
--enable-kafka
90+
91+
# create eventhub for schema history
92+
az eventhubs eventhub create \
93+
--resource-group $RESOURCE_GROUP
94+
--namespace $EVENTHUB_NAMESPACE \
95+
--name $EVENTHUB_SCHEMA_HISTORY \
96+
--partition-count 1 \
97+
--cleanup-policy Delete \
98+
--retention-time-in-hours 168
8499
```
85100

86101
Later in the configuration process you'll need the EventHubs connection string, so grab it and store it somewhere:
87102

88103
```bash
104+
RESOURCE_GROUP=debezium
105+
EVENTHUB_NAMESPACE=debezium
106+
89107
az eventhubs namespace authorization-rule keys list \
90-
--resouce-group debezium \
91-
--namespace-name debezium \
108+
--resouce-group $RESOURCE_GROUP \
109+
--namespace-name $EVENTHUB_NAMESPACE \
92110
--name RootManageSharedAccessKey \
93111
--query "primaryConnectionString" \
94112
--output tsv
@@ -108,11 +126,11 @@ Docker Compose will use `.env` to get the environment variables values used in t
108126

109127
```bash
110128
DEBEZIUM_VERSION=2.7
111-
EVENTHUB_NAMESPACE=debezium
112-
EH_CONNECTION_STRING=
129+
EVENTHUB_NAMESPACE=<eventhub_namespace>
130+
EVENTHUB_CONNECTION_STRING=<eventhub_connection_string>
113131
```
114132

115-
Copy it and create a new `.env` file. Leave the version set to `2.7`. Change the `EVENTHUB_NAMESPACE` to the EventHubs name you created before. Also set `EH_CONNECTION_STRING` to hold the EventHubs connection string you got before. Make sure not to use any additional quotes or double quotes.
133+
Copy it and create a new `.env` file. Leave the version set to `2.7`. Change the `EVENTHUB_NAMESPACE` to the EventHubs name you created before. Also set `EVENTHUB_CONNECTION_STRING` to hold the EventHubs connection string you got before. Make sure not to use any additional quotes or double quotes.
116134

117135
#### The .yaml file
118136

@@ -165,7 +183,7 @@ Once the startup has finished, you'll see something like
165183
[Worker clientId=connect-1, groupId=1] Finished starting connectors and tasks [org.apache.kafka.connect.runtime.distributed.DistributedHerder]
166184
```
167185

168-
you will see three topics (or EventHub to use the Azure EventHubs nomenclature):
186+
you will see four topics (or EventHub to use the Azure EventHubs nomenclature):
169187

170188
```bash
171189
az eventhubs eventhub list \
@@ -179,30 +197,36 @@ and the result will show:
179197
- debezium_configs
180198
- debezium_offsets
181199
- debezium_statuses
200+
- schemahistory
182201

183202
to explore Azure Event Hubs is strongly suggest to download and use [Service Bus Explorer](https://github.com/paolosalvatori/ServiceBusExplorer)
184203

185204
#### Register SQL Server Connector
186205

187206
Now that Debezium is running, the SQL Server Connector (which is used both for connecting to Azure SQL or SQL Server) can be registered. Before doing that, make sure to specify the correct connection for your SQL Server instance in a file named `sqlserver-connector-config.json`. You can create one using the template file [sqlserver-connector-config.json.template](debezium/sqlserver-connector-config.json.template) file.
188207

189-
Please note that, the script [debezium/on-prem/register-connector.ps1](debezium/on-prem/register-connector.ps1) will take care of generating the Debezium SQL Server connector configuration JSON file, and then will use it to register a new connector on Debezium.
190-
The generated file will be stored in the `debezium` folder.
191-
192-
If you are using the Wide World Importers database, the only values you have to change are:
208+
Make sure to change the following properties to match your SQL Server configuration:
193209

194210
```json
195211
"database.hostname": "<sql_server_name>.database.windows.net",
196212
"database.names": "<db_name>",
213+
"database.user" : "<debezium_user_name>",
214+
"database.password" : "<debezium_user_password>",
197215
```
198216

199-
If you are following the step-by-step guide using a database of yours, make sure to also correctly set values for
217+
You would need to replace `<sql_server_name>`, `<db_name>`, `<debezium_user_name>`, and `<debezium_user_password>` with proper values.
218+
219+
Also, make sure to change the following properties to match your Azure Event Hub configuration:
200220

201221
```json
202-
"database.user" : "<debezium_user_name>",
203-
"database.password" : "<debezium_user_password>",
222+
"schema.history.internal.kafka.bootstrap.servers": "<eventhub_namespace>.servicebus.windows.net:9093",
223+
"schema.history.internal.kafka.topic": "<eventhub_schema_history>",
224+
"schema.history.internal.consumer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"$ConnectionString\" password=\"<eventhub_connectionstring>\";",
225+
"schema.history.internal.producer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"$ConnectionString\" password=\"<eventhub_connectionstring>\";",
204226
```
205227

228+
You would need to replace `<eventhub_namespace>`, `<eventhub_schema_history>`, and `<eventhub_connectionstring>` with proper values.
229+
206230
All the other values used are explained in detail here:
207231

208232
[SQL Server Connector Configuration Values](./documentation/SQL-Server-Connector-Configuration-Value.md)

debezium/azure/00-deploy-debezium.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
set -euo pipefail
55

66
DEBEZIUM_VERSION=2.7
7-
RESOURCE_GROUP="dbzrg"
8-
EVENTHUB_NAMESPACE="dbzeventhub"
9-
EVENTHUB_SCHEMA_HISTORY="dbzschemahistory"
10-
CONTAINER_NAME="dbzcontainer"
7+
RESOURCE_GROUP="debezium"
8+
EVENTHUB_NAMESPACE="debezium"
9+
EVENTHUB_SCHEMA_HISTORY="schemahistory"
10+
CONTAINER_NAME="debezium"
1111
LOCATION="WestUS2"
1212

1313
echo "deploying resource group"
@@ -33,7 +33,7 @@ az eventhubs eventhub create \
3333
--output none
3434

3535
echo "gathering eventhubs connection string"
36-
EH_CONNECTION_STRING=`az eventhubs namespace authorization-rule keys list --resource-group $RESOURCE_GROUP --name RootManageSharedAccessKey --namespace-name $EVENTHUB_NAMESPACE --output tsv --query 'primaryConnectionString'`
36+
EVENTHUB_CONNECTION_STRING=`az eventhubs namespace authorization-rule keys list --resource-group $RESOURCE_GROUP --name RootManageSharedAccessKey --namespace-name $EVENTHUB_NAMESPACE --output tsv --query 'primaryConnectionString'`
3737

3838
echo "deploying debezium container"
3939
az container create \
@@ -57,13 +57,13 @@ az container create \
5757
CONNECT_REQUEST_TIMEOUT_MS=60000 \
5858
CONNECT_SECURITY_PROTOCOL=SASL_SSL \
5959
CONNECT_SASL_MECHANISM=PLAIN \
60-
CONNECT_SASL_JAAS_CONFIG="org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EH_CONNECTION_STRING}\";" \
60+
CONNECT_SASL_JAAS_CONFIG="org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EVENTHUB_CONNECTION_STRING}\";" \
6161
CONNECT_PRODUCER_SECURITY_PROTOCOL=SASL_SSL \
6262
CONNECT_PRODUCER_SASL_MECHANISM=PLAIN \
63-
CONNECT_PRODUCER_SASL_JAAS_CONFIG="org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EH_CONNECTION_STRING}\";" \
63+
CONNECT_PRODUCER_SASL_JAAS_CONFIG="org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EVENTHUB_CONNECTION_STRING}\";" \
6464
CONNECT_CONSUMER_SECURITY_PROTOCOL=SASL_SSL \
6565
CONNECT_CONSUMER_SASL_MECHANISM=PLAIN \
66-
CONNECT_CONSUMER_SASL_JAAS_CONFIG="org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EH_CONNECTION_STRING}\";"
66+
CONNECT_CONSUMER_SASL_JAAS_CONFIG="org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EVENTHUB_CONNECTION_STRING}\";"
6767

6868
echo "eventhub connection string"
69-
echo $EH_CONNECTION_STRING
69+
echo $EVENTHUB_CONNECTION_STRING

debezium/azure/01-register-connector.sh

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,6 @@ set -euo pipefail
55

66
RESOURCE_GROUP="dbzrg"
77
CONTAINER_NAME="dbzcontainer"
8-
EVENTHUB_NAMESPACE="dbzeventhub"
9-
10-
echo "generating Debezium SQL Server connector configuration JSON file"
11-
EH_CONNECTION_STRING=`az eventhubs namespace authorization-rule keys list --resource-group $RESOURCE_GROUP --name RootManageSharedAccessKey --namespace-name $EVENTHUB_NAMESPACE --output tsv --query 'primaryConnectionString'`
12-
cat > ../sqlserver-connector-config.json << EOF
13-
{
14-
"name": "wwi",
15-
"config": {
16-
"snapshot.mode": "schema_only",
17-
"connector.class": "io.debezium.connector.sqlserver.SqlServerConnector",
18-
"database.hostname": "dmmssqlsrv.database.windows.net",
19-
"database.port": "1433",
20-
"database.user": "debezium-wwi",
21-
"database.password": "Abcd1234!",
22-
"database.names": "WideWorldImportersStandardCDC",
23-
"driver.encrypt": "false",
24-
"driver.trustServerCertificate": "true",
25-
"schema.history.internal.kafka.bootstrap.servers": "${EVENTHUB_NAMESPACE}.servicebus.windows.net:9093",
26-
"schema.history.internal.kafka.topic": "dbzschemahistory",
27-
"schema.history.internal.consumer.security.protocol": "SASL_SSL",
28-
"schema.history.internal.consumer.sasl.mechanism": "PLAIN",
29-
"schema.history.internal.consumer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EH_CONNECTION_STRING}\";",
30-
"schema.history.internal.producer.security.protocol": "SASL_SSL",
31-
"schema.history.internal.producer.sasl.mechanism": "PLAIN",
32-
"schema.history.internal.producer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EH_CONNECTION_STRING}\";",
33-
"table.include.list": "Sales.Orders,Warehouse.StockItems",
34-
"tombstones.on.delete": "false",
35-
"topic.prefix": "SQLAzure",
36-
"transforms": "Reroute",
37-
"transforms.Reroute.type": "io.debezium.transforms.ByLogicalTableRouter",
38-
"transforms.Reroute.topic.regex": "(.*)",
39-
"transforms.Reroute.topic.replacement": "wwi"
40-
}
41-
}
42-
EOF
43-
echo "done"
448

459
echo "finding debezium ip"
4610
DEBEZIUM_IP=`az container show --resource-group $RESOURCE_GROUP --name $CONTAINER_NAME --output tsv --query "ipAddress.ip"`

debezium/on-prem/.env.sample

Lines changed: 0 additions & 3 deletions
This file was deleted.

debezium/on-prem/.env.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
DEBEZIUM_VERSION=2.7
2-
EH_NAME=debezium
3-
EH_CONNECTION_STRING=Endpoint=sb://.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=
2+
EVENTHUB_NAMESPACE=<eventhub_namespace>
3+
EVENTHUB_CONNECTION_STRING=<eventhub_connection_string>

debezium/on-prem/docker-compose.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
ports:
66
- 8083:8083
77
environment:
8-
- BOOTSTRAP_SERVERS=${EH_NAME}.servicebus.windows.net:9093
8+
- BOOTSTRAP_SERVERS=${EVENTHUB_NAMESPACE}.servicebus.windows.net:9093
99
- GROUP_ID=1
1010
- CONFIG_STORAGE_TOPIC=debezium_configs
1111
- OFFSET_STORAGE_TOPIC=debezium_offsets
@@ -15,10 +15,10 @@ services:
1515
- CONNECT_REQUEST_TIMEOUT_MS=60000
1616
- CONNECT_SECURITY_PROTOCOL=SASL_SSL
1717
- CONNECT_SASL_MECHANISM=PLAIN
18-
- CONNECT_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="$$ConnectionString" password="${EH_CONNECTION_STRING}";
18+
- CONNECT_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="$$ConnectionString" password="${EVENTHUB_CONNECTION_STRING}";
1919
- CONNECT_PRODUCER_SECURITY_PROTOCOL=SASL_SSL
2020
- CONNECT_PRODUCER_SASL_MECHANISM=PLAIN
21-
- CONNECT_PRODUCER_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="$$ConnectionString" password="${EH_CONNECTION_STRING}";
21+
- CONNECT_PRODUCER_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="$$ConnectionString" password="${EVENTHUB_CONNECTION_STRING}";
2222
- CONNECT_CONSUMER_SECURITY_PROTOCOL=SASL_SSL
2323
- CONNECT_CONSUMER_SASL_MECHANISM=PLAIN
24-
- CONNECT_CONSUMER_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="$$ConnectionString" password="${EH_CONNECTION_STRING}";
24+
- CONNECT_CONSUMER_SASL_JAAS_CONFIG=org.apache.kafka.common.security.plain.PlainLoginModule required username="$$ConnectionString" password="${EVENTHUB_CONNECTION_STRING}";
Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,2 @@
1-
$RESOURCE_GROUP="dbzrg"
2-
$EVENTHUB_NAMESPACE="dbzeventhub"
3-
4-
$EH_CONNECTION_STRING=az eventhubs namespace authorization-rule keys list --resource-group $RESOURCE_GROUP --name RootManageSharedAccessKey --namespace-name $EVENTHUB_NAMESPACE --output tsv --query 'primaryConnectionString'
5-
6-
$SQLSERVER_CONNECTOR_CONFIG="{
7-
`"name`": `"wwi`",
8-
`"config`": {
9-
`"snapshot.mode`": `"schema_only`",
10-
`"connector.class`": `"io.debezium.connector.sqlserver.SqlServerConnector`",
11-
`"database.hostname`": `"dmmssqlsrv.database.windows.net`",
12-
`"database.port`": `"1433`",
13-
`"database.user`": `"debezium-wwi`",
14-
`"database.password`": `"Abcd1234!`",
15-
`"database.names`": `"WideWorldImportersStandardCDC`",
16-
`"driver.encrypt`": `"false`",
17-
`"driver.trustServerCertificate`": `"true`",
18-
`"schema.history.internal.kafka.bootstrap.servers`": `"${EVENTHUB_NAMESPACE}.servicebus.windows.net:9093`",
19-
`"schema.history.internal.kafka.topic`": `"dbzschemahistory`",
20-
`"schema.history.internal.consumer.security.protocol`": `"SASL_SSL`",
21-
`"schema.history.internal.consumer.sasl.mechanism`": `"PLAIN`",
22-
`"schema.history.internal.consumer.sasl.jaas.config`": `"org.apache.kafka.common.security.plain.PlainLoginModule required username=\`"`$ConnectionString\`" password=\`"${EH_CONNECTION_STRING}\`";`",
23-
`"schema.history.internal.producer.security.protocol`": `"SASL_SSL`",
24-
`"schema.history.internal.producer.sasl.mechanism`": `"PLAIN`",
25-
`"schema.history.internal.producer.sasl.jaas.config`": `"org.apache.kafka.common.security.plain.PlainLoginModule required username=\`"`$ConnectionString\`" password=\`"${EH_CONNECTION_STRING}\`";`",
26-
`"table.include.list`": `"Sales.Orders,Warehouse.StockItems`",
27-
`"tombstones.on.delete`": `"false`",
28-
`"topic.prefix`": `"SQLAzure`",
29-
`"transforms`": `"Reroute`",
30-
`"transforms.Reroute.type`": `"io.debezium.transforms.ByLogicalTableRouter`",
31-
`"transforms.Reroute.topic.regex`": `"(.*)`",
32-
`"transforms.Reroute.topic.replacement`": `"wwi`"
33-
}
34-
}"
35-
$SQLSERVER_CONNECTOR_CONFIG | Out-File '..\sqlserver-connector-config.json'
36-
371
$JSON = Get-Content '..\sqlserver-connector-config.json' | Out-String
382
Invoke-RestMethod http://localhost:8083/connectors/ -Method POST -Body $JSON -ContentType "application/json"

debezium/on-prem/register-connector.sh

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,5 @@
11
#!/bin/sh
22

3-
RESOURCE_GROUP="dbzrg"
4-
EVENTHUB_NAMESPACE="dbzeventhub"
5-
6-
echo "generating Debezium SQL Server connector configuration JSON file"
7-
EH_CONNECTION_STRING=`az eventhubs namespace authorization-rule keys list --resource-group $RESOURCE_GROUP --name RootManageSharedAccessKey --namespace-name $EVENTHUB_NAMESPACE --output tsv --query 'primaryConnectionString'`
8-
cat > ../sqlserver-connector-config.json << EOF
9-
{
10-
"name": "wwi",
11-
"config": {
12-
"snapshot.mode": "schema_only",
13-
"connector.class": "io.debezium.connector.sqlserver.SqlServerConnector",
14-
"database.hostname": "dmmssqlsrv.database.windows.net",
15-
"database.port": "1433",
16-
"database.user": "debezium-wwi",
17-
"database.password": "Abcd1234!",
18-
"database.names": "WideWorldImportersStandardCDC",
19-
"driver.encrypt": "false",
20-
"driver.trustServerCertificate": "true",
21-
"schema.history.internal.kafka.bootstrap.servers": "${EVENTHUB_NAMESPACE}.servicebus.windows.net:9093",
22-
"schema.history.internal.kafka.topic": "dbzschemahistory",
23-
"schema.history.internal.consumer.security.protocol": "SASL_SSL",
24-
"schema.history.internal.consumer.sasl.mechanism": "PLAIN",
25-
"schema.history.internal.consumer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EH_CONNECTION_STRING}\";",
26-
"schema.history.internal.producer.security.protocol": "SASL_SSL",
27-
"schema.history.internal.producer.sasl.mechanism": "PLAIN",
28-
"schema.history.internal.producer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"\$ConnectionString\" password=\"${EH_CONNECTION_STRING}\";",
29-
"table.include.list": "Sales.Orders,Warehouse.StockItems",
30-
"tombstones.on.delete": false,
31-
"topic.prefix": "SQLAzure",
32-
"transforms": "Reroute",
33-
"transforms.Reroute.type": "io.debezium.transforms.ByLogicalTableRouter",
34-
"transforms.Reroute.topic.regex": "(.*)",
35-
"transforms.Reroute.topic.replacement": "wwi"
36-
}
37-
}
38-
EOF
39-
echo "done"
40-
413
curl -i -X POST \
424
-H "Accept:application/json" \
435
-H "Content-Type:application/json" \

debezium/sqlserver-connector-config.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"driver.encrypt": "false",
1212
"driver.trustServerCertificate": "true",
1313
"schema.history.internal.kafka.bootstrap.servers": "<eventhub_namespace>.servicebus.windows.net:9093",
14-
"schema.history.internal.kafka.topic": "dbzschemahistory",
14+
"schema.history.internal.kafka.topic": "<eventhub_schema_history>",
1515
"schema.history.internal.consumer.security.protocol": "SASL_SSL",
1616
"schema.history.internal.consumer.sasl.mechanism": "PLAIN",
1717
"schema.history.internal.consumer.sasl.jaas.config": "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"$ConnectionString\" password=\"<eventhub_connectionstring>\";",

0 commit comments

Comments
 (0)