select *
from (SELECT h.event "Wait Event",
SUM(h.wait_time + h.time_waited) / 1000000 "Total Wait Time"
FROM v$active_session_history h, v$event_name e
WHERE sample_time between
to_date('2020-05-16 05:45', 'yyyy-mm-dd hh24:mi') and
to_date('2020-05-16 06:30', 'yyyy-mm-dd hh24:mi')
AND h.event_id = e.event_id
AND e.wait_class <> 'Idle'
GROUP BY h.event
ORDER BY 2 DESC)
where rownum < 10;
---发现数据库现在正在进行备份
---此库备份模式NFS+rman
--查询备份情况
select to_char(vw.sid) sid,
to_char(v.serial#) serial,
to_char(v.last_call_et) call,
vw.event,
to_char(v.username) username,
v.sql_id,
v.client_info,
to_char(v.BLOCKING_SESSION) bk,
v.program
from v$session_wait vw, v$session v
where vw.sid = v.sid
and vw.event not like '%message%'
and vw.event not like '%Streams%'
and username is not null
order by vw.event, v.username desc;
--更全备份信息
SELECT B.RECID BackupSet_ID,
A.SET_STAMP,
DECODE (B.INCREMENTAL_LEVEL,
'', DECODE (BACKUP_TYPE, 'L', 'Archivelog', 'Full'),
1, 'Incr-1级',
0, 'Incr-0级',
B.INCREMENTAL_LEVEL)
"Type LV",
B.CONTROLFILE_INCLUDED "包含CTL",
DECODE (A.STATUS,
'A', 'AVAILABLE',
'D', 'DELETED',
'X', 'EXPIRED',
'ERROR')
"STATUS",
A.DEVICE_TYPE "Device Type",
A.START_TIME "Start Time",
A.COMPLETION_TIME "Completion Time",
A.ELAPSED_SECONDS "Elapsed Seconds",
A.BYTES/1024/1024/1024 "Size(G)",
A.COMPRESSED,
A.TAG "Tag",
A.HANDLE "Path"
FROM GV$BACKUP_PIECE A, GV$BACKUP_SET B
WHERE A.SET_STAMP = B.SET_STAMP AND A.DELETED = 'NO'
ORDER BY A.COMPLETION_TIME DESC;
--备份进度
SELECT SID, SERIAL#, opname,ROUND(SOFAR/TOTALWORK*100)||'%' "%_COMPLETE",
TRUNC(elapsed_seconds/60) || ':' || MOD(elapsed_seconds,60) elapsed,
TRUNC(time_remaining/60) || ':' || MOD(time_remaining,60) remaining,
CONTEXT,target,SOFAR, TOTALWORK
FROM V$SESSION_LONGOPS
WHERE OPNAME LIKE 'RMAN%'
AND OPNAME NOT LIKE '%aggregate%'
AND TOTALWORK != 0
AND SOFAR <> TOTALWORK;
--综上;NFS+RMAN 备份方式导致数据告警