1、在外部进行冷启动,利用冷启动清除旧数据 /datatest11/dbtest11/sqllib/bin/asncap capture_schema=asncdc capture_server=DOEDVLP startmode=cold & 参考文档:https://www.ibm.com/docs/en/idr/11.4.0?topic=zos-asncap-starting-capture 如果cdc进程未启动成功用如下命令查找删除冷启动进程: ps -ef | grep cdc kill -9 pid
2、再次进入db2正常热启动asncdc进程(默认启动方式warmsi (default) ) /datatest11/dbtest11/sqllib/bin/asncap capture_schema=asncdc capture_server=DOEDVLP &
3、再次查看asncdc状态 db2 =>VALUES ASNCDC.ASNCDCSERVICES('status','asncdc') 就可以看到成功启动的状态如下:
2023-05-18-11.15.31.336548 ASN0600I "AsnCcmd" : "" : "Initial" : Program "capcmd 11.4.0 (Build 11.1.4.7 Level s2204041200, PTF DYN2204041200AMD64)" is starting. 2023-05-18-11.15.33.355436 ASN0520I "AsnCcmd" : "ASNCDC" : "Initial" : The STATUS command response: "HoldLThread" thread is in the "is waiting" state.
2023-05-18-11.15.33.355558 ASN0520I "AsnCcmd" : "ASNCDC" : "Initial" : The STATUS command response: "AdminThread" thread is in the "is resting" state.
2023-05-18-11.15.33.355575 ASN0520I "AsnCcmd" : "ASNCDC" : "Initial" : The STATUS command response: "PruneThread" thread is in the "is resting" state.
2023-05-18-11.15.33.355585 ASN0520I "AsnCcmd" : "ASNCDC" : "Initial" : The STATUS command response: "WorkerThread" thread is in the "is doing work" state.
4、如果看到如下日志 ASN0109I CAPTURE "ASNCDC" : "WorkerThread". The Capture program has successfully initialized and is capturing data changes for "0" registrations. "0" registrations are in a stopped state. "6" registrations are in an inactive state. 表明asncdc进程启动后,但有六个表注册处于非活跃状态,解决方法需要从捕获模式删除这些表,再重新加入捕获模式
5、删除和加入捕获模式
从捕获模式删除表
CALL ASNCDC.REMOVETABLE('MYSCHEMA', 'MYTABLE')
将表置于捕获模式
CALL ASNCDC.ADDTABLE('MYSCHEMA', 'MYTABLE')
此时可以关注 Schema-ASNCDC-Tables-IBMSNAP_REGISTER表中数据的变化
6、重新初始化 ASN 服务 VALUES ASNCDC.ASNCDCSERVICES('reinit','asncdc')
出现如下消息则表示所有表都捕获程序已成功初始化并正在捕获数据: ASN0023I CAPTURE "ASNCDC" : "WorkerThread". The Capture program has been reinitialized and is capturing changes for "7" registrations. "0" registrations are in a stopped state. "0" registrations are in an inactive state. 此时异常状态修复完成,问题解决