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

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;

oracle 操作实例(一)----redolog 损坏恢复

    日志文件位置

SELECT group#,member FROM v$logfile;

oracle 操作实例(一)----redolog 损坏恢复

    记录下来: 开始破坏

    第一步,关闭数据库oracle 操作实例(一)----redolog 损坏恢复

    第二步,删除或者移动一个rodo日志.

oracle 操作实例(一)----redolog 损坏恢复

二,恢复

  启动数据库报错

oracle 操作实例(一)----redolog 损坏恢复

   发现启动到mount状态后开始报错了

  报错说的还不怎么详细.我们深入看一下

 show parameter background_dump 

oracle 操作实例(一)----redolog 损坏恢复

进入报错日志里面查看--报错日志为第一个log文件...

查看最近的报错信息

oracle 操作实例(一)----redolog 损坏恢复

oracle 操作实例(一)----redolog 损坏恢复

可以看见日志文件redo3找不到了

  查看日志状态:

oracle 操作实例(一)----redolog 损坏恢复

    哇,不行.

    现在关闭数据库

oracle 操作实例(一)----redolog 损坏恢复

    也报错了

    强制关闭

    shutdown abort

启动数据库到mount状态  

oracle 操作实例(一)----redolog 损坏恢复

     查看日志状态:oracle 操作实例(一)----redolog 损坏恢复

      有一个日志文件报错了

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#;

oracle 操作实例(一)----redolog 损坏恢复

  处理文件:

  alter database clear logfile group 3;oracle 操作实例(一)----redolog 损坏恢复

  开启数据库:

oracle 操作实例(一)----redolog 损坏恢复

   没有报错了

假如日志成员全部删除了也是这样恢复的

    全部删除了,

oracle 操作实例(一)----redolog 损坏恢复

  启动报错 

oracle 操作实例(一)----redolog 损坏恢复

  按照上文恢复

  好像并不能关闭了----

oracle 操作实例(一)----redolog 损坏恢复

 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

相关文章: