confluent 同步SQL server 2017数据到kafka

版权声明:本文为博主原创文章,转载请注明出处 https://blog.csdn.net/vkingnew/article/details/89156255
配置文件:


SQL server开启
ALTER DATABASE TestDB  SET CHANGE_TRACKING = ON  (CHANGE_RETENTION = 3 DAYS, AUTO_CLEANUP = ON)
go
ALTER TABLE [TestDB].dbo.[orders] ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON) 
ALTER TABLE [TestDB].dbo.[users] ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON) 


报错信息:
Msg 4997, Level 16, State 1, Server 10-19-166-249, Line 1
Cannot enable change tracking on table 'orders'. Change tracking requires a primary key on the table. Create a primary key on the table before enabling change tracking.

--报错信息:
[2019-04-09 15:51:08,321] ERROR Exception thrown while querying for ChangeKey{databaseName=TestDB, schemaName=dbo, tableName=orders} (io.confluent.connect.cdc.mssql.QueryService:94)
com.microsoft.sqlserver.jdbc.SQLServerException: Snapshot isolation transaction failed accessing database 'TestDB' because snapshot isolation is not allowed in this database. Use ALTER DATABASE to allow snapshot isolation.

ALTER DATABASE TestDB SET ALLOW_SNAPSHOT_ISOLATION ON


select name from sysobjects where xtype='u' ;

--修改表字段:
--SQL server:
alter table orders add  lastmodifytime datetime not null default getdate();
alter table orders drop constraint DF__orders__lastmodi__5BE2A6F2 ;
alter table orders drop column  lastmodifytime;
ALTER TABLE orders ALTER COLUMN id bigint not NULL;
ALTER TABLE users ALTER COLUMN id bigint not NULL;
alter table orders add constraint PK_ID primary key(id);
alter table users add constraint PK_users_ID primary key(id);
ALTER TABLE [TestDB].dbo.[users] ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON)
ALTER TABLE [TestDB].dbo.[orders] ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON)

-- 配置文件:
name=mscdc
connector.class=io.confluent.connect.cdc.mssql.MsSqlSourceConnector
tasks.max=1
initial.database=TestDB
username=sa
password=Yijiupi123
server.name=10.19.166.249
server.port=1433
change.tracking.tables=dbo.users,dbo.orders

--启动:

--查看DDL:

猜你喜欢

转载自blog.csdn.net/vkingnew/article/details/89156255