SQL1116N A connection to or activation of database "T_1" cannot be made because of BACKUP PENDING.

今天客户这里需要做DB2数据库的迁移,有好长时间没有做DB2了,只好就依照oracle来做DB2啦

首先更改了数据库的日志模式:

查看归档模式
db2 get db cfg for db_name |grep -i log;默认是关闭的
结果如下:
Log retain for recovery enabled             (LOGRETAIN) = OFF
User exit for logging enabled                (USEREXIT) = OFF
HADR log write synchronization mode     (HADR_SYNCMODE) = NEARSYNC
First log archive method                 (LOGARCHMETH1) = OFF
更改为归档日志:
db2 update db cfg for db_name using LOGRETAIN ON
更改归档目录:
db2 update db cfg for db_name using LOGARCHMETH1 "disk:/archive/db_name_db_log"

在我重新连接数据库的时候提示:

db2 connect to t_1 to mydb
SQL1116N  A connection to or activation of database "T_1" cannot be made
because of BACKUP PENDING.  SQLSTATE=57019


网上找了n多最后才知道

若修改数据库LOGRETAIN参数,从循环日志模式改为归档日志模式,则会导致数据库backup pending状态。

如:
执行“db2 update db cfg for
mydb using LOGRETAIN RECOVERY”
数据库状态“Backup pending = YES”
此时就无法连接,访问数据库“SQL1116N A connection to or activation of database "sampledb" cannot be made because of BACKUP PENDING. SQLSTATE=57019”
因此,需要对数据库做离线全库备份,使状态恢复正常,以便正常访问。

db2 backup db mydb  to /opt/bak

db2inst2@DB2Server01:~> db2 connect to mydb


   Database Connection Information


 Database server        = DB2/LINUXX8664 9.7.5
 SQL authorization ID   = DB2INST2
 Local database alias   =
MYDB

这是pending为no

 db2 get db cfg for t_1 | grep Backup
 Backup pending                                          = NO


你可能感兴趣的:(sql,数据库,db2,database,authorization,archive)