rman 异机恢复

target DB

[root@testora197 rmanback]# hostname

testora197.uplooking.com

[oracle@testora197 ~]$ echo $ORACLE_SID

Gabriel

SQL> select  *  from  v$version where rownum<2;

BANNER

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

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod

 

auxiliary  DB

[root@testora201 ~]# hostname

testora201.uplooking.com

 

 

target  database    首先查看数据库中的数据:

 

SQL> conn  gabriel/gabriel

Connected.

SQL> select  table_name  from user_tables;

 

TABLE_NAME

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

TEST_REDO

SQL> select  count(1)  from  test_redo;

 

  COUNT(1)

----------

         2

进行一个0级备份:

[root@testora197 rmanback]# ll

total 644260

-rw-r----- 1 oracle oinstall   4035072 Aug  6 14:51 arch_4dmjanvh_1_1_20110806

-rw-r----- 1 oracle oinstall   1610752 Aug  6 14:51 arch_4emjanvh_1_1_20110806

-rw-r----- 1 oracle oinstall   7405568 Aug  6 14:51 ctl_file_4fmjanvl_1_1_20110806

-rw-r----- 1 oracle oinstall  33677312 Aug  6 14:50 gabriel_lev0_4amjanrv_1_1_20110806

-rw-r----- 1 oracle oinstall 612220928 Aug  6 14:51 gabriel_lev0_4bmjans0_1_1_20110806

-rw-r----- 1 oracle oinstall     98304 Aug  6 14:51 gabriel_spfile_4gmjanvm_1_1_20110806

 

Auxiliary数据库上装好数据库软件, 不建库,准备拿192.168.0.110的全库备份进行恢复

具体步骤如下:

(1)      拷贝192.168.0.110 的备份到 target库上:

 

 

[root@testora201 rmanback]# scp 192.168.0.110:/backup/rmanback/*  ./

The authenticity of host '192.168.0.110 (192.168.0.110)' can't be established.

RSA key fingerprint is 78:44:1c:ce:78:24:b4:54:a2:94:f7:50:03:36:74:2d.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.0.110' (RSA) to the list of known hosts.

root@192.168.0.110's password:

arch_4dmjanvh_1_1_20110806                                                                          100% 3941KB   3.9MB/s   00:01

arch_4emjanvh_1_1_20110806                                                                                                    100% 1573KB   1.5MB/s   00:00

ctl_file_4fmjanvl_1_1_20110806                                                                                                        100% 7232KB   3.5MB/s   00:02

gabriel_lev0_4amjanrv_1_1_20110806                                                                                                    100%   32MB   2.3MB/s   00:14

gabriel_lev0_4bmjans0_1_1_20110806                                                                                                    100%  584MB   1.5MB/s   06:21

gabriel_spfile_4gmjanvm_1_1_20110806                                                                                                  100%   96KB  96.0KB/s   00:00

 

由于110 上有一个数据库的存在, ORACLE_SID 如下:

[oracle@testora201 ~]$ echo  $ORACLE_SID

gabriel1

为了不影响此库,做了一个随便的设置(假设我们拿到了一个备份, 但是不知道SID)

[oracle@testora201 ~]$ export  ORACLE_SID=test

[oracle@testora201 ~]$ rman  target  /

[oracle@testora201 rmanback]$ rman  target /  nocatalog

[uniread] Loaded history (21 lines)

 

Recovery Manager: Release 10.2.0.1.0 - Production on Sat Aug 6 20:41:56 2011

 

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

 

connected to target database (not started)

可以看出 数据库的状态是 not started  状态, 要进行参数文件恢复数据库必须启动到nomount 状态。

RMAN> startup  nomount

 

startup failed: ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/10g/dbs/inittest.ora'

 

starting Oracle instance without parameter file for retrival of spfile

Oracle instance started

 

Total System Global Area     159383552 bytes

 

Fixed Size                     1218244 bytes

Variable Size                 58722620 bytes

Database Buffers              92274688 bytes

Redo Buffers                   7168000 bytes

可以看到 数据启动, 此过程 rman  没有 找到 spfiletest.ora  inittest.ora  直接采用默认的init.ora 启动了。

(2)     恢复参数文件

RMAN> restore spfile to pfile '/u01/app/oracle/product/10g/dbs/initgabrielaa.ora'  from  '/backup/rmanback/gabriel_spfile_4gmjanvm_1_1_20110806';

 

Starting restore at 06-AUG-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=36 devtype=DISK

 

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

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

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

RMAN-03002: failure of restore command at 08/06/2011 20:48:42

RMAN-06172: no autobackup found or specified handle is not a valid copy or piece

----看到此错误刚开始有点迷悟,难道真的是 not a valid , target 库上进行了相关的命令恢复, 完全是正常的, 根据经验,肯定是文件权限的问题, 检查了一下, 果然是scp 后,忘记了 chown  chmod 进行相关更改后:

[root@testora201 ~]# chown  oracle.oinstall /backup/rmanback/ -R

[root@testora201 ~]# chmod 755  /backup/rmanback/ -R

[oracle@testora201 ~]$ rman target /  nocatalog

[uniread] Loaded history (25 lines)

 

Recovery Manager: Release 10.2.0.1.0 - Production on Sat Aug 6 20:55:50 2011

 

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

 

connected to target database: DUMMY (not mounted)

using target database control file instead of recovery catalog

 

RMAN> restore spfile to pfile '/u01/app/oracle/product/10g/dbs/initgabrielaa.ora'  from  '/backup/rmanback/gabriel_spfile_4gmjanvm_1_1_20110806';

 

Starting restore at 06-AUG-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=39 devtype=DISK

 

channel ORA_DISK_1: autobackup found: /backup/rmanback/gabriel_spfile_4gmjanvm_1_1_20110806

channel ORA_DISK_1: SPFILE restore from autobackup complete

Finished restore at 06-AUG-11

 参数文件恢复完成, vim  initgabrielaa.ora  找出相关信息, 改为正确的SID 将数据库启动 nomount 状态

[oracle@testora201 ~]$ export ORACLE_SID=gabriel

[oracle@testora201 ~]$ sql  /  as sysdba

[uniread] Loaded history (10 lines)

 

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Aug 6 21:04:07 2011

 

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

 

Connected to an idle instance.

 

SQL> create spfile='/u01/app/oracle/product/10g/dbs/spfilegabriel.ora' from pfile='/u01/app/oracle/product/10g/dbs/initgabriel.ora';

 

File created.

SQL> startup  nomount

ORA-09925: Unable to create audit trail file

Linux Error: 2: No such file or directory

Additional information: 9925

可以看出oracle 相关的一些dump 目录没有创建, 根据initgabriel.ora 的相关信息建立所需目录

[root@testora201 ~]# mkdir /u01/app/oracle/admin/gabriel/{a,b,c,u,dp}dump -p

[root@testora201 ~]# mkdir /u01/app/oracle/oradata/gabriel

[root@testora201 ~]# chown  oracle.oinstall /u01/app/oracle/admin/gabriel -R

[root@testora201 ~]# chmod  755 /u01/app/oracle/admin/gabriel -R

[root@testora201 ~]# chown  oracle.oinstall  /u01/app/oracle/oradata/gabriel

[root@testora201 ~]# chmod  755   /u01/app/oracle/oradata/Gabriel

 

SQL> startup  nomount

ORACLE instance started.

 

Total System Global Area  167772160 bytes

Fixed Size                  1218292 bytes

Variable Size              83888396 bytes

Database Buffers           75497472 bytes

Redo Buffers                7168000 bytes

SQL> show parameter  pfile

 

NAME                                 TYPE        VALUE

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

spfile                               string      /u01/app/oracle/product/10g/db

                                                 s/spfilegabriel.ora

 

(3)     恢复控制文件

在上已经创建了控制文件的存放路径, 根据initgabriel.ora 信息 直接对三个参数文件进行恢复

RMAN> restore  controlfile    from  '/backup/rmanback/ctl_file_4fmjanvl_1_1_20110806';

 

Starting restore at 06-AUG-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

 

channel ORA_DISK_1: restoring control file

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

output filename=/u01/app/oracle/oradata/gabriel/control01.ctl

output filename=/u01/app/oracle/oradata/gabriel/control02.ctl

output filename=/u01/app/oracle/oradata/gabriel/control03.ctl

Finished restore at 06-AUG-11

 

RMAN> startup  mount

 

database is already started

database mounted

released channel: ORA_DISK_1

 

(4)     恢复数据文件

Restore   database:

由于个人建立数据库的规范性, 数据文件存放目录 target 库的目录基本一致, 无需做set newname 处理, 直接进行 restore 处理

RMAN> restore database;

 

Starting restore at 06-AUG-11

Starting implicit crosscheck backup at 06-AUG-11

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=156 devtype=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: sid=155 devtype=DISK

Crosschecked 4 objects

Crosschecked 17 objects

Finished implicit crosscheck backup at 06-AUG-11

 

Starting implicit crosscheck copy at 06-AUG-11

using channel ORA_DISK_1

using channel ORA_DISK_2

Finished implicit crosscheck copy at 06-AUG-11

 

searching for all files in the recovery area

cataloging files...

no files cataloged

 

using channel ORA_DISK_1

using channel ORA_DISK_2

 

channel ORA_DISK_1: starting datafile backupset restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

restoring datafile 00002 to /u01/app/oracle/oradata/gabriel/undotbs01.dbf

restoring datafile 00004 to /u01/app/oracle/oradata/gabriel/users01.dbf

