失效链接处理 |
DB2数据库开归档日志功能 PDF 下载
本站整理下载:
相关截图:
主要内容:
创建归档日志目录和离线全库备份目录:
#su - root
#mkdir -p /archive/dbtest_log
#chmod 777 -R /archive/dbtest_log
#mkdir -p /opt/db2bak
#chmod 777 -R /opt/db2bak
连接数据库:
#su - db2inst1
#db2 connect to dbtest
查看默认日志设置:
#db2 get db cfg for dbtest |grep -i log
结果如下,默认情况为循环日志
Log retain for recovery enabled (LOGRETAIN) = OFF
First log archive method (LOGARCHMETH1) = OFF
更改为归档日志模式:
#db2 update db cfg for dbtest using LOGRETAIN ON
再查看:
#db2 get db cfg for dbtest |grep -i log
结果如下,模式已改为归档日志
Log retain for recovery enabled (LOGRETAIN) = RECOVERY
First log archive method (LOGARCHMETH1) = LOGRETAIN
更改归档日志目录:
#db2 update db cfg for dbtest using LOGARCHMETH1 "DISK:/archive/dbtest_log/"
再查看:
#db2 get db cfg for dbtest |grep -i log
结果如下,归档日志路径已更改
First log archive method (LOGARCHMETH1) = DISK:/archive/dbtest_log/
断开数据库连接:
#db2 connect reset
手动归档测试:
#db2 archive log for db dbtest
如报backup pending,因为从循环日志模式改为归档日志模式所导致
查看数据库备份状态:
#db2 get db cfg for dbtest | grep -i backup
结果如下,有pending
Backup pending = YES
需要对数据库做一次离线全库备份:
#db2 backup db dbtest to /opt/db2bak
查看离线全库备份目录:
#cd /opt/db2bak
#ls
结果如下,备份成功
DBTEST.0.db2inst1.NODE0000.CATN0000.20170626140016.001
再次查看数据库备份状态:
#db2 get db cfg for dbtest | grep -i backup
结果如下,pending已解除
Backup pending = NO
再次手动归档测试:
#db2 archive log for db dbtest
查看归档日志目录:
#cd /archive/dbtest_log/db2inst1/DBTEST/NODE0000/C0000000
#ls
结果如下,备份成功
S0000000.LOG S0000001.LOG
删除离线全库备份目录:
#su - root
#rm -rf /opt/db2bak
注:关闭归档日志,即改回循环日志模式:
#db2 update db cfg for dbtest using LOGRETAIN OFF
确认归档日志已关闭:
#db2 get db cfg for dbtest |grep -i log
Log retain for recovery enabled (LOGRETAIN) = OFF
First log archive method (LOGARCHMETH1) = OFF
强制关掉归档,解除backup pending:
#db2dart dbtest /CHST /WHAT DBBP OFF
|