【已解决】怎样确认是否做过dump tran with truncate_only操作?
本帖最后由 Gubuntu 于 2010-11-29 21:02 编辑情况是这样的,我们的数据库每周日做全量备份,其余每天做一次增量备份
但数据库的阈值存储过程里面有dump tran with truncate_only操作
这样会导致后续增量备份失败的,除非再做一次全量备份
客户对此很不满
所以想在备份开始时判断日志是否被dump tran with truncate_only过,如果有,则下一次自动转为全量备份。
不知道有没有办法确认是否做过dump tran with truncate_only
有其它自动转全量的方法也行 可以考虑变通做法
1.在阀值过程写标志位到一个什么表,甚至直接print信息到errorlog都行
2.dump database后取@@error也可以。 如果是ase15.0的话, 有个函数tran_dumpable_status()
-----------------------------------------------------------------------------------
tran_dumpable_status
Description
Returns a true/false indication of whether dump transaction is allowed.
Syntax
tran_dumpable_status("database_name")
Parameters
database_name
is the name of the target database.
Examples
Example 1
Checks to see if the pubs2 database can be dumped:
1> select tran_dumpable_status("pubs2")
2> go
-----------
106
(1 row affected)
In this example, you cannot dump pubs2. The return code of 106 is a sum of all the conditions met (2, 8, 32, 64). See the Usage section for a description of the return codes.
Usage
tran_dumpable_status allows you to determine if dump transaction is allowed on a database without having to run the command. tran_dumpable_status performs all of the checks that Adaptive Server performs when dump transaction is issued.
If tran_dumpable_status returns 0, you can perform the dump transaction command on the database. If it returns any other value, it cannot. The non-0 values are:
*
1 – A database with the name you specified does not exist.
*
2 – A log does not exist on a separate device.
*
4 – The log first page is in the bounds of a data-only disk fragment.
*
8 – the trunc log on chkpt option is set for the database.
*
16 – Non-logged writes have occurred on the database.
*
32 – Truncate-only dump tran has interrupted any coherent sequence of dumps to dump devices.
*
64 – Database is newly created or upgraded. Transaction log may not be dumped until a dump database has been performed. 多谢两位,我研究研究先:) 如果是ase15.0的话, 有个函数tran_dumpable_status()
---------------------------------------------- ...
andkylee 发表于 2010-11-29 15:48 http://bbs.chinaunix.net/images/common/back.gif
这个方法不错,我试过了,应该可以。:P 返回结果32就可以了是吗? 回复 6# hefan
返回0表示正常的,是可以dump tran。 其它都是异常。
请参考:
如果 tran_dumpable_status 返回 0,则可以对数据库执行 dump transaction命令。如果返回任何其它值,则无法执行该命令。非零值有:
1 — 指定名称的数据库不存在。
2 — 日志没有放置在单独的设备上。
4 — 日志首页位于仅限数据的磁盘片段区域内。
8 — 为数据库设置了 trunc log on chkpt 选项。
16 — 在数据库上发生了未记录的写入操作。
32 — 仅截断 dump tran 已中断发送到转储设备的任意连续的转储系列。
64 — 最近创建或升级了数据库。在执行 dump database 之前,不会转储事务日志。 checkDumpDB()
{
db=$1
isql -Usa -P${passwd} -S${dbsvr} <<EOF > /tmp/$db.tmp
use master
go
select tran_dumpable_status("$db")
go
EOF
dumpStatus=`cat /tmp/$db.tmp | sed'1d;2d;$d' | xargs`
if [ "$dumpStatus" -ne 0 ]
then
echo tran_dumpable_status_fail
exit $dumpStatus
fi
} 对“32 — 仅截断 dump tran 已中断发送到转储设备的任意连续的转储系列。”这句有点不大理解
请教哪位详细说一下。
页:
[1]