restoring datafile 00006 to /u01/app/oracle/oradata/gabriel/rman01.dbf

restoring datafile 00008 to /u01/app/oracle/oradata/gabriel/test_readonly01.dbf

channel ORA_DISK_1: reading from backup piece /backup/rmanback/gabriel_lev0_4amjanrv_1_1_20110806

channel ORA_DISK_2: starting datafile backupset restore

channel ORA_DISK_2: specifying datafile(s) to restore from backup set

restoring datafile 00001 to /u01/app/oracle/oradata/gabriel/system01.dbf

restoring datafile 00003 to /u01/app/oracle/oradata/gabriel/sysaux01.dbf

restoring datafile 00005 to /u01/app/oracle/oradata/gabriel/example01.dbf

restoring datafile 00007 to /u01/app/oracle/oradata/gabriel/rm01.dbf

channel ORA_DISK_2: reading from backup piece /backup/rmanback/gabriel_lev0_4bmjans0_1_1_20110806

channel ORA_DISK_1: restored backup piece 1

piece handle=/backup/rmanback/gabriel_lev0_4amjanrv_1_1_20110806 tag=ORCL_LEV0

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

channel ORA_DISK_2: restored backup piece 1

piece handle=/backup/rmanback/gabriel_lev0_4bmjans0_1_1_20110806 tag=ORCL_LEV0

channel ORA_DISK_2: restore complete, elapsed time: 00:01:44

Finished restore at 06-AUG-11

 

Recover  database:

 

RMAN> recover database;

 

Starting recover at 06-AUG-11

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=155 devtype=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: sid=154 devtype=DISK

 

starting media recovery

 

channel ORA_DISK_1: starting archive log restore to default destination

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=57

channel ORA_DISK_1: restoring archive log

archive log thread=1 sequence=58

channel ORA_DISK_1: reading from backup piece /backup/rmanback/arch_4emjanvh_1_1_20110806

channel ORA_DISK_1: restored backup piece 1

piece handle=/backup/rmanback/arch_4emjanvh_1_1_20110806 tag=ARC_BAK

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

archive log filename=/u01/app/oracle/flash_recovery_area/GABRIEL/archivelog/2011_08_06/o1_mf_1_57_73tlrw4c_.arc thread=1 sequence=57

channel default: deleting archive log(s)

archive log filename=/u01/app/oracle/flash_recovery_area/GABRIEL/archivelog/2011_08_06/o1_mf_1_57_73tlrw4c_.arc recid=59 stamp=758498972

archive log filename=/u01/app/oracle/flash_recovery_area/GABRIEL/archivelog/2011_08_06/o1_mf_1_58_73tlrwb5_.arc thread=1 sequence=58

channel default: deleting archive log(s)

archive log filename=/u01/app/oracle/flash_recovery_area/GABRIEL/archivelog/2011_08_06/o1_mf_1_58_73tlrwb5_.arc recid=58 stamp=758498972

unable to find archive log

archive log thread=1 sequence=59

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

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

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

RMAN-03002: failure of recover command at 08/06/2011 22:09:35

RMAN-06054: media recovery requesting unknown log: thread 1 seq 59 lowscn 905349

----由于缺省必要的redo log  故数据库报以上错误,当然可以使用 recover database until scn 905349 排除以上故障。

 

(5)      Resetlogs  打开数据库, resetlogs  数据库后 数据库自动生成了 3 redo group  1 temp文件。

 

[oracle@testora201 ~]$ sql /  as  sysdba

[uniread] Loaded history (28 lines)

 

SQL*Plus: Release 10.2.0.1.0 - Production on Sat Aug 6 22:13:33 2011

 

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

 

 

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

With the Partitioning, OLAP and Data Mining options

 

SQL> alter database open  resetlogs;

 

Database altered.

 

[oracle@testora201 ~]$ cd /u01/app/oracle/oradata/gabriel/

control01.ctl        example01.dbf        redo03.log           sysaux01.dbf         test_readonly01.dbf

control02.ctl        redo01.log           rm01.dbf             system01.dbf         undotbs01.dbf

control03.ctl        redo02.log           rman01.dbf           temp01.dbf           users01.dbf

SQL> select dbms_flashback.get_system_change_number as scn from dual;

 

       SCN

----------

907093

SQL> conn  gabriel/gabriel

Connected.

SQL>  select  count(1)  from  test_redo;

 

  COUNT(1)

----------

         2

数据是可以看到了,既然已经resetlogs  数据的丢失是肯定的, 如果要正常使用此库, 还需对数据库的  redo log    temp  做优化处理, 如果 target 数据库还在使用, 想两个库不相冲突,必须使用系统级别的nid  更改一下 dbname  dbid.

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

转载于:http://blog.itpub.net/8117479/viewspace-704418/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值