問題描述
這個問題與:Debezium 如何使用 Kafka Connect 正確注冊 SqlServer 連接器 - 連接被拒絕
在 Windows 10 中,我在 Docker 容器外部的 Microsoft SQL Server 實例上運行 Debezium.我每 390 毫秒收到以下警告:
In Windows 10, I have Debezium running on an instance of Microsoft SQL Server that is outside of a Docker container. I am getting the following warning every 390 milliseconds:
數據庫中沒有記錄最大LSN;請確保 SQL服務器代理正在運行
[io.debezium.connector.sqlserver.SqlServerStreamingChangeEventSource]
No maximum LSN recorded in the database; please ensure that the SQL Server Agent is running
[io.debezium.connector.sqlserver.SqlServerStreamingChangeEventSource]
我在 Github 上檢查了 Debezium 的代碼,唯一能找到此警告的地方在代碼注釋中指出,只有在 Agent 未運行時才應拋出此警告.我已確認 SQL Server 代理正在運行.
I checked Debezium's code on Github and the only place that I can find this warning states in the code comments that this warning should only be thrown if the Agent is not running. I have confirmed that the SQL Server Agent is running.
為什么會出現此警告,我該如何解決?
Why is this warning showing up and how do I fix it?
注意:
我當前的解決方案似乎只適用于非生產環境 - 根據 Docker 的文檔.
My current solution appears to only work in a non-production environment - per Docker's documentation.
推薦答案
LSN 是與 SQL Server 更改相關的片段"信息.如果您沒有 LSN,則可能是您的 CDC 未運行或未正確配置.Debezium 使用 LSN 進行復制,因此您的 SQL Server 需要生成它.
LSN is the "pieces" of information related about your SQL Server changes. If you don't have LSN, is possible that your CDC is not running or not configured properly. Debezium consumes LSNs to replicate so, your SQL Server need to generate this.
一些方法:
- 您是否檢查過您的表是否啟用了 CDC?這將列出啟用 CDC 的表:
SELECT s.name AS Schema_Name, tb.name AS Table_Name
, tb.object_id, tb.type, tb.type_desc, tb.is_tracked_by_cdc
FROM sys.tables tb
INNER JOIN sys.schemas s on s.schema_id = tb.schema_id
WHERE tb.is_tracked_by_cdc = 1
- 您的 CDC 數據庫已啟用并運行?(參見 這里)
檢查是否啟用:
SELECT *
FROM sys.change_tracking_databases
WHERE database_id=DB_ID('MyDatabase')
并檢查是否正在運行:
EXECUTE sys.sp_cdc_enable_db;
GO
- 您的 CDC 服務是否在 SQL Server 上運行?請參閱 在文檔中
EXEC sys.sp_cdc_start_job;
GO
- 在 CDC 中啟用表時,我在使用角色名稱時遇到了一些問題.就我而言,在
null
處配置解決了我的問題(更多詳細信息 此處)
- On enabling table in CDC, I had some issues with rolename. For my case, configuring at
null
solved my problem (more details here)
EXEC sys.sp_cdc_enable_table
@source_schema=N'dbo',
@source_name=N'AD6010',
@capture_instance=N'ZZZZ_AD6010',
@role_name = NULL,
@filegroup_name=N'CDC_DATA',
@supports_net_changes=1
GO
這篇關于Debezium:數據庫中沒有記錄最大LSN;請確保 SQL Server 代理正在運行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!