在oracle;对logmnr工具分析日志这个不陌生;对数据恢复应用场景经常用到;这里为了方便对归档日志进行分析;
当然网上有一个logmnr界面的工具;感觉很人性化;下载需要积分;为此写一个脚本。
##=========================================================== ## oracle_log_fetch.sh ## created by lottu ## 2016/08/07 ## usage: oracle_log_fetch.sh $START_TIME ##============================================================ #!/bin/bash ORACLE_SID=ora11g; START_TIME=$1; out_file="/tmp/logfilelist" sqlplus / as sysdba >/dev/null 2>&1 <<EOF set echo off set feedback off set heading off spool ${out_file} select name from v\$archived_log where next_time > to_date(‘${START_TIME}‘, ‘yyyy-mm-dd hh24:mi:ss‘); spool off exit EOF #dbms_logmnr.add_logfile(logfilename=>‘‘); awk ‘BEGIN{print "begin"}NR>10 && !/SQL/ {print "dbms_logmnr.add_logfile(logfilename=>‘\‘‘"$1"‘\‘‘);"}END{print "end; \n \/"}‘ /tmp/logfilelist.lst > addlogfile.sql sqlplus / as sysdba >/dev/null 2>&1 <<EOF start addlogfile.sql; exec dbms_logmnr.start_logmnr(options=>dbms_logmnr.dict_from_online_catalog); truncate table lottu.lottu01; insert into lottu.lottu01 select * from v$logmnr_contents; commit; exec dbms_logmnr.end_logmnr; exit EOF
时间: 2024-11-06 13:51:13