您好,登錄后才能下訂單哦!
查看數據庫是否處于非歸檔模式
關閉數據庫
shutdown immediate
備份控制文件和數據文件(沒有備份日志文件,建議一起備份)
[oracle@enmoedu1 PROD]$ ll
total 2014624
-rw-r----- 1 oracle oinstall 9748480 Jan 24 21:49 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Jan 24 21:49 control02.ctl
-rw-r----- 1 oracle oinstall 363077632 Jan 24 21:49 example01.dbf
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:48 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:49 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:48 redo03.log
-rw-r----- 1 oracle oinstall 576724992 Jan 24 21:49 sysaux01.dbf
-rw-r----- 1 oracle oinstall 807411712 Jan 24 21:49 system01.dbf
-rw-r----- 1 oracle oinstall 30416896 Jan 24 21:48 temp01.dbf
-rw-r----- 1 oracle oinstall 110108672 Jan 24 21:49 undotbs01.dbf
-rw-r----- 1 oracle oinstall 26222592 Jan 24 21:49 users01.dbf
[oracle@enmoedu1 PROD]$ cp *.dbf /home/oracle/bak/
[oracle@enmoedu1 PROD]$ cp *.ctl /home/oracle/bak/
[oracle@enmoedu1 PROD]$
啟動數據庫,并創建一個表,插入數據提交
startup ——啟動數據庫
SYS@PROD> create table t4(id number);
Table created.
SYS@PROD> insert into t4 values(1);
1 row created.
SYS@PROD> commit;
Commit complete.
SYS@PROD> select * from t4;
ID
----------
1
SYS@PROD>
關閉數據庫,刪除數據文件和控制文件
[oracle@enmoedu1 PROD]$ rm -rf *.dbf
[oracle@enmoedu1 PROD]$ rm -rf *.ctl
[oracle@enmoedu1 PROD]$ ll
total 153612
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:57 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo03.log
[oracle@enmoedu1 PROD]$
啟動數據庫到nomount,說明參數文件沒問題,到mount,找不到控制文件,使用操作系統命令拷貝控制文件再mount
SYS@PROD> startup nomount;
ORACLE instance started.
Total System Global Area 835104768 bytes
Fixed Size 2257840 bytes
Variable Size 536874064 bytes
Database Buffers 289406976 bytes
Redo Buffers 6565888 bytes
SYS@PROD> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-00205: error in identifying control file, check alert log for more info
SYS@PROD> host
[oracle@enmoedu1 PROD]$ cp /home/oracle/bak/*.ctl ./
[oracle@enmoedu1 PROD]$ ll
total 172652
-rw-r----- 1 oracle oinstall 9748480 Jan 24 22:01 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Jan 24 22:01 control02.ctl
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:57 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo03.log
[oracle@enmoedu1 PROD]$ exit
SYS@PROD> alter database mount;——可以到mount了,控制文件沒問題了
Database altered.
SYS@PROD>
SYS@PROD> alter database open;——找不到數據文件,
alter database open
*
ERROR at line 1:
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/u01/app/oracle/oradata/PROD/system01.dbf'
SYS@PROD>
拷貝回數據文件
[oracle@enmoedu1 PROD]$ cp /home/oracle/bak/*.dbf ./
[oracle@enmoedu1 PROD]$ ll
total 2014848
-rw-r----- 1 oracle oinstall 9748480 Jan 24 22:05 control01.ctl
-rw-r----- 1 oracle oinstall 9748480 Jan 24 22:05 control02.ctl
-rw-r----- 1 oracle oinstall 363077632 Jan 24 22:03 example01.dbf
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:57 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 24 21:56 redo03.log
-rw-r----- 1 oracle oinstall 576724992 Jan 24 22:04 sysaux01.dbf
-rw-r----- 1 oracle oinstall 807411712 Jan 24 22:05 system01.dbf
-rw-r----- 1 oracle oinstall 30416896 Jan 24 22:05 temp01.dbf
-rw-r----- 1 oracle oinstall 110108672 Jan 24 22:05 undotbs01.dbf
-rw-r----- 1 oracle oinstall 26222592 Jan 24 22:05 users01.dbf
[oracle@enmoedu1 PROD]$ exit
SYS@PROD> alter database open;
alter database open
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 2951
Session ID: 125 Serial number: 3
發現報錯了,因為我備份了控制文件和數據文件,然后開庫新建了一個表,導致數據庫的日志文件和控制文件的scn不一致了,查看alter日志
進入startup mount執行
recover database until cancel;
alter database open resetlogs;
startup mount ——進入到mount
SYS@PROD> recover database until cancel;——不完全恢復
Media recovery complete.
SYS@PROD> alter database open resetlogs;——重置日志
Database altered.
SYS@PROD> select open_mode from v$database;——數據庫已經打開
OPEN_MODE
--------------------
READ WRITE
SYS@PROD> select * from t4;——查詢t4表,沒有數據
select * from t4
*
ERROR at line 1:
ORA-00942: table or view does not exist
SYS@PROD>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。