ORACLE11G RMAN备份恢复到异机数据库

ORACLE11G RMAN备份恢复到异机数据库

1. 源数据库环境

操作系统版本 : Centos6.7 x64


数据库版本 : Oracle 11.2.0.4 x64
数据库名 : prb
数据库SID : prb
db_unique_name : prb
instance_name : prb
IP : 10.0.8.100



2. 目标数据库环境



操作系统版本  : Centos6.7 x64
数据库版本 : Oracle 11.2.0.4 x64 (只安装oracle数据库软件,no netca dbca)
数据库名 : prb
数据库SID : prb
db_unique_name: prb
instance_name : prb
IP:10.0.8.101


 

将参数文件备份、控制文件备份、数据文件备份、以及归档备份到目标主机

此处实验环境为同平台,同字节序,同版本,源机器和目标机器相同的目录结构。

目标机器只需要安装oracle只安装oracle数据库软件,no netca dbca

第一次利用备份恢复测试环境,之后从源机器拷贝备份到目标机器并在控制文件中注册,再见行恢复测试。

备份数据库

backup format '/u01/prb/rmanbk/fulldb_%d_%U' database includecurrent controlfile plus archivelog delete input;

orapwdfile='/u01/app/oracle/product/11.2.0.4/db_1/dbs/orapwprb' password=oracleentries=10 force=y

1 rman 连接到源数据库

prd-db1-> rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Aug 1719:23:27 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PRB (DBID=1906641159)

RMAN>

2  分别列出参数文件备份,控制文件备份,数据文件备份,以及归档备份的名字

参数文件备份如下:

RMAN> list backup of spfile;

using target database control file instead of recovery catalog

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time CompletionTime   

------- ---- -- ---------- ----------- ------------ -------------------

3       Full    9.36M     DISK        00:00:01     2016/08/17 16:47:34

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20160817T164718

        Piece Name:/u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1

  SPFILE Included:Modification time: 2016/08/17 16:30:57

  SPFILE db_unique_name:PRB

控制文件备份如下:

RMAN> list backup of controlfile;

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time CompletionTime   

------- ---- -- ---------- ----------- -------------------------------

3       Full    9.36M     DISK        00:00:01     2016/08/17 16:47:34

        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20160817T164718

        Piece Name:/u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1

  Control File Included:Ckp SCN: 972048       Ckp time:2016/08/17 16:47:33

数据文件备份如下:

RMAN> list backup of database;

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time CompletionTime   

------- ---- -- ---------- ----------- -------------------------------

2       Full    1.08G     DISK        00:00:15     2016/08/17 16:47:33

        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20160817T164718

        Piece Name:/u01/prb/rmanbk/fulldb_PRB_03rdg8cm_1_1

  List of Datafiles inbackup set 2

  File LV Type CkpSCN    Ckp Time            Name

  ---- -- ---- ----------------------------- ----

  1       Full 972030     2016/08/17 16:47:18/u01/app/oracle/oradata/prb/system01.dbf

  2       Full 972030     2016/08/17 16:47:18/u01/app/oracle/oradata/prb/sysaux01.dbf

  3       Full 972030     2016/08/17 16:47:18/u01/app/oracle/oradata/prb/undotbs01.dbf

  4       Full 972030     2016/08/17 16:47:18/u01/app/oracle/oradata/prb/users01.dbf

列出归档备份如下:

RMAN> list backup of archivelog all;

List of Backup Sets

===================

BS Key  Size       Device Type Elapsed Time CompletionTime   

------- ---------- ----------- ------------ -------------------

1       68.93M     DISK       00:00:01     2016/08/17 16:47:17

        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20160817T164716

        Piece Name:/u01/prb/rmanbk/fulldb_PRB_02rdg8ck_1_1

  List of Archived Logsin backup set 1

  Thrd Seq     Low SCN   Low Time            Next SCN  Next Time

  ---- ------- ----------------------------- ---------- ---------

  1    4      955212     2016/08/17 16:26:15966337     2016/08/17 16:28:09

  1    5      966337     2016/08/17 16:28:09971912     2016/08/17 16:45:39

  1    6       971912    2016/08/17 16:45:39 972019    2016/08/17 16:47:16

BS Key  Size       Device Type Elapsed Time CompletionTime   

