首页 > 代码库 > db2无法force掉备份连接的处理办法

db2无法force掉备份连接的处理办法

在数据库在线备份的时候会与Load和ALTER TABLE <表名> ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE发生冲突导致这两种操作被挂起,而在MIS系统中数据库往往比较大(TB级别很常见),备份时候经常花费几个小时,甚至1天以上的时间。当我们急需上述两种操作的时候,就需要kill掉备份,一般步骤如下:

#1 找到备份连接[db2inst1@limt bin]$ db2 list applications show detail|grep -i back#2 force掉备份连接[db2inst1@limt bin]$ db2 "force application(26)"DB20000I  The FORCE APPLICATION command completed successfully.DB21024I  This command is asynchronous and may not be effective immediately.

然后有时我们连续执行了几次备份依然不能kill掉,我们可以用另一种手段:

#找到Process ID of client application [db2inst1@limt bin]$ db2 get snapshot for application agentid 55|less            Application SnapshotApplication handle                         = 55Application status                         = Connect CompletedStatus change time                         = Not CollectedApplication code page                      = 1208Application country/region code            = 0DUOW correlation token                     = *LOCAL.db2inst1.150104134326Application name                           = db2bpApplication ID                             = *LOCAL.db2inst1.150104134326Sequence number                            = 00001TP Monitor client user ID                  =TP Monitor client workstation name         =TP Monitor client application name         =TP Monitor client accounting string        =Connection request start timestamp         = 2015-01-04 21:43:26.408291Connect request completion timestamp       = 2015-01-04 21:43:28.310947Application idle time                      = Not CollectedCONNECT Authorization ID                   = DB2INST1Client login ID                            = db2inst1Configuration NNAME of client              = limtClient database manager product ID         = SQL10010Process ID of client application           = 4153  # 此处为要找到的BP进程号Platform of client application             = LINUXAMD64  Communication protocol of client           = Local Client#此进程为db2bp[db2inst1@limt bin]$ ps -ef|grep 4153db2inst1   4153      1  0 21:28 pts/0    00:00:00 /home/db2inst1/sqllib/bin/db2bp 3796A502 5 Adb2inst1   4961   3796  0 21:46 pts/0    00:00:00 grep 4153 [db2inst1@limt bin]$ kill -9 4153#这个时候再次查看备份连接就消失了

 

这个办法一般也适合force C程序的嵌入式SQL程序

db2无法force掉备份连接的处理办法