Prerequisites
- SQL Server version ≥ 2016 Service Pack 1 Standard or Enterprise Edition
- A database user with sufficient privileges to configure the database, including enabling CDC, CT and creating users
SQL Server Setup
1. Grant Database Access
- Configure one of the Connection Options to ensure Streamkap can reach your database.
2. Enable Change Data Capture
Restores
During restores, CDC will be disabled. All of the related metadata is automatically removed from the database. This applies to snapshot restores, point-in-time restores, and SQL Server Native restores from S3. After performing one of these types of restores, you can re-enable CDC and re-specify tables to track.3. Create Database User
It’s recommended to create a separate user and role for Streamkap to access your SQL Server database. Below is an example script that does that.4. Enable Snapshots
To backfill your data, the Connector needs to be able to perform snapshots (See Snapshots & Backfilling for more information). To enable this process, a table must be created for the Connector to use.Please create the signal table with the name
streamkap_signal
. It will not be recognised if given another name.Streamkap Setup
Follow these steps to configure your new connector:1. Create the Source
- Navigate to Add Connectors.
- Choose SQL Server.
2. Connection Settings
- Name: Enter a name for your connector.
- Endpoint: Specify the endpoint of the SQL Server database.
-
Port: Default is
1433
. -
Connect via SSH Tunnel: The Connector will connect to an SSH server in your network which has access to your database. This is necessary if the Connector cannot connect directly to your database.
- See SSH Tunnel for setup instructions.
-
Username: Username to access the database. By default, Streamkap scripts use
streamkap_user
. - Password: Password to access the database.
- Source Database: Specify the database to stream data from.
-
Heartbeats: Crucial for low and intermittent traffic databases. Enabled by default.
- Heartbeat Table Schema: If configured, this allows the connector to receive and acknowledge changes from low and intermittent traffic databases and prevent offsets from become stale.
- See SQL Server Heartbeats for setup instructions.
- Heartbeat Table Schema: If configured, this allows the connector to receive and acknowledge changes from low and intermittent traffic databases and prevent offsets from become stale.
3. Snapshot Settings
- Signal Table Schema: The Connector will use a table in this schema to manage snapshots. See Enable Snapshots for setup instructions.
4. Advanced Parameters
- Represent binary data as: Specifies how the data for binary columns e.g.
blob
,binary
,varbinary
should be interpreted. Your destination for this data can impact which option you choose. Default isbytes
.
5. Schema and Table Capture
- Add Schemas/Tables: Specify the schema(s) and table(s) for capture
- You can bulk upload here. The format is a simple list of schemas and tables, with each entry on a new row. Save as a
.csv
file without a header.
- You can bulk upload here. The format is a simple list of schemas and tables, with each entry on a new row. Save as a
Troubleshooting
Table schema evolution and change tracking tables
Table schema evolution and change tracking tables
When CDC is enabled for a table and changes occur to it, change events are persisted to a ‘change table’ on the SQL Server database server.If you introduce a change in the structure of the source table, for example, by adding a new column, that change is not reflected in the change table.For as long as the change table continues to use the outdated table structure, the Streamkap SQL Server Source is unable to capture change events for the table correctly.You must intervene to refresh the change table structure because of the way that CDC is implemented in SQL Server.The procedure for completing an Online refresh is simpler than running it Offline, and you can complete it without any downtime to your systems and Streamkap pipelines.For every source table that has changed, copy paste the script below into SQL Server Management Studio, change placeholders as required, and then run all queries.
Refresh change table structure (Online)
Online refresh limitation
In the interval between the source table structure changing in the source database, and _before _the change table structure is refreshed, change events continue to be captured with the outdated table structure.For example, if you added a new column to a source table, change events that are captured before the change table is refreshed will not contain the new column.If this cannot be tolerated, an Offline refresh has to be performed. However, that means downtime for whatever system made structural changes to your tables and your Streamkap pipelines.Please contact us for assistance if an Offline refresh is required.If you’re not sure what
{refresh_table}
name to use, use {schema}_{table}_v{N}
. For example, if the source table is sales.orders
then you’d use sales_orders_v2
Refresh table limitation
There cannot be more than 2 change tables for every source table.After refreshing a change table using the above script, confirm with Streamkap Support that your SQL Server Source has started streaming from the refreshed change table. Once confirmed, disable CDC on the outdated change table. Use the script below to do that.SQL
Two capture instances already exist for source table
Two capture instances already exist for source table
If you’re getting this error message when refreshing the change table structure, it’s because there cannot be more than 2 change tables for every source table.To fix the problem, 1 of the 2 change tables for the source table need to be disabled. The scripts below can help you do that.The above script should return 2 results, the 2 change tables for the
{table}
specified. Typically you would disable the oldest change table, so use the create_date
column to identify the oldest one.When you’ve identified the change table to disable, use itssource_schema
, source_table
and capture_instance
names in the query below and execute. Then, try your refresh table script again.The Connector's running but there is no data
The Connector's running but there is no data
The Connector’s running but there is no dataThere can be a number of reasons. The most common are misconfiguration of CDC and privilege grants.To diagnose, run the following script:If the query returns an error or no results check:
- you are connected to the SQL Server database with a user that has
DB_OWNER
role privileges. - if the
EXEC sys.sp_cdc_help_change_data_capture
stored procedure returns no results, the source tables you want Streamkap to capture may not be CDC enabled.
- the table(s) captured by the Connector are listed.
- there are
capture_instance
s for the capture tables. - the database user or role used by the Connector are members of the
rolename
for the capture table(s).
The SQL Server Setup scripts are failing
The SQL Server Setup scripts are failing
The SQL Server Setup scripts are failingThere can be many reasons for the Setup scripts to fail, but the scripts below can help you diagnose the issues.If any of the queries return an error or no results:
- Check you connected to the SQL Server database with a user that has
DB_OWNER
role privileges - If the
SELECT ... FROM sys.databases ...
returns no results, the database you want Streamkap to capture may not be CDC enabled - If the
EXEC sys.sp_cdc_help_change_data_capture
stored procedure returns no results, the source tables you want Streamkap to capture may not be CDC enabled