------- ---------- ----------- ------------ -------------------

4       13.00K     DISK       00:00:00     2016/08/17 16:47:35

        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20160817T164735

        Piece Name:/u01/prb/rmanbk/fulldb_PRB_05rdg8d7_1_1

  List of Archived Logsin backup set 4

  Thrd Seq     Low SCN   Low Time            Next SCN   Next Time

  ---- ------- ----------------------------- ---------- ---------

  1    7      972019     2016/08/17 16:47:16972053     2016/08/17 16:47:35

目标主机创建相应的目录

 

mkdir -p/u01/app/oracle/admin/prb/{adump,dpdump,pfile,scripts} 

mkdir -p /u01/app/oracle/oradata/prb

mkdir -p /u01/app/oracle/fast_recovery_area/prb

mkdir -p /u01/prb/rmanbk

mkdir -p /u01/archivelog

 

将备份文件、密码文件copy到目标主机

scp /u01/prb/rmanbk/*  oracle@prd-db2:/u01/prb/rmanbk/

scp/u01/app/oracle/product/11.2.0.4/db_1/dbs/orapwprb oracle@prd-db2: /u01/app/oracle/product/11.2.0.4/db_1/dbs/

恢复参数文件及控制文件

配置新主机上的ORACLE_SID

echo 'db_name=prb' > $ORACLE_HOME/dbs/initprb.ora 

export ORACLE_SID=prb

sqlplus  / assysdba@prb

startup nomountpfile='/u01/app/oracle/product/11.2.0.4/db_1/dbs/initprb.ora'

目标主机上发起rman连接

prd-db2-> rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Aug 1718:36:34 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

 

设置dbid 并启动实例到nomount状态

RMAN> set dbid 3601019238

executing command: SET DBID

RMAN> startup nomount;

Oracle instance started

Total System Global Area    217157632 bytes

Fixed Size                    2251816 bytes

Variable Size               159384536 bytes

Database Buffers             50331648 bytes

Redo Buffers                  5189632 bytes

恢复spfile文件

RMAN> restore spfile to'/u01/app/oracle/product/11.2.0.4/db_1/dbs/spfileprb.ora' from '/u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1';

Starting restore at 2016/08/17 18:37:40

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring spfile from AUTOBACKUP/u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1

channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete

Finished restore at 2016/08/17 18:37:41

startup force nomount

RMAN>  startup forcenomount;

 

Oracle instance started

Total System Global Area    584568832 bytes

Fixed Size                    2255432 bytes

Variable Size               226493880 bytes

Database Buffers            352321536 bytes

Redo Buffers                  3497984 bytes

恢复控制文件

RMAN> restore controlfile to'/u01/app/oracle/oradata/prb/control01.ctl' from '/u01/prb/rmanbk/fulldb_PRB_04rdg8d5_1_1';

 

Starting restore at 2016/08/17 18:38:26

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=19 device type=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

Finished restore at 2016/08/17 18:38:27

 启动数据库到加载状态

RMAN> alter database mount;

 

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACKFOLLOWS ===============

RMAN-00571:===========================================================

RMAN-03002: failure of alter db command at 08/17/201618:38:39

ORA-00205: error in identifying control file, checkalert log for more info

 

prd-db2-> export ORACLE_SID=prb

prd-db2-> sqlplus  /as  sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 17 18:42:042016

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 -64bit Production

With the Partitioning, OLAP, Data Mining and Real ApplicationTesting options

SQL> shutdown immediate;

ORA-01507: database not mounted

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

Total System Global Area 584568832 bytes

Fixed Size          2255432 bytes

Variable Size         226493880 bytes

Database Buffers      352321536 bytes

Redo Buffers            3497984 bytes

ORA-00205: error in identifying control file, checkalert log for more info

解决办法:

scp /u01/app/oracle/oradata/prb/control01.ctlprd-db2:/u01/app/oracle/oradata/prb/

scp /u01/app/oracle/fast_recovery_area/prb/control02.ctl prd-db2:/u01/app/oracle/fast_recovery_area/prb/

启动到mount状态正常

SQL> startup mount

ORACLE instance started.

 

Total System Global Area  584568832 bytes

Fixed Size                  2255432 bytes

Variable Size           226493880 bytes

Database Buffers     352321536 bytes

Redo Buffers             3497984 bytes

Database mounted.

 

三  在新控制文件中注册数据文件备份和归档备份

prd-db2-> rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Wed Aug 1718:52:34 2016

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PRB (DBID=1906641159, not open)

RMAN> catalog start with '/u01/prb/rmanbk/';

using target database control file instead of recovery catalog

searching for all files that match the pattern /u01/prb/rmanbk/

no files found to be unknown to the database

恢复整个库

RMAN> restore database;

Starting restore at 2016/08/17 18:53:42

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=18 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore frombackup set

channel ORA_DISK_1: restoring datafile 00001 to/u01/app/oracle/oradata/prb/system01.dbf

channel ORA_DISK_1: restoring datafile 00002 to/u01/app/oracle/oradata/prb/sysaux01.dbf

channel ORA_DISK_1: restoring datafile 00003 to/u01/app/oracle/oradata/prb/undotbs01.dbf

channel ORA_DISK_1: restoring datafile 00004 to/u01/app/oracle/oradata/prb/users01.dbf

channel ORA_DISK_1: reading from backup piece/u01/prb/rmanbk/fulldb_PRB_03rdg8cm_1_1

channel ORA_DISK_1: piecehandle=/u01/prb/rmanbk/fulldb_PRB_03rdg8cm_1_1 tag=TAG20160817T164718

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:15

Finished restore at 2016/08/17 18:53:57

 

RMAN> recover database;

Starting recover at 2016/08/17 18:54:12

using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to defaultdestination

channel ORA_DISK_1: restoring archived log

archived log thread=1 sequence=7

channel ORA_DISK_1: reading from backup piece/u01/prb/rmanbk/fulldb_PRB_05rdg8d7_1_1

channel ORA_DISK_1: piecehandle=/u01/prb/rmanbk/fulldb_PRB_05rdg8d7_1_1 tag=TAG20160817T164735

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

archived log file name=/u01/app/oracle/fast_recovery_area/PRB/archivelog/2016_08_17/o1_mf_1_7_cv8jlo4y_.arcthread=1 sequence=7

RMAN-00571:===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS===============

RMAN-00571: ===========================================================

RMAN-03002: failure of recover command at 08/17/2016 18:54:14

ORA-00283: recovery session canceled due to errors

RMAN-11003: failure during parse/execution of SQL statement:alter database recover logfile '/u01/app/oracle/fast_recovery_area/PRB/archivelog/2016_08_17/o1_mf_1_7_cv8jlo4y_.arc'

ORA-00283: recovery session canceled due to errors

ORA-00313: open failed for members of log group 2 of thread 1

ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/prb/redo02.log'

ORA-27037: unable to obtain file status

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

缺失归档日志情况下的恢复

prd-db2-> export ORACLE_SID=prb

prd-db2-> sqlplus  /as  sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 17 19:03:522016

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 -64bit Production

With the Partitioning, OLAP, Data Mining and Real ApplicationTesting options

 

SQL> shutdown immediate;

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup mount;

ORACLE instance started.

 

Total System Global Area 584568832 bytes

Fixed Size          2255432 bytes

Variable Size         226493880 bytes

Database Buffers      352321536 bytes

Redo Buffers            3497984 bytes

Database mounted.

SQL> alter database open ;

alter database open

*

ERROR at line 1:

ORA-01589: must use RESETLOGS or NORESETLOGS option fordatabase open

SQL> alter database open noresetlogs;

alter database open noresetlogs

*

ERROR at line 1:

ORA-01588: must use RESETLOGS option for database open

SQL> alter database open resetlogs;

Database altered.

SQL> select max(sequence#) from v$archived_log; 

MAX(SEQUENCE#)

--------------

         7

数据库正常启动

prd-db2-> export ORACLE_SID=prb

prd-db2-> sqlplus  /as  sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 17 19:11:492016

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 -64bit Production

With the Partitioning, OLAP, Data Mining and Real ApplicationTesting options

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

Total System Global Area 584568832 bytes

Fixed Size          2255432 bytes

Variable Size         226493880 bytes

Database Buffers      352321536 bytes

Redo Buffers           3497984 bytes

Database mounted.

Database opened.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28291944/viewspace-2151643/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/28291944/viewspace-2151643/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值