-- logminer 使用 online dict and continuous mine
execute sys.DBMS_LOGMNR.START_LOGMNR(STARTSCN =>648270993 , ENDSCN =>648270993, OPTIONS =>dbms_logmnr.dict_from_online_catalog+sys.DBMS_LOGMNR.CONTINUOUS_MINE); --V$LOGMNR_DICTIONARY-------查询使用的数据字典文件 select filename from v$logmnr_dictionary; --V$LOGMNR_PARAMETERS-------查询当前LogMiner设定的参数 select * from v$logmnr_parameters; --V$LOGMNR_LOGS-------查询分析的日志文件 select filename from v$logmnr_logs; CREATE TABLE tzm.ttt18 AS select ROW_ID, SCN, XIDUSN,XIDSLT,XIDSQN, XID, TABLE_NAME, SEG_OWNER, OPERATION_CODE, CSF, SQL_REDO from v$logmnr_contents
-- logminer 指定 dict
alter system set utl_file_dir='/home/oracle/logminer' scope=spfile; shutdown immediate startup show parameter utl_file_dir execute sys.DBMS_LOGMNR.START_LOGMNR(dictfilename=>'/home/oracle/logminer/dictionary.ora',STARTSCN => 624342312, ENDSCN =>624342384, OPTIONS =>sys.DBMS_LOGMNR.CONTINUOUS_MINE);
/*
* redologfile,sequence,scn关系
*/
SELECT * FROM ( select 'onlinelog',l.GROUP#,sequence#,FIRST_CHANGE# as startscn ,NEXT_CHANGE# as endscn,l.STATUS,l.bytes fsize, to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') firsttime, to_char(NEXT_TIME,'yyyy/mm/dd:hh24:mi:ss') nexttime,MEMBER from V$log l, v$logfile lf WHERE l.GROUP#=lf.GROUP# UNION ALL select 'archivelog',recid,SEQUENCE#,FIRST_CHANGE# as startscn ,NEXT_CHANGE# AS endscn,STATUS,BLOCKS*BLOCK_SIZE AS fsize , to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') firsttime, to_char(NEXT_TIME,'yyyy/mm/dd:hh24:mi:ss') nexttime, name from v$archived_log WHERE name IS NOT NULL ) WHERE STARTscn <= 622116275 AND 622116275 <= endscn
-- show session and sql
SELECT s.SID, s.SERIAL#, s.USERNAME, s.STATUS,s.OSUSER, s.SCHEMANAME , s.LOGON_TIME , s.machine , s.program , s.seq# , s.event , sq.SQL_TEXT FROM V$SESSION s LEFT OUTER JOIN V$SQL sq ON sq.SQL_ID=s.SQL_ID WHERE s.TYPE='USER' ORDER BY 3,4,8,9,7
-- query object name by objectid
select object_name,OBJECT_ID, data_object_id, dba_objects.* from dba_objects where object_id in (5644153);
-- archiveed log size
SELECT logtime,thread#,sum(logsize)/1024/1024/1024||'GB',count(name) FROM ( SELECT thread#, TRUNC(first_time, 'dd') AS logtime, a.blocks*a.block_size AS logsize, name FROM v$archived_log a WHERE a.STATUS = 'A' AND a.dest_id = 1) li GROUP BY logtime, thread# ORDER BY logtime DESC, thread#
-- alter dump redolog
oradebug setmypid; alter system dump logfile '/opt/oracle/archivelog/archive_1_5_989852304.log' scn min 648270877 scn max 648270878; oradebug tracefile_name;
-- redolog
select lf.TYPE, l.GROUP#,sequence#,FIRST_CHANGE# as startscn ,NEXT_CHANGE# as endscn,l.STATUS,l.bytes fsize, to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') firsttime, to_char(NEXT_TIME,'yyyy/mm/dd:hh24:mi:ss') nexttime,MEMBER from V$log l, v$logfile lf WHERE l.GROUP#=lf.GROUP# ALTER DATABASE ADD logfile GROUP 12 '/opt/oracle/oradata/orcl/redo12.log' SIZE 5120m ; ALTER DATABASE ADD logfile GROUP 13 '/opt/oracle/oradata/orcl/redo13.log' SIZE 5120m ; ALTER DATABASE ADD logfile GROUP 14 '/opt/oracle/oradata/orcl/redo14.log' SIZE 5120m ; ALTER DATABASE ADD logfile GROUP 15 '/opt/oracle/oradata/orcl/redo15.log' SIZE 5120m ; ALTER DATABASE ADD logfile GROUP 16 '/opt/oracle/oradata/orcl/redo16.log' SIZE 5120m ; ALTER DATABASE ADD logfile GROUP 17 '/opt/oracle/oradata/orcl/redo17.log' SIZE 5120m ; ALTER DATABASE ADD logfile GROUP 18 '/opt/oracle/oradata/orcl/redo18.log' SIZE 5120m ; ALTER DATABASE ADD logfile GROUP 19 '/opt/oracle/oradata/orcl/redo19.log' SIZE 5120m ; ALTER DATABASE ADD logfile GROUP 20 '/opt/oracle/oradata/orcl/redo20.log' SIZE 5120m ; ALTER database DROP logfile group 8; ALTER database DROP logfile group 9; ALTER database DROP logfile group 10; ALTER database DROP logfile group 11; ALTER system switch logfile ; alter system checkpoint; alter system archive log SEQUENCE 4979;