一,實驗前的准備
數據庫全備保證自己沒成功還能補救一下
vim full.sh export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2/db_1 export ORACLE_SID=proc export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK export PATH=$ORACLE_HOME/bin:$PATH rman target / log /u01/backup/rman_full.log append<<EOF run {allocate channel c1 type disk; allocate channel c2 type disk; backup database filesperset 4 format '/u01/backup/full_%d_%T_%s_%p'; sql 'alter system archive log current'; sql 'alter system archive log current'; sql 'alter system archive log current'; backup archivelog all format '/u01/backup/arch_%d_%T_%s_%p' delete input; backup current controlfile format '/u01/backup/ctl_%d_%T_%s_%p'; crosscheck backup; crosscheck archivelog all; delete noprompt obsolete; delete noprompt expired backup; delete noprompt expired archivelog all; } EOF
查看日志組的狀態
size_MB,members,archived,status,first_change#,to_char(FIRST_TIME,'yyyy-mm-dd hh24:mi:ss') first_time from v$log;
日志文件位置
SELECT group#,member FROM v$logfile;
記錄下來: 開始破壞
第一步,關閉數據庫
第二步,刪除或者移動一個rodo日志.
二,恢復
啟動數據庫報錯
發現啟動到mount狀態后開始報錯了
報錯說的還不怎么詳細.我們深入看一下
show parameter background_dump
進入報錯日志里面查看--報錯日志為第一個log文件...
查看最近的報錯信息
可以看見日志文件redo3找不到了
查看日志狀態:
哇,不行.
現在關閉數據庫
也報錯了
強制關閉
shutdown abort
啟動數據庫到mount狀態
查看日志狀態:
有一個日志文件報錯了
1 select a.group#,a.thread#,b.member,a.bytes/1024/1024 2 size_MB,a.members,a.archived,a.status from v$log a,v$logfile b where a.group#=b.group#;
處理文件:
alter database clear logfile group 3;
開啟數據庫:
沒有報錯了
假如日志成員全部刪除了也是這樣恢復的
全部刪除了,
啟動報錯
按照上文恢復
好像並不能關閉了----

1 SQL> startup mount 2 ORACLE instance started. 3 4 Total System Global Area 1803841536 bytes 5 Fixed Size 2254144 bytes 6 Variable Size 1577061056 bytes 7 Database Buffers 218103808 bytes 8 Redo Buffers 6422528 bytes 9 Database mounted. 10 SQL> select group#,thread#,sequence#,bytes/1024/1024 11 size_MB,members,archived,status,first_change#,to_char(FIRST_TIME,'yyyy-mm-dd hh24:mi:ss') first_time from v$log; 12 2 13 GROUP# THREAD# SEQUENCE# SIZE_MB MEMBERS ARC STATUS 14 ---------- ---------- ---------- ---------- ---------- --- ---------------- 15 FIRST_CHANGE# FIRST_TIME 16 ------------- ------------------- 17 1 1 10749 512 1 NO CURRENT 18 39958366 2019-02-27 17:17:59 19 20 3 1 0 512 1 YES UNUSED 21 39938038 2019-02-27 16:47:59 22 23 2 1 10747 512 1 YES INACTIVE 24 39938029 2019-02-27 16:47:59 25 26 27 SQL> alter database clear logfile group 3;^H^H^H^H^H^H 28 2 29 SQL> s^H^H 30 SP2-0042: unknown command " - rest of line ignored. 31 SQL> 32 SQL> 33 SQL> 34 SQL> alter database open; 35 alter database open 36 * 37 ERROR at line 1: 38 ORA-03113: end-of-file on communication channel 39 Process ID: 3292 40 Session ID: 1705 Serial number: 5 41 42 43 SQL> alter database clear logfile group 3; 44 ERROR: 45 ORA-03114: not connected to ORACLE 46 47 48 SQL> exit 49 Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production 50 With the Partitioning, OLAP, Data Mining and Real Application Testing options 51 [oracle@dataknown prod]$ sqlplus / as sysdba 52 53 SQL*Plus: Release 11.2.0.4.0 Production on Wed Feb 27 17:51:40 2019 54 55 Copyright (c) 1982, 2013, Oracle. All rights reserved. 56 57 Connected to an idle instance. 58 59 SQL> startup mount 60 ORACLE instance started. 61 62 Total System Global Area 1803841536 bytes 63 Fixed Size 2254144 bytes 64 Variable Size 1577061056 bytes 65 Database Buffers 218103808 bytes 66 Redo Buffers 6422528 bytes 67 Database mounted. 68 SQL> alter database clear logfile group 3; 69 70 Database altered. 71 72 SQL> alter database open; 73 74 Database altered. 75 76 SQL>
插入發現以下報錯的可以參考參考

1 SQL> alter database clear logfile group 3; 2 alter database clear logfile group 3 3 * 4 ERROR at line 1: 5 ORA-00350: log 3 of instance prod (thread 1) needs to be archived 6 ORA-00312: online log 3 thread 1: '/data/oradata/prod/redo03.log'
執行以下命令:
alter database clear unarchived logfile group 3;
然后在打開數據庫