RMAN-00554 RMAN-04005 ORA-12528

RMAN在使用recover catalog的情况下在nomount状态连接实例出现以下错误信息:

RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database:
ORA-12528: TNS:listener: all appropriate instances are blocking new connections

下面我来模拟一下这种情况
1.将数据库置于nomount状态

SQL> startup nomount
ORACLE instance started.

Total System Global Area  327155712 bytes
Fixed Size                  1273516 bytes
Variable Size             138412372 bytes
Database Buffers          184549376 bytes
Redo Buffers                2920448 bytes

2.连接目标数据库

[oracle@oracle11g ~]$ rman target sys/zzh_2046@test catalog rman/rman@jy

Recovery Manager: Release 10.2.0.5.0 - Production on Sun Feb 1 23:01:08 2015

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

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00554: initialization of internal recovery manager package failed
RMAN-04005: error from target database:
ORA-12528: TNS:listener: all appropriate instances are blocking new connections

3.检查监听状态

[oracle@oracle11g ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.5.0 - Production on 01-FEB-2015 23:00:49

Copyright (c) 1991, 2010, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.5.0 - Production
Start Date                01-FEB-2015 22:51:09
Uptime                    0 days 0 hr. 9 min. 40 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /u01/app/oracle/10.2.0/db/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))
Services Summary...
Service "test" has 1 instance(s).
  Instance "test", status BLOCKED, has 1 handler(s) for this service...
Service "test_XPT" has 1 instance(s).
  Instance "test", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully

从上面的信息可以看到Instance “test”,status BLOCKED,对于ora-12528错误在MOS有一篇文章描述造成这种问题的原因:

Cause

When an instance is in restricted mode, PMON updates the listener with that information and blocks new connections from being established.

The lsnrctl services output will show the handler is blocked for new connections or lsnrctl status may show the instance is in RESTRICTED mode.

解决方法如下:

The (UR=A) clause for TNS connect strings was created in response to an enhancement request.  This clause can be inserted into the "(CONNECT_DATA=" section of a TNS connect string and allow a privileged or administrative user to connect via the listener even when the service handler is blocking connections for non-privileged users.

Here's an example of a connect string configured with (UR=A):

PROD =
   (DESCRIPTION =
     (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = myhost.oracle.com)(PORT = 1521)))
      (CONNECT_DATA =
          (UR=A)
          (SERVICE_NAME = prod10ib.oracle.com)
       )
     )



Please note that the (UR=A) clause is intended to work with a dynamically registered handler so the use of SERVICE_NAME versus SID is required when using dynamic registration (i.e. handler exists in lsnrctl output but is BLOCKED).  The use of SID in a TNS connect string may allow a connection if using a static handler in the listener.ora file under SID_DESC.

4.修改tns文件增加(UR=A)

[oracle@oracle11g admin]$ vi tnsnames.ora

test =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.2)(PORT = 1521))
    )
    (CONNECT_DATA =
     (UR=A)
     (SERVICE_NAME = test)
    )
  )


jy =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.11)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = jy)
    )
  )

5.再次连接目标数据库执行恢复

[oracle@oracle11g admin]$ rman target sys/zzh_2046@test catalog rman/rman@jy

Recovery Manager: Release 10.2.0.5.0 - Production on Sun Feb 1 23:04:03 2015

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

connected to target database: test (not mounted)
connected to recovery catalog database

RMAN> restore controlfile;

Starting restore at 01-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/10.2.0/db/dbs/c-2155613261-20150201-01
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/10.2.0/db/dbs/c-2155613261-20150201-01 tag=TAG20150201T213315
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output filename=/u01/app/oracle/oradata/test/control01.ctl
output filename=/u01/app/oracle/oradata/test/control02.ctl
output filename=/u01/app/oracle/oradata/test/control03.ctl
Finished restore at 01-FEB-15

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> recover database;

Starting recover at 01-FEB-15
Starting implicit crosscheck backup at 01-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 8 objects
Finished implicit crosscheck backup at 01-FEB-15

Starting implicit crosscheck copy at 01-FEB-15
using channel ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck copy at 01-FEB-15

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /u01/app/oracle/oradata/test/redo03.log
archive log thread 1 sequence 4 is already on disk as file /u01/app/oracle/oradata/test/redo01.log
archive log filename=/u01/app/oracle/oradata/test/redo03.log thread=1 sequence=3
archive log filename=/u01/app/oracle/oradata/test/redo01.log thread=1 sequence=4
media recovery complete, elapsed time: 00:00:01
Finished recover at 01-FEB-15

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

