[20141210]使用logminer看远程归档文件(补充).txt
--如果要在本机看其他主机的归档或者日志文件,由于dbid不一样,是无法查看的.必须要包括字典信息.
--如果需要查看别的数据库的归档文件,必须要有别的数据字典文件。正常需要使用utl_file_dir,而经常这个参数没有设置。
--在使用如下命令建立数据字典。
exec dbms_logmnr.start_logmnr(dictfilename=>'/home/oracle11g/testd/dict_test.ora');
--如果没有建立参数utl_file_dir:
SYS@test> show parameter utl_file_dir
NAME TYPE VALUE
-------------- -------- --------------------
utl_file_dir string
SYS@test> exec dbms_logmnr.start_logmnr(dictfilename=>'/home/oracle11g/testd/dict_test.ora');
BEGIN dbms_logmnr.start_logmnr(dictfilename=>'/home/oracle11g/testd/dict_test.ora'); END;
*
ERROR at line 1:
ORA-01292: no log file has been specified for the current LogMiner session
ORA-06512: at "SYS.DBMS_LOGMNR", line 58
ORA-06512: at line 1
--实际上可以使用EXECUTE DBMS_LOGMNR_D.BUILD(OPTIONS=> DBMS_LOGMNR_D.STORE_IN_REDO_LOGS);前提是建立附加日志。
--就可以把字典放在日志文件中。把归档以及日志在拷贝过了就可以了。自己已经做了测试。参考链接:
http://blog.itpub.net/267265/viewspace-1360796/
--我当时是先执行,打开附件日志。
SYS@test> alter database add supplemental log data;
Database altered.
SYS@test> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 13
Next log sequence to archive 15
Current log sequence 15
SYS@test> EXECUTE DBMS_LOGMNR_D.BUILD(OPTIONS=> DBMS_LOGMNR_D.STORE_IN_REDO_LOGS);
PL/SQL procedure successfully completed.
SYS@test> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 15
Next log sequence to archive 17
Current log sequence 17
$ ls -l 2014_12_08/
total 18704
-rw-r----- 1 oracle oinstall 9434112 2014-12-08 12:00:16 o1_mf_1_14_b8b8lj2y_.arc
-rw-r----- 1 oracle oinstall 12288 2014-12-08 12:00:55 o1_mf_1_15_b8b8mq3g_.arc
-rw-r----- 1 oracle oinstall 9432064 2014-12-08 12:00:58 o1_mf_1_16_b8b8mt39_.arc
--可以发现发生了两次arhcive log 切换。我估计执行前先切换1次,执行完成后再切换1次。这样数据字典在o1_mf_1_16_b8b8mt39_.arc
--中。
--这样来确定数据字典在那个archive log 文件中的。实际上还可以通过v$archived_log视图的dictionary_begin,dictionary_end来确定。
--例子:
SYS@test> select name,sequence#,first_change#,next_change#,blocks,dictionary_begin,dictionary_end from V$ARCHIVED_LOG ;
NAME SEQUENCE# FIRST_CHANGE# NEXT_CHANGE# BLOCKS DIC DIC
------------------------------------------------------------------------------------------ ------------ ------------- ------------ ------------ --- ---
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_10_b8b8df1n_.arc 10 931129 931303 161 NO NO
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_11_b8b8fk0f_.arc 11 931303 931316 1 NO NO
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_12_b8b8kh27_.arc 12 931316 931554 171 YES NO
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_13_b8b8lf2o_.arc 13 931554 931761 170 YES NO
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_14_b8b8lj2y_.arc 14 931761 932735 18425 YES YES
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_15_b8b8mq3g_.arc 15 932735 932756 23 NO NO
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_16_b8b8mt39_.arc 16 932756 933718 18421 YES YES
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_17_b8b9565v_.arc 17 933718 934020 1953 NO NO
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_18_b8b9qgnt_.arc 18 934020 934793 973 NO NO
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_08/o1_mf_1_19_b8b9qhjd_.arc 19 934793 935755 18420 YES YES
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_09/o1_mf_1_20_b8d0v1dq_.arc 20 935755 966171 88585 NO NO
/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_12_09/o1_mf_1_21_b8g3fsbh_.arc 21 966171 998811 88596 NO NO
12 rows selected.