oracle 操作实例----redolog 损坏恢复

Posted kingle66

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 操作实例----redolog 损坏恢复相关的知识,希望对你有一定的参考价值。

一,实验前的准备

   数据库全备保证自己没成功还能补救一下

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>
View Code

 

插入发现以下报错的可以参考参考

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\'
View Code

执行以下命令:

 alter database clear unarchived logfile group 3; 

然后在打开数据库

  

    

  

   

以上是关于oracle 操作实例----redolog 损坏恢复的主要内容,如果未能解决你的问题,请参考以下文章

oracle 删除archivelog对数据库影响么

mysql8好用吗?现在用的多吗?

oracle笔记--SGA总结

SCN

Oracle数据块损坏的恢复实例

Oracle Logminer 分析重做日志RedoLog和归档日志ArchiveLog