
首先要确认DB2是否启动。在root帐户下用“rcdb2
status”进行查看,如果没有要先启动DB2。
rcdb2 ( status | start | restart
| stop )


配置DB2归档模式一般需要数相应实例下的据库管理员权限,root帐户无效。用“id”命令可以查本帐户的归属。

操作系统: SUSE
linux Enterprise Server 11 SP1 64位
软件:
DB2
9.7.5。使用的IBM提供的DB2-SUSE11虚拟机
实例:
db2inst1相应帐户db2inst1
数据库:
ZZZ
查看ZZZ数据库的归档设置。
db2inst1@db2975:~/bin>
db2 get db
cfg for ZZZ | grep -i log
Log retain for
recovery
status
= NO
User exit for
logging
status
= NO
Catalog cache
size
(4KB)
(CATALOGCACHE_SZ) = 150
Log buffer size
(4KB)
(LOGBUFSZ) = 256
Log file size
(4KB)
(LOGFILSIZ) = 1024
Number of
primary log
files
(LOGPRIMARY) = 13
Number of
secondary log
files
(LOGSECOND) = 4
Changed path to
log
files
(NEWLOGPATH) =
Path to log
files
= /db2fs/db2inst1/NODE0000/SQL00003/SQLOGDIR/
Overflow log
path
(OVERFLOWLOGPATH) =
Mirror log
path
(MIRRORLOGPATH) =
First active log
file
=
Block log on
disk
full
(BLK_LOG_DSK_FUL) = NO
Block non logged
operations
(BLOCKNONLOGGED) = NO
Percent max
primary log space by transaction (MAX_LOG) =
0
Num. of active
log files for 1 active UOW(NUM_LOG_SPAN) = 0
Percent log file
reclaimed before soft chckpt (SOFTMAX) = 520
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
Options for
logarchmeth1
(LOGARCHOPT1) =
Second log
archive
method
(LOGARCHMETH2) = OFF
Options for
logarchmeth2
(LOGARCHOPT2) =
Failover log
archive
path
(FAILARCHPATH) =
Number of log
archive retries on error
(NUMARCHRETRY) = 5
Log archive
retry Delay
(secs)
(ARCHRETRYDELAY) = 20
Log pages during
index
build
(LOGINDEXBUILD) = OFF

开启归档模式
db2inst1@db2975:~/bin>
db2
update db cfg for ZZZ using LOGRETAIN ON
DB20000I The
UPDATE DATABASE CONFIGURATION command completed
successfully.
如果ZZZ数据库为使用状况的话,回复会多一些。
DB20000I The
UPDATE DATABASE CONFIGURATION command completed
successfully.
SQL1363W One or
more of the parameters submitted for immediate
modification
were not changed dynamically. For
these configuration parameters, all
applications must disconnect from
this database before the changes become
effective.
开启用户出口
db2inst1@db2975:~/bin>
db2
update db cfg for ZZZ using USEREXIT ON
DB20000I The
UPDATE DATABASE CONFIGURATION command completed
successfully.
再次查看ZZZ的配置
db2inst1@db2975:~/bin> db2 get
db cfg for ZZZ | grep -i log
Log retain for
recovery
status
= NO
User exit for
logging
status
= NO
Catalog cache
size
(4KB)
(CATALOGCACHE_SZ) = 150
Log buffer size
(4KB)
(LOGBUFSZ) = 256
Log file size
(4KB)
(LOGFILSIZ) = 1024
Number of
primary log
files
(LOGPRIMARY) = 13
Number of
secondary log
files
(LOGSECOND) = 4
Changed path to
log
files
(NEWLOGPATH) =
Path to log
files
= /db2fs/db2inst1/NODE0000/SQL00003/SQLOGDIR/
Overflow log
path
(OVERFLOWLOGPATH) =
Mirror log
path
(MIRRORLOGPATH) =
First active log
file
=
Block log on
disk
full
(BLK_LOG_DSK_FUL) = NO
Block non logged
operations
(BLOCKNONLOGGED) = NO
Percent max
primary log space by transaction (MAX_LOG) =
0
Num. of active
log files for 1 active UOW(NUM_LOG_SPAN) = 0
Percent log file
reclaimed before soft chckpt (SOFTMAX) = 520
Log retain for
recovery
enabled
(LOGRETAIN) = RECOVERY
User exit for
logging
enabled
(USEREXIT) = ON
HADR log write
synchronization
mode
(HADR_SYNCMODE) = NEARSYNC
First log archive
method
(LOGARCHMETH1) = USEREXIT
Options for
logarchmeth1
(LOGARCHOPT1) =
Second log
archive
method
(LOGARCHMETH2) = OFF
Options for
logarchmeth2
(LOGARCHOPT2) =
Failover log
archive
path
(FAILARCHPATH) =
Number of log
archive retries on error
(NUMARCHRETRY) = 5
Log archive
retry Delay
(secs)
(ARCHRETRYDELAY) = 20
Log pages during
index
build
(LOGINDEXBUILD) = OFF

这时建议做一下数据库备份,如果在线备份成功,说明设置成功。
db2inst1@db2975:~/bin>
db2 backup db
ZZZ to /tmp
Backup successful. The timestamp
for this backup image is : 20130401083641
db2inst1@db2975:~/bin>
db2 backup db
ZZZ online to /tmp
Backup successful. The timestamp
for this backup image is : 20130401083834
如果可以建议重启DB2,查看数据库重新挂载是否正常。
db2975:~ # rcdb2
restart
Stopping
DAS:
done
Stopping instance db2inst1 (50001)
(/opt/ibm/db2/V9.7):
done
Starting
DAS:
done
Starting instance db2inst1 (50001)
(/opt/ibm/db2/V9.7):
done
Activating database ZZZ for
db2inst1
done
Activating database QWE for
db2inst1
done
Activating database PPP for
db2inst1
done

自此为NBU备份DB2而设置的归档完成。
SP:
db2 get db cfg
for QQQ
查看QQQ数据库的所有配置。
db2 update db cfg for
QQQ using LOGARCHMETH1 "disk:/db2fs/"
如果不使用用户出口(USEREXIT
ON),开启归档后就要给归档指定存储位置,否则数据库无法正常挂载。
相关资料如下
NBU与Netbackup
http://blog.sina.com.cn/s/articlelist_1768282477_15_1.html
NetBackup备份DB2数据库的步骤(使用Vendor方式备份DB2归档日志)
http://blog.sina.com.cn/s/blog_6965d96d0100tu71.html
北京同力天合网络技术有限公司
TAPP(Technical
Assistance Partner Program)
朱宗智
本期明星销售:徐国力
电话:13521877225
E-mail:xgl@it9173.com
如果电话敬请告知获得途径“新浪博客”
加载中,请稍候......