sqlserver CDC is always running? when node is failove on always on cluster

he katty 1 Reputation point
2021-04-16T08:11:45.917+00:00

recently, i enable CDC on sqlserver with always on cluster, but when the primary is down, then there can be a change, then the secondary can be primary and primary will be secondary when it is up, but i see the CDC disappeared , and if i cannot capture the data change with the original primary node connection.

SQL Server | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cris Zhan-MSFT 6,661 Reputation points
    2021-04-19T06:09:23.057+00:00

    Hi,

    According to your description, I think what you said "always on cluster" refers to the Always On availability groups. Using CDC with an availability group, you need to create CDC jobs on the primary replica or possible primary replica (failover), and only enable it on the primary replica.

    Please check the document- Replication, change tracking, & change data capture - Always On availability groups.

    You should create the jobs at the new primary replica after failover. The CDC jobs running at the old primary database should be disabled when the local database becomes a secondary database. Post this if the replica becomes primary again, you need to reenable the CDC jobs on the replica. To disable and enable jobs, use the @enabled option of sp_update_job (Transact-SQL). For more information about creating CDC jobs, see sys.sp_cdc_add_job (Transact-SQL).

    In addition here is a post about how CDC jobs are always enabled only on the current primary replica.
    https://dba.stackexchange.com/questions/139231/cdc-with-alwayson-availability-groups


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.