1、做好关库前备份,有备无患rman
检查最近备份情况:
col status for a10
col input_type for a20
col INPUT_BYTES_DISPLAY for a10
col OUTPUT_BYTES_DISPLAY for a10
col TIME_TAKEN_DISPLAY for a10
select * from(
select input_type,
status,
to_char(start_time,
'yyyy-mm-dd hh24:mi:ss'),
to_char(end_time,
'yyyy-mm-dd hh24:mi:ss'),
input_bytes_display,
output_bytes_display,
time_taken_display,
COMPRESSION_RATIO
from v\$rman_backup_job_details
order by 3 desc ) where rownum < 5;
2、检查alert、trace是否有报错 adrci或者查询alert日志视图
col message_text format a160
select message_text as ALert_log_error_last_24hours
from v\$diag_alert_ext
where originating_timestamp > (sysdate - 1) and message_text like '%ORA-%';
3、执行一些动作:
$lsnrctl stop 关闭监听
alter system checkpoint 执行检查点,刷出缓存脏数据
alter system switch logfile 切换日志文件,进行归档,该操作也会触发checkpoint,再查看alert文件是否报错
(alter system archive log current 归档当前日志文件)
4、查看redo log日志信息及其状态
col member for a45
col status for a8
select a.thread#,a.group#,a.bytes/1024/1024 m,b.member,a.status from v$log a,v$logfile b where a.group#=b.group# order by 2;
5、检查是否存在Dead事务
select ADDR,KTUXEUSN,KTUXESLT,KTUXESQN,KTUXESIZ from x$ktuxe where KTUXECFL='DEAD';
可以预估回滚时间:
通过估算事务 undo 空间减少的速度,可以估算事务回滚完成的时间大约0.3天,7个小时左右。
set serveroutput on declare l_start number; l_end number; begin select ktuxesiz into l_start from x$ktuxe where KTUXEUSN=11 and KTUXESLT=33; dbms_lock.sleep(60); select ktuxesiz into l_end from x$ktuxe where KTUXEUSN=11 and KTUXESLT=33; dbms_output.put_line('time est Day:'|| round(l_end/(l_start -l_end)/60/24,2)); end;
6、检查是否存在active状态的文件(处于begin backup active状态的文件需要end backup)
select status from v$backup;
7、需要恢复的数据文件:
select file#,online_status from v$recover_file
select * from v$recover_log
8、所有数据文件状态,必要时检查对应的物理文件(datafile,control file)是否正确存在
col name for a60
col status for a10
select name,status from v$datafile;
host ls -lrht 'filename'
select status ,name from v\$controlfile where status='INVALID';
9、检查是否存在坏块
select * from gv\$database_block_corruption;
10、kill掉所有前端进程
ps -ef|grep -v grep|grep LOCAL=NO|awk '{print $2}'|xargs kill -9
(或者对应的alter system kill session的语法:
set linesize 260 pagesize 10000
col machine for a60
select machine, 'alter system kill session ' || ''''||sid|| ',' || serial# ||''''|| 'immediate;',status
from v$session
where type='USER' and status='ACTIVE';)
11、安全停库:
shutdown immediate




