本文主要是通過介紹Oracle數據庫恢復的相關實際應用語句來引出如何恢復正常的Oracle數據庫,如果你在Oracle數據庫存在不解之處時,你不妨浏覽下面的文章,希望你能從中獲得自己想要的東西。
事情起由是在Oracle 10g手動建庫腳本中看到dbms_backup_restore.zerodbid(0)過程,其中作用是修改數據庫的dbid。於是想通過該存儲直接在sqlplus中執行修改dbid。
修改之前記錄其dbid
引用
- SQL> select dbid from v$database;
- DBID
- 1488207495
修改dbid
引用
- SQL> exec dbms_backup_restore.zerodbid(0);
- PL/SQL procedure successfully completed.
貌似執行成功了,但隨後alert日志顯示ckpt進程將數據實例終止
引用
- Tue Mar 9 01:43:22 2010
- CKPT: terminating instance due to error 1242
- Instance terminated by CKPT, pid = 16653
- Tue Mar 9 01:43:53 2010
再次啟動Oracle數據庫報錯
引用
- Tue Mar 9 01:56:09 2010
- Errors in file /ora10g/app/admin/ldbra/udump
/ldbra_ora_12275.trc:- ORA-01221: data file 1 is not the same file
to a background process- ORA-1221 signalled during: ALTER DATABASE OPEN...
dump Oracle數據文件頭
引用
- SQL> ALTER SESSION SET EVENTS 'immediate
trace name file_hdrs level 3';
通過跟蹤文件可以看到dbid以被重置為0
引用
- V10 STYLE FILE HEADER:
- Compatibility Vsn = 169870080=0xa200300
- Db ID=0=0x0, Db Name='LDBRA'
- Activation ID=0=0x0
- Control Seq=8122=0x1fba, File size=65280=0xff00
- File Number=1, Blksiz=8192, File Type=3 DATA
還有一種途徑是通過bbed工具觀察
引用
- struct kcvfhhdr, 76 bytes @20
- ub4 kccfhswv @20 0x00000000
- ub4 kccfhcvn @24 0x0a200300
- ub4 kccfhdbi @28 0x00000000
當然第一反應是重建控制文件,看看能不能恢復成功
引用
- SQL> alter database backup controlfile to trace;
- Database altered.
- STARTUP NOMOUNT
- CREATE CONTROLFILE REUSE DATABASE "LDBRA"
RESETLOGS ARCHIVELOG- MAXLOGFILES 16
- MAXLOGMEMBERS 3
- MAXDATAFILES 100
- MAXINSTANCES 8
- MAXLOGHISTORY 292
- LOGFILE
- GROUP 1 '/ora10g/app/oradata/ldbra/redo01.log' SIZE 50M,
- GROUP 2 '/ora10g/app/oradata/ldbra/redo02.log' SIZE 50M,
- GROUP 3 '/ora10g/app/oradata/ldbra/redo03.log' SIZE 50M
- STANDBY LOGFILE
- DATAFILE
- '/ora10g/app/oradata/ldbra/system01.dbf',
- '/ora10g/app/oradata/ldbra/undotbs01.dbf',
- '/ora10g/app/oradata/ldbra/sysaux01.dbf',
- '/ora10g/app/oradata/ldbra/users01.dbf',
- '/ora10g/app/oradata/ldbra/example01.dbf',
- '/ora10g/app/product/10.2.0/db_1/dbs/company.dbf',
- '/ora10g/app/product/10.2.0/db_1/dbs/streams.dbf'
- CHARACTER SET ZHS16GBK
- ;