dataguard从库数据库丢失恢复例子(模拟所有的控制文件)

1.退出日志应用模式
[oracle@localhost ~]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.4.0 Production on Mon Jan 14 16:09:16 2019

Copyright (c) 1982, 2013, Oracle. All rights reserved.

SQL> connect / as sysdba
Connected.
SQL> alter database recover managed standby database cancel;

Database altered.

2.停掉数据库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

3.模拟删除掉所有的控制文件
[oracle@localhost slnngkdg]$ cd /u01/app/oracle/oradata/slnngkdg
[oracle@localhost slnngkdg]$ mv control01.ctl bak_control01.ctl
[oracle@localhost slnngkdg]$ cd /u01/app/oracle/fast_recovery_area/slnngkdg
[oracle@localhost slnngkdg]$ mv control02.ctl bak_control02.ctl

4.尝试启动数据库
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.

Total System Global Area 3724607488 bytes
Fixed Size 2258760 bytes
Variable Size 788531384 bytes
Database Buffers 2919235584 bytes
Redo Buffers 14581760 bytes
ORA-00205: error in identifying control file, check alert log for more info

发现报错

5.启动数据库到nonout状态,然后恢复控制文件
[oracle@localhost ~]$ rman target /
RMAN> startup nomount;

database is already started

RMAN> restore controlfile from '/home/oracle/rman_bakckup/ctl_SLNNGK_36_1_20190114';

Starting restore at 14-JAN-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=133 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
output file name=/u01/app/oracle/oradata/slnngkdg/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/slnngkdg/control02.ctl
Finished restore at 14-JAN-19

6.启动数据库到mount状态
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1


7.做不完全恢复,指定sequence,数据量很大的情况下,该步骤会很消耗时间,可以写个脚本采用nohup执行
从主库看下当前的日志序号,看到主库当前的日志序号为290,那么我们直接指定该序号,要是没有权限查看,也可以使用系统视图查看(Select Max(t.SEQUENCE#) +1 From v$archived_log t)
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive_log
Oldest online log sequence 288
Next log sequence to archive 290
Current log sequence 290


run{
set until sequence 290;
restore database;
recover database;
}

8.打开数据库
RMAN> alter database open;

database opened


9.应用主库日志
alter database recover managed standby database using current logfile disconnect from session;

原文地址:https://www.cnblogs.com/hxlasky/p/10267509.html