天天看點

Oracle 10.2.0.3使用Logminor工具和把system表空間變成locally

資料庫是10.2.0.3,SID=compard

I logminor

1.判斷utl_file_dir這個參數是否設定

show parameter utl_file_dir

2.生成資料字典資訊

exec  dbms_logmnr_d.build(dictionary_filename=>'compard.ora',dictionary_location=>'/usr/tmp');

在結束的時候出現下面這個錯誤:

ORA-01301: error writing to file during flat file build

ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 1675

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 3474

ORA-06512: at "SYS.DBMS_LOGMNR_INTERNAL", line 3552

ORA-06512: at "SYS.DBMS_LOGMNR_D", line 12

ORA-06512: at line 1

metalink上面的解決方案如下: bug5518651

Solution

Do the following to recreate logminer objects:

SQL> connect / as sysdba

> spool logrun.txt

drop table SYSTEM.LOGMNR_SESSION$;

 @?/rdbms/admin/dbmslm.sql

 @?/rdbms/admin/prvtlm.plb

 @?/rdbms/admin/dbmslmd.sql

@?/rdbms/admin/prvtlmd.plb

 @?/rdbms/admin/prvtlmc.plb

.*Note: the spool step is not required but will record errors if needed for further analysis.                     

不過我沒有管他,因為此時資料字典檔案已經産生。最後我重新試了一下,其實按照metalink上的solution做了之後,還有這個錯誤。

3.添加分析對象,線上離線日志都可以。

 exec dbms_logmnr.add_logfile(logfilename=>'/uattest/uat/db/apps_st/data/log03b.dbf',options=>dbms_logmnr.new);

這裡的options選項有三個參數可以用:

NEW - 表示建立一個新的日志檔案清單

ADDFILE - 表示向這個清單中添加日志檔案,一次分析多個日志

REMOVEFILE - 和addfile相反。

4.開始分析:exec dbms_logmnr.start_logmnr(DictFileName =>'/usr/tmp/compard.ora');

察看結果:

  select scn,cscn,TIMESTAMP,sql_undo from v$logmnr_contents;

可以使用create table apps.<tablename> as select * from v$logmnr_contents這樣就容易檢視了。

5.結束分析:execute dbms_logmnr.end_logmnr;

II:把system表空間變成local

shutdown immediate

startup restrict

select 'alter tablespace '||tablespace_name||' read only;' from dba_tablespaces

除了sysaux,temporary,unod不可以外。

alter tablespace SYSAUX offline;

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

如果有2個以上的temporary tablespace需要drop一個

drop tablespace temp1;

 execute DBMS_SPACE_ADMIN.TABLESPACE_MIGRATE_TO_LOCAL ('SYSTEM');

alter tablespace SYSAUX online;

select 'alter tablespace '||tablespace_name||' read write;' from dba_tablespaces

where status='READ ONLY';

select status from dba_tablespaces;

alter system disable restricted session或者重新啟動資料庫

然後shutdown immediate

startup

繼續閱讀