出现这个问题的原因是当使用动态注册监听时,当实例处于限制模式或受阻的情况下PMON将会更新监听程序来阻新的连接,解决方法其实有两种:
一是在tns连接描述串中增加(UR=A)子句来让动态监听程序使用service_name来进行注册
二是使用静态监听注册

配置RMAN RECOVERY CATALOG

Oracle的RMAN配置信息默认存放在target数据库的控制文件中,也可以配置一个recovery catalog服务器来存储这些信息,下面是控制文件和恢复的特性比较

Control file:
– Simpler administration
– Default
Recovery catalog:
– Replicates control file data
– Has room for more data
– Can service many targets
– Can store RMAN scripts
RMAN repository data is always stored in the control file of the target database. But it can also be stored in a separate database, called a recovery catalog.
A recovery catalog preserves backup information in a separate database, which is useful in the event of a lost control file. This allows you to store a longer history of backups than what is possible with a control file–based repository. A single recovery catalog is able to store information for multiple target databases. The recovery catalog can also hold RMAN stored scripts, which are sequences of RMAN commands for common backup tasks. Centralized storage of scripts in the recovery catalog can be more convenient than working with command files.
Usage of a separate recovery catalog database is not recommended for small installations where administration of a separate recovery catalog database would be burdenso

下面来演示下恢复目录的配置,其中jy为catalog数据库,test数据库为测试数据库
1.创建用户/表空间与授权(我这里使用users表空间没有新建表空间)

SQL> create user rman identified by "rman"
  2  default tablespace users
  3  temporary tablespace temp
  4  quota unlimited on users;

User created.

SQL> grant recovery_catalog_owner to rman;

Grant succeeded.

SQL>  conn rman/rman
Connected.
SQL> select count (*) from user_objects;

  COUNT(*)
----------
         0

2:创建恢复目录

[oracle@jingyong1 admin]$ rman catalog rman/rman@jy

Recovery Manager: Release 10.2.0.5.0 - Production on Sun Feb 1 21:22:31 2015

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

connected to recovery catalog database

RMAN> create catalog;

recovery catalog created


SQL> conn rman/rman
Connected.
SQL> select count (*) from user_objects;

  COUNT(*)
----------
       194

可以看出在rman用户下的对象个数为194个

3:增加tns服务名

[oracle@oracle11g admin]$ vi tnsnames.ora

jy =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.56.11)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = jy)
    )
  )

4:注册目标数据库,同步catalog和控制文件

[oracle@oracle11g admin]$ rman target sys/zzh_2046@test catalog rman/rman@jy

Recovery Manager: Release 10.2.0.5.0 - Production on Sun Feb 1 21:25:25 2015

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

connected to target database: TEST (DBID=2155613261)
connected to recovery catalog database

RMAN> register database;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

RMAN> resync catalog;

starting full resync of recovery catalog
full resync complete

RMAN> list incarnation;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       10      TEST     2155613261       PARENT  1          30-JUN-05
1       11      TEST     2155613261       PARENT  446075     05-SEP-14
1       12      TEST     2155613261       PARENT  2849317    27-JAN-15
1       13      TEST     2155613261       PARENT  2880152    27-JAN-15
1       2       TEST     2155613261       CURRENT 3017109    01-FEB-15

rman还原控制文件(四)

RMAN使用恢复目录还原控制文件
1.人为删除所有控制文件

[root@oracle11g test]# ls -lrt
total 2213868
-rw-r—– 1 oracle oinstall 20979712 Feb 1 11:37 temp01.dbf
-rw-r—– 1 oracle oinstall 11804672 Feb 1 22:31 users01.dbf
-rw-r—– 1 oracle oinstall 52436992 Feb 1 22:31 test01.dbf
-rw-r—– 1 oracle oinstall 52429312 Feb 1 22:31 redo03.log
-rw-r—– 1 oracle oinstall 52429312 Feb 1 22:31 redo02.log
-rw-r—– 1 oracle oinstall 104865792 Feb 1 22:31 example01.dbf
-rw-r—– 1 oracle oinstall 576724992 Feb 1 22:37 sysaux01.dbf
-rw-r—– 1 oracle oinstall 492838912 Feb 1 22:42 undotbs01.dbf
-rw-r—– 1 oracle oinstall 838868992 Feb 1 22:42 system01.dbf
-rw-r—– 1 oracle oinstall 52429312 Feb 1 22:42 redo01.log
-rw-r—– 1 oracle oinstall 9814016 Feb 1 22:42 control03.ctl
-rw-r—– 1 oracle oinstall 9814016 Feb 1 22:42 control02.ctl
-rw-r—– 1 oracle oinstall 9814016 Feb 1 22:42 control01.ctl
[root@oracle11g test]# rm -rf control*.ctl
[root@oracle11g test]# ls -lrt
total 2185068
-rw-r—– 1 oracle oinstall 20979712 Feb 1 11:37 temp01.dbf
-rw-r—– 1 oracle oinstall 11804672 Feb 1 22:31 users01.dbf
-rw-r—– 1 oracle oinstall 52436992 Feb 1 22:31 test01.dbf
-rw-r—– 1 oracle oinstall 52429312 Feb 1 22:31 redo03.log
-rw-r—– 1 oracle oinstall 52429312 Feb 1 22:31 redo02.log
-rw-r—– 1 oracle oinstall 104865792 Feb 1 22:31 example01.dbf
-rw-r—– 1 oracle oinstall 576724992 Feb 1 22:37 sysaux01.dbf
-rw-r—– 1 oracle oinstall 492838912 Feb 1 22:42 undotbs01.dbf
-rw-r—– 1 oracle oinstall 838868992 Feb 1 22:42 system01.dbf
-rw-r—– 1 oracle oinstall 52429312 Feb 1 22:42 redo01.log

2.人为将数据库异常终止

[root@oracle11g test]# ps -ef | grep smon
oracle    4135     1  0 22:30 ?        00:00:00 ora_smon_test
root      3179  3123  0 22:45 pts/3    00:00:00 grep smon
[root@oracle11g test]# kill -9 4135

3.将数据库启动到nomount状态

SQL> startup nomount
ORACLE instance started.

Total System Global Area  327155712 bytes
Fixed Size                  1273516 bytes
Variable Size             138412372 bytes
Database Buffers          184549376 bytes
Redo Buffers                2920448 bytes

4.还原控制文件

[oracle@oracle11g admin]$ rman target sys/zzh_2046@test catalog rman/rman@jy

Recovery Manager: Release 10.2.0.5.0 - Production on Sun Feb 1 23:04:03 2015

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

connected to target database: test (not mounted)
connected to recovery catalog database

RMAN> restore controlfile;

Starting restore at 01-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/10.2.0/db/dbs/c-2155613261-20150201-01
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/app/oracle/10.2.0/db/dbs/c-2155613261-20150201-01 tag=TAG20150201T213315
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output filename=/u01/app/oracle/oradata/test/control01.ctl
output filename=/u01/app/oracle/oradata/test/control02.ctl
output filename=/u01/app/oracle/oradata/test/control03.ctl
Finished restore at 01-FEB-15

5.执行完全恢复

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> recover database;

Starting recover at 01-FEB-15
Starting implicit crosscheck backup at 01-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 8 objects
Finished implicit crosscheck backup at 01-FEB-15

Starting implicit crosscheck copy at 01-FEB-15
using channel ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck copy at 01-FEB-15

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /u01/app/oracle/oradata/test/redo03.log
archive log thread 1 sequence 4 is already on disk as file /u01/app/oracle/oradata/test/redo01.log
archive log filename=/u01/app/oracle/oradata/test/redo03.log thread=1 sequence=3
archive log filename=/u01/app/oracle/oradata/test/redo01.log thread=1 sequence=4
media recovery complete, elapsed time: 00:00:01
Finished recover at 01-FEB-15



RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

将控制文件还原到新目录
有一种将控制文件还原到一个或多个新目录的方法是修改control_files参数,然后用没有任何参数的restore controlfile命令将控制文件还原到默认位置。例如,如果在有些控制文件目录所在的磁盘出现故障还原控制文件,可以修改control_files参数将出现故障的磁盘使用其它的磁盘来替代,然后执行restore controlfile命令来还原控制文件。

如果不修改control_files参数也可以使用restore controlfile to ‘filename’ [from autobackup]命令来将控制文件还原到你所指定的位置。
示例:
RESTORE CONTROLFILE TO ‘/tmp/my_controlfile’;

下面的命令将使用自动备份将控制文件还原到’/u01/app/oracle/‘目录下

RMAN> restore controlfile to '/u01/app/oracle/control_temp.ctl' from autobackup;

Starting restore at 02-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=148 devtype=DISK

recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: TEST
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/app/oracle/flash_recovery_area/TEST/autobackup/2015_02_02/o1_mf_s_870567448_bdwndtqk_.bkp
channel ORA_DISK_1: control file restore from autobackup complete
Finished restore at 02-FEB-15

上面的命令可以在数据库为nomount,mount,open状态下进行,因为不会覆盖任何当前使用的控制文件。在将控制文件还原到新目录后,可以修改control_files参数来引用新目录下的控制文件。

使用备份控制文件的限制
在使用备份控制文件还原数据库后,你必须执行recover database来恢复数据库并且必须执行alter database open resetlogs来打开数据库。

rman还原控制文件(三)

设置闪回区的情况下还原控制文件所使用的命令是相同的。然而如果当前数据库正在使用闪回区,RMAN通过对所有基于控制文件中的基于磁盘的备份和镜像副本和任何在闪回区中而不在还原的控制文件中的备份执行隐式的crosscheck来更新从备份中还原的控制文件。因此还原后的控制文件会完整的和精确的记录在闪回区中的所有备份和其它任何在备份该控制文件时所知道的备份。这提高了在数据库还原操作中的可用性。

下面来看一个使用闪回区还原控制文件的实例:
1.环境检查,看是否已经启用闪回区与设置控制文件自动备份

SQL> show parameter db_recover

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      /u01/app/oracle/flash_recovery_area
db_recovery_file_dest_size           big integer 2G

SQL> select flashback_on from v$database;

FLASHBACK_ON
------------------
YES


RMAN> show controlfile autobackup;

RMAN configuration parameters are:
CONFIGURE CONTROLFILE AUTOBACKUP ON;

从上面信息可知已经启用了闪回区并设置了控制文件自动备份

2.创建一个表空间,在数据库结构发生变化时,就会自动备份控制文件

SQL> create tablespace testbak datafile '/u01/app/oracle/oradata/test/testbak.dbf' size 10M  extent management local segment space management auto;

Tablespace created.

从alert日志中可以看到产生的控制文件自动备份的文件信息

create tablespace testbak datafile '/u01/app/oracle/oradata/test/testbak.dbf' size 10M  extent management local segment space management auto
Mon Feb 02 00:17:28 CST 2015
Starting control autobackup
Control autobackup written to DISK device
        handle '/u01/app/oracle/flash_recovery_area/TEST/autobackup/2015_02_02/o1_mf_s_870567448_bdwndtqk_.bkp'
Completed: create tablespace testbak datafile '/u01/app/oracle/oradata/test/testbak.dbf' size 10M  extent management local segment space management auto

其实控制文件和spfile同时被自动备份了

查看闪回区是否存在自动备份文件

[root@oracle11g 2015_02_02]# ls -lrt
total 19360
-rw-r----- 1 oracle oinstall 9895936 Feb  2 00:17 o1_mf_s_870567448_bdwndtqk_.bkp

3.人为删除所有控制文件

[root@oracle11g test]# ls -lrt
total 2213868
-rw-r----- 1 oracle oinstall  20979712 Feb  1 11:37 temp01.dbf
-rw-r----- 1 oracle oinstall  11804672 Feb  1 22:31 users01.dbf
-rw-r----- 1 oracle oinstall  52436992 Feb  1 22:31 test01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo03.log
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo02.log
-rw-r----- 1 oracle oinstall 104865792 Feb  1 22:31 example01.dbf
-rw-r----- 1 oracle oinstall 576724992 Feb  1 22:37 sysaux01.dbf
-rw-r----- 1 oracle oinstall 492838912 Feb  1 22:42 undotbs01.dbf
-rw-r----- 1 oracle oinstall 838868992 Feb  1 22:42 system01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:42 redo01.log
-rw-r----- 1 oracle oinstall   9814016 Feb  1 22:42 control03.ctl
-rw-r----- 1 oracle oinstall   9814016 Feb  1 22:42 control02.ctl
-rw-r----- 1 oracle oinstall   9814016 Feb  1 22:42 control01.ctl
[root@oracle11g test]# rm -rf control*.ctl
[root@oracle11g test]# ls -lrt
total 2185068
-rw-r----- 1 oracle oinstall  20979712 Feb  1 11:37 temp01.dbf
-rw-r----- 1 oracle oinstall  11804672 Feb  1 22:31 users01.dbf
-rw-r----- 1 oracle oinstall  52436992 Feb  1 22:31 test01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo03.log
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo02.log
-rw-r----- 1 oracle oinstall 104865792 Feb  1 22:31 example01.dbf
-rw-r----- 1 oracle oinstall 576724992 Feb  1 22:37 sysaux01.dbf
-rw-r----- 1 oracle oinstall 492838912 Feb  1 22:42 undotbs01.dbf
-rw-r----- 1 oracle oinstall 838868992 Feb  1 22:42 system01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:42 redo01.log

4.人为将数据库异常终止

[root@oracle11g test]# ps -ef | grep smon
oracle    3068     1  0 22:30 ?        00:00:00 ora_smon_test
root      3179  3123  0 22:45 pts/3    00:00:00 grep smon
[root@oracle11g test]# kill -9 3068

5.将数据库启动到nomount状态

SQL> startup nomount
ORACLE instance started.

Total System Global Area  327155712 bytes
Fixed Size                  1273516 bytes
Variable Size             138412372 bytes
Database Buffers          184549376 bytes
Redo Buffers                2920448 bytes

6.恢复控制文件

RMAN> restore controlfile  from autobackup;

Starting restore at 02-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=148 devtype=DISK

recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: TEST
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/app/oracle/flash_recovery_area/TEST/autobackup/2015_02_02/o1_mf_s_870567448_bdwndtqk_.bkp
channel ORA_DISK_1: control file restore from autobackup complete
Finished restore at 02-FEB-15

在上面的还原控制文件的过程可以看到如下内容说明是使用存储在闪回区中的控制文件自动备份来还原控制文件

channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/app/oracle/flash_recovery_area/TEST/autobackup/2015_02_02/o1_mf_s_870567448_bdwndtqk_.bkp

磁带备份在还原控制文件后不会自动执行crosscheck。如果正使用磁带备份,那么在还原控制文件并将数据库置于mount状态后,必须手工执行crosscheck.

RMAN> CROSSCHECK BACKUP DEVICE TYPE SBT;

7.执行完全恢复

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> recover database;

Starting recover at 01-FEB-15
Starting implicit crosscheck backup at 01-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 8 objects
Finished implicit crosscheck backup at 01-FEB-15

Starting implicit crosscheck copy at 01-FEB-15
using channel ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck copy at 01-FEB-15

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /u01/app/oracle/oradata/test/redo03.log
archive log thread 1 sequence 4 is already on disk as file /u01/app/oracle/oradata/test/redo01.log
archive log filename=/u01/app/oracle/oradata/test/redo03.log thread=1 sequence=3
archive log filename=/u01/app/oracle/oradata/test/redo01.log thread=1 sequence=4
media recovery complete, elapsed time: 00:00:01
Finished recover at 01-FEB-15



RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

rman还原控制文件(二)

当没有使用恢复目录时,必须从控制文件自动备份中还原控制文件。如果从控制文件自动备份中还原控制文件,数据库必须置于nomount状态。必须首先设置数据库的DBID,然后执行restore controlfile from autobackup命令

1.人为删除所有控制文件

[root@oracle11g test]# ls -lrt
total 2213868
-rw-r----- 1 oracle oinstall  20979712 Feb  1 11:37 temp01.dbf
-rw-r----- 1 oracle oinstall  11804672 Feb  1 22:31 users01.dbf
-rw-r----- 1 oracle oinstall  52436992 Feb  1 22:31 test01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo03.log
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo02.log
-rw-r----- 1 oracle oinstall 104865792 Feb  1 22:31 example01.dbf
-rw-r----- 1 oracle oinstall 576724992 Feb  1 22:37 sysaux01.dbf
-rw-r----- 1 oracle oinstall 492838912 Feb  1 22:42 undotbs01.dbf
-rw-r----- 1 oracle oinstall 838868992 Feb  1 22:42 system01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:42 redo01.log
-rw-r----- 1 oracle oinstall   9814016 Feb  1 22:42 control03.ctl
-rw-r----- 1 oracle oinstall   9814016 Feb  1 22:42 control02.ctl
-rw-r----- 1 oracle oinstall   9814016 Feb  1 22:42 control01.ctl
[root@oracle11g test]# rm -rf control*.ctl
[root@oracle11g test]# ls -lrt
total 2185068
-rw-r----- 1 oracle oinstall  20979712 Feb  1 11:37 temp01.dbf
-rw-r----- 1 oracle oinstall  11804672 Feb  1 22:31 users01.dbf
-rw-r----- 1 oracle oinstall  52436992 Feb  1 22:31 test01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo03.log
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:31 redo02.log
-rw-r----- 1 oracle oinstall 104865792 Feb  1 22:31 example01.dbf
-rw-r----- 1 oracle oinstall 576724992 Feb  1 22:37 sysaux01.dbf
-rw-r----- 1 oracle oinstall 492838912 Feb  1 22:42 undotbs01.dbf
-rw-r----- 1 oracle oinstall 838868992 Feb  1 22:42 system01.dbf
-rw-r----- 1 oracle oinstall  52429312 Feb  1 22:42 redo01.log

2.人为将数据库异常终止

[root@oracle11g test]# ps -ef | grep smon
oracle    3063     1  0 22:30 ?        00:00:00 ora_smon_test
root      3179  3123  0 22:45 pts/3    00:00:00 grep smon
[root@oracle11g test]# kill -9 3063

3.将数据库启动到nomount状态

SQL> startup nomount
ORACLE instance started.

Total System Global Area  327155712 bytes
Fixed Size                  1273516 bytes
Variable Size             138412372 bytes
Database Buffers          184549376 bytes
Redo Buffers                2920448 bytes

4.从以前的备份信息中可以找到如下信息,其中c-2155613261-20150201-03中的2155613261就是DBID

Starting Control File and SPFILE Autobackup at 01-FEB-15
piece handle=/u01/app/oracle/10.2.0/db/dbs/c-2155613261-20150201-03 comment=NONE
Finished Control File and SPFILE Autobackup at 01-FEB-15

5.还原控制文件

RMAN> show controlfile autobackup format;

RMAN configuration parameters are:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'STB' TO '%F';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE 'SBT_TAPE' TO '%F';

RMAN> set dbid 2155613261;

executing command: SET DBID

RMAN> restore controlfile from autobackup;

Starting restore at 01-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK

recovery area destination: /u01/app/oracle/flash_recovery_area
database name (or database unique name) used for search: TEST
channel ORA_DISK_1: no autobackups found in the recovery area
channel ORA_DISK_1: looking for autobackup on day: 20150201
channel ORA_DISK_1: autobackup found: c-2155613261-20150201-03
channel ORA_DISK_1: control file restore from autobackup complete
output filename=/u01/app/oracle/oradata/test/control01.ctl
output filename=/u01/app/oracle/oradata/test/control02.ctl
output filename=/u01/app/oracle/oradata/test/control03.ctl
Finished restore at 01-FEB-15

6.恢复数据库

RMAN> sql 'alter database mount';

sql statement: alter database mount
released channel: ORA_DISK_1

RMAN> recover database;

Starting recover at 01-FEB-15
Starting implicit crosscheck backup at 01-FEB-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 13 objects
Finished implicit crosscheck backup at 01-FEB-15

Starting implicit crosscheck copy at 01-FEB-15
using channel ORA_DISK_1
Crosschecked 6 objects
Finished implicit crosscheck copy at 01-FEB-15

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 2 is already on disk as file /u01/app/oracle/oradata/test/redo02.log
archive log thread 1 sequence 3 is already on disk as file /u01/app/oracle/oradata/test/redo03.log
archive log filename=/u01/app/oracle/oradata/test/redo02.log thread=1 sequence=2
archive log filename=/u01/app/oracle/oradata/test/redo03.log thread=1 sequence=3
media recovery complete, elapsed time: 00:00:03
Finished recover at 01-FEB-15

RMAN> sql 'alter database open resetlogs';

sql statement: alter database open resetlogs

RMAN会使用自动备份的格式与DBID来判断在什么存储位置来搜索控制文件自动备份。如果找到,RMAN就会从备份中将控制文件还原到由control_files参数所指定的所有位置

Proudly powered by WordPress | Indrajeet by Sus Hill.