Script:检查数据库当前是否有备份操作在执行中

以下脚本可以用于检测数据库当前是否有备份操作在执行中:

SELECT DECODE(os_backup.backup + rman_backup.backup, 0, 'FALSE', 'TRUE') backup
  FROM (SELECT COUNT(*) backup FROM gv$backup WHERE status = 'ACTIVE') os_backup,
       (SELECT COUNT(*) backup
          FROM gv$session
         WHERE status = 'ACTIVE'
           AND client_info like '%rman%') rman_backup
/

Comments

  1. 我测试了一下:一个窗口执行rman 备份,另一个窗口查看
    sys@RAC> SELECT DECODE(os_backup.backup + rman_backup.backup, 0, ‘FALSE’, ‘TRUE’) backup
    2 FROM (SELECT COUNT(*) backup FROM v$backup WHERE status = ‘ACTIVE’) os_backup,
    3 (SELECT COUNT(*) backup
    4 FROM v$session
    5 WHERE status = ‘ACTIVE’
    6 AND client_info like ‘%id=rman%’) rman_backup
    7 /

    BACKU
    —–
    FALSE

  2. 看来是要分单实例还是rac 数据库这两种情况
    sys@RAC> SELECT DECODE(os_backup.backup + rman_backup.backup, 0, ‘FALSE’, ‘TRUE’) backup
    2 FROM (SELECT COUNT(*) backup FROM gv$backup WHERE status = ‘ACTIVE’) os_backup,
    3 (SELECT COUNT(*) backup
    4 FROM gv$session
    5 WHERE status = ‘ACTIVE’
    6 AND client_info like ‘%rman%’) rman_backup
    7 /

    BACKU
    —–
    TRUE

Trackbacks

  1. […] Script:检查数据库当前是否有备份操作在执行中 […]

  2. […] Script:データベースにバックアップしているかを確認してください […]

Comment

*

沪ICP备14014813号-2

沪公网安备 31010802001379号