当做在线备份,即加上online参数后,可以看到如下告警:
[db2inst1@localhost backup]$ db2 backup db sample online to /dev/null
SQL2413N Online backup is not allowed because the database is not recoverable
or a backup pending condition is in effect.
很简单,只要改成offline的默认备份方式即可:
[db2inst1@localhost backup]$ db2 backup db sample to /dev/null
Backup successful. The timestamp for this backup image is : 20131125221418
再次连接DB,就OK了:
[db2inst1@localhost backup]$ db2 connect to sample
Database Connection Information
Database server = DB2/LINUX 9.7.5
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
这时我们可以测试下日志归档是否成功:
[db2inst1@localhost backup]$ db2 terminate
DB20000I The TERMINATE command completed successfully.
[db2inst1@localhost backup]$ db2 archive log for db sample
DB20000I The ARCHIVE LOG command completed successfully.
再去LOGARCHMETH1设置的目录下可以发现有如下路径,日志成功归档:
[db2inst1@localhost C0000000]$ pwd
/db2src/TS/backup/db2inst1/SAMPLE/NODE0000/C0000000
[db2inst1@localhost C0000000]$ ls
S0000000.LOG
这样就完成了日志归档到磁盘的设置工作,可以看到工作还是相当简化的,只要配置了归档方式,重启DB2后还需要做一个离线备份,即可完成DB2的归档配置,这样DB2在被启动手工归档或者日志空间不足的时候就会自动归档到这个目录。