免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7006 | 回复: 8
打印 上一主题 下一主题

【已解决】怎样确认是否做过dump tran with truncate_only操作? [复制链接]

论坛徽章:
1
巨蟹座
日期:2014-08-15 14:56:13
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-11-29 14:46 |只看该作者 |倒序浏览
本帖最后由 Gubuntu 于 2010-11-29 21:02 编辑

情况是这样的,我们的数据库每周日做全量备份,其余每天做一次增量备份
但数据库的阈值存储过程里面有dump tran with truncate_only操作
这样会导致后续增量备份失败的,除非再做一次全量备份

客户对此很不满

所以想在备份开始时判断日志是否被dump tran with truncate_only过,如果有,则下一次自动转为全量备份。
不知道有没有办法确认是否做过dump tran with truncate_only

有其它自动转全量的方法也行

论坛徽章:
0
2 [报告]
发表于 2010-11-29 15:08 |只看该作者
可以考虑变通做法
1.在阀值过程写标志位到一个什么表,甚至直接print信息到errorlog都行
2.dump database后取@@error也可以。

论坛徽章:
6
水瓶座
日期:2014-06-04 03:34:37水瓶座
日期:2014-06-17 13:20:31数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00数据库技术版块每日发帖之星
日期:2016-07-17 06:20:00数据库技术版块每日发帖之星
日期:2016-08-01 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
3 [报告]
发表于 2010-11-29 15:48 |只看该作者
如果是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.

论坛徽章:
1
巨蟹座
日期:2014-08-15 14:56:13
4 [报告]
发表于 2010-11-29 18:23 |只看该作者
多谢两位,我研究研究先:)

论坛徽章:
1
巨蟹座
日期:2014-08-15 14:56:13
5 [报告]
发表于 2010-11-29 18:36 |只看该作者
如果是ase15.0的话, 有个函数tran_dumpable_status()

---------------------------------------------- ...
andkylee 发表于 2010-11-29 15:48



    这个方法不错,我试过了,应该可以。

论坛徽章:
0
6 [报告]
发表于 2011-03-04 17:48 |只看该作者
返回结果32就可以了是吗?

论坛徽章:
6
水瓶座
日期:2014-06-04 03:34:37水瓶座
日期:2014-06-17 13:20:31数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00数据库技术版块每日发帖之星
日期:2016-07-17 06:20:00数据库技术版块每日发帖之星
日期:2016-08-01 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
7 [报告]
发表于 2011-03-04 19:21 |只看该作者
回复 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 之前,不会转储事务日志。

论坛徽章:
1
巨蟹座
日期:2014-08-15 14:56:13
8 [报告]
发表于 2011-03-21 21:11 |只看该作者
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
}

论坛徽章:
0
9 [报告]
发表于 2011-03-25 13:04 |只看该作者
对“32 — 仅截断 dump tran 已中断发送到转储设备的任意连续的转储系列。”这句有点不大理解

请教哪位详细说一下。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP