Chinaunix首页 | 论坛 | 博客
  • 博客访问: 282569
  • 博文数量: 107
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 74
  • 用 户 组: 普通用户
  • 注册时间: 2016-11-18 09:57
文章分类

全部博文(107)

文章存档

2023年(2)

2021年(1)

2017年(1)

2015年(4)

2014年(9)

2013年(4)

2012年(14)

2011年(49)

2010年(23)

分类: LINUX

2012-02-03 18:26:03


 
 ======================打开DB2热备的操作日志=================================
 
[db2inst1@zhaohh ~]$ db2 connect to TEST1
   Database Connection Information
 Database server        = DB2/LINUX 9.5.0
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST1
[db2inst1@zhaohh ~]$ db2 update db cfg for MYNEWDB using logretain recovery
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
[db2inst1@zhaohh ~]$ db2 connect reset
DB20000I  The SQL command completed successfully.
[db2inst1@zhaohh ~]$ db2 connect to TEST1
SQL1116N  A connection to or activation of database "TEST1" cannot be made
because of BACKUP PENDING.  SQLSTATE=57019
[db2inst1@zhaohh ~]$ db2 connect to TEST1
SQL1116N  A connection to or activation of database "TEST1" cannot be made
because of BACKUP PENDING.  SQLSTATE=57019
[db2inst1@zhaohh ~]$ db2 BACKUP DATABASE MYNEWDB  to /home/db2inst1/
Backup successful. The timestamp for this backup image is : 20120204021515
[db2inst1@zhaohh ~]$ db2 connect to TEST1
   Database Connection Information
 Database server        = DB2/LINUX 9.5.0
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST1
 
 
 [db2inst1@zhaohh ~]$ db2 BACKUP DATABASE MYNEWDB online  to /home/db2inst1/
SQL1433N  The application is already connected to "TEST1" while the command
issued requires a connection to "MYNEWDB" for successful execution.
[db2inst1@zhaohh ~]$ db2 connect to TEST1
   Database Connection Information
 Database server        = DB2/LINUX 9.5.0
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST1
[db2inst1@zhaohh ~]$ db2 BACKUP DATABASE MYNEWDB online  to /home/db2inst1/
SQL1433N  The application is already connected to "TEST1" while the command
issued requires a connection to "MYNEWDB" for successful execution.
[db2inst1@zhaohh ~]$ db2 BACKUP DATABASE TEST1 online  to /home/db2inst1/
Backup successful. The timestamp for this backup image is : 20120204021737
供参考打开userexit参数和trackmod参数:
[db2inst1@zhaohh ~]$
[db2inst1@zhaohh ~]$ db2 update db cfg for MYNEWDB using userexit on
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
对于低版本的db2,如8.1及8.1以下版本,建议做数据库全备,增量备,数据库日志文件级备份用于恢复。
用userexit的方法较为复杂,不建议打开。但这样做需要定时手工清除数据库归档日志。

[db2inst1@zhaohh ~]$ db2 connect to TEST1
   Database Connection Information
 Database server        = DB2/LINUX 9.5.0
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST1
[db2inst1@zhaohh ~]$ db2 update db cfg for MYNEWDB using trackmod on
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
[db2inst1@zhaohh ~]$ db2 connect to TEST1
   Database Connection Information
 Database server        = DB2/LINUX 9.5.0
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST1
注意:db2 8.1及低于8.1的版本需要重置连接。只有启动了trackmod参数db2才支持增量备份。
[db2inst1@zhaohh ~]$ db2 connect reset
DB20000I  The SQL command completed successfully.
[db2inst1@zhaohh ~]$ db2 BACKUP DATABASE test1 online  to /home/db2inst1/
Backup successful. The timestamp for this backup image is : 20120204022442
 

恢复db2数据库:
用以下命令查看www库的相关备份信息,找到最新的用于恢复,恢复前drop www库:
db2 list history backup all for www
db2 restore database www load C:\progra~1\veritas\netbackup\bin\nbdb2.dll taken at 20120213155755
恢复完毕后用备份的数据库日志做回滚,否则数据库处于pending 状态:
。。。
注意: C:\progra~1\veritas\netbackup\bin\nbdb2.dll是安装了nbu client agent后才生成的。
有时恢复DB2数据库时,可能出现数据库处于rollforward pending状态而无法连接的情况,下面的命令可以手动解除rollforward pending状态:
db2 rollforward db to end of logs and stop
 
 
 
 
 
 
 
 
 
阅读(2808) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~