rac 简单归档设置下备份恢复理解

理解最简单的备份方法,理解rman是如何备份与恢复的。
集群环境下对归档日志的备份注意事项:
必须保证备份实例上能够访问所有实例的归档日志,否则会报错,除非为各个实例分配通道。

集群环境下恢复注意事项:
进行restore时,为每个实例配置通道,以正确的转储。
进行recover时,当前操作实例必须能够访问所有的归档日志文件,否则可能恢复失败。

以上注意事项在任何归档日志设置情况下成立,只是有些情况下oracle为我们做了,或通过asm,或通过nfs,或其它方式。


以下以 最简单的归档日志设置 为例进行测试,
alter system set log_archive_dest_1='LOCATION=/oracle/rac1_arch' scope=spfile sid='RACDB1';
alter system set log_archive_dest_1='LOCATION=/oracle/rac2_arch' scope=spfile sid='RACDB2';

备份过程:

RACDB1@rac1 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 23:52:28 2012

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

connected to target database: RACDB (DBID=769091368)

RMAN> backup archivelog all tag='arc_bak' format='/oracle/backup/arch_%U_%T';

Starting backup at 11-JAN-12
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=152 instance=RACDB1 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 01/11/2012 23:52:54
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625: error identifying file /oracle/rac2_arch/2_11_771474603.dbf
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

RMAN> quit


Recovery Manager complete.

ORA-19625: error identifying file /oracle/rac2_arch/2_11_771474603.dbf 
ORA-19625: error identifying file /oracle/rac2_arch/2_11_771474603.dbf
找不到2_11_771474603.dbf 这个归档日志文件,因为在本地/oracle/rac2_arch/目录没有这个文件。这个文件在节点二的本地/oracle/rac2_arch/目录下,看下面:

RACDB1@rac1 /home/oracle$ ll /oracle/rac2_arch/
total 0
RACDB1@rac1 /home/oracle$ ssh rac2
Last login: Wed Jan 11 23:50:52 2012 from rac1
RACDB2@rac2 /home/oracle$ ll /oracle/rac1_arch/
total 0
RACDB2@rac2 /home/oracle$ ll /oracle/rac2_arch/
total 132
-rw-rw---- 1 oracle oinstall 95744 Jan 11 23:51 2_11_771474603.dbf   --就是无法找到这个日志文件
-rw-rw---- 1 oracle oinstall 32768 Jan 11 23:52 2_12_771474603.dbf

采用connect的方法来分配通道,可以成功备份。

RACDB1@rac1 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Jan 12 00:31:16 2012

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

connected to target database: RACDB (DBID=769091368)

RMAN>  run
2>  {
3>  allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;
 allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
5>  backup archivelog all tag='arc_bak' ;
6>  release channel c1;
7>  release channel c2;
8>  }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=131 instance=RACDB1 devtype=DISK

allocated channel: c2
channel c2: sid=147 instance=RACDB2 devtype=DISK

Starting backup at 12-JAN-12
current log archived
......
......
piece handle=/oracle/backup/arch_08n0hm06_1_1_20120112 tag=ARC_BAK comment=NONE
channel c2: backup set complete, elapsed time: 00:00:03
Finished backup at 12-JAN-12

released channel: c1

released channel: c2

RMAN> quit


Recovery Manager complete.

--查看两个节点的备份结果
RACDB1@rac1 /home/oracle$ ll /oracle/backup/
total 159996
-rw-r----- 1 oracle oinstall 123994112 Jan 12 00:31 arch_05n0hlvp_1_1_20120112
-rw-r----- 1 oracle oinstall  39667712 Jan 12 00:32 arch_07n0hm05_1_1_20120112
RACDB1@rac1 /home/oracle$ su rac2
su: user rac2 does not exist
RACDB1@rac1 /home/oracle$ ssh rac2
Last login: Thu Jan 12 00:27:36 2012 from rac1
RACDB2@rac2 /home/oracle$ ll /oracle/backup/
total 73252
-rw-r----- 1 oracle oinstall 73526784 Jan 12 00:32 arch_06n0hlvp_1_1_20120112
-rw-r----- 1 oracle oinstall  1399296 Jan 12 00:32 arch_08n0hm06_1_1_20120112

恢复过程:
 --全备数据库
 --分别在两个节点构造数据后,备份所有归档日志
 --关闭数据库后,在asmcmd下删除一数据文件
 --使用归档日志实施数据文件的恢复.(备份中没有对此数据文件的备份)
 
 归档日志设置:
 alter system set log_archive_dest_1='LOCATION=/oracle/rac1_arch' scope=spfile sid='RACDB1';
 alter system set log_archive_dest_1='LOCATION=/oracle/rac2_arch' scope=spfile sid='RACDB2';

--首先全备数据库
BACKUP FORMAT '/oracle/backup/racdb_%U_%T' DATABASE TAG racdb_hot_db_bk; 
--两个节点构造数据 
RACDB1@rac1 /home/oracle$ sqlplus lau/lau@racdb1

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 22:54:44 2012

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, Real Application Clusters, OLAP and Data Mining options

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/racdb/datafile/system.256.771474531
+DATA/racdb/datafile/undotbs1.258.771474533
+DATA/racdb/datafile/sysaux.257.771474533
+DATA/racdb/datafile/users.259.771474535
+DATA/racdb/datafile/example.264.771474649
+DATA/racdb/datafile/undotbs2.265.771474825

6 rows selected.

SQL> create tablespace test;

Tablespace created.

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/racdb/datafile/system.256.771474531
+DATA/racdb/datafile/undotbs1.258.771474533
+DATA/racdb/datafile/sysaux.257.771474533
+DATA/racdb/datafile/users.259.771474535
+DATA/racdb/datafile/example.264.771474649
+DATA/racdb/datafile/undotbs2.265.771474825
+DATA/racdb/datafile/test.283.772321119

7 rows selected.

SQL> create table t(id int,text varchar2(10)) tablespace test;

Table created.

SQL> insert into t values(1,'hello');

1 row created.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
RACDB1@rac1 /home/oracle$ ssh rac2
Last login: Wed Jan 11 21:29:25 2012 from rac1
RACDB2@rac2 /home/oracle$ sqlplus lau/lau@racdb2

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 21:41:51 2012

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, Real Application Clusters, OLAP and Data Mining options

SQL> insert into t values(2,'world');

1 row created.

SQL> commit;

Commit complete.

SQL> alter system switch logfile;

System altered.

SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

--查看两个节点的归档日志
RACDB2@rac2 /home/oracle$ ll /oracle/rac2_arch/
total 1052
-rw-r----- 1 oracle oinstall 1070592 Jan 11 21:42 2_8_771474603.dbf
RACDB2@rac2 /home/oracle$ ssh rac1
Last login: Wed Jan 11 21:29:21 2012 from 192.168.246.1
RACDB1@rac1 /home/oracle$ ll /oracle/rac1_arch/
total 26876
-rw-r----- 1 oracle oinstall 27486720 Jan 11 21:41 1_9_771474603.dbf
RACDB1@rac1 /home/oracle$ ssh rac2
Last login: Wed Jan 11 21:41:31 2012 from rac1
RACDB2@rac2 /home/oracle$ ll /oracle/backup/
total 0

--全备归档日志
RACDB2@rac2 /home/oracle$ ssh rac1
Last login: Wed Jan 11 21:42:49 2012 from rac2
RACDB1@rac1 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 21:43:47 2012

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

connected to target database: RACDB (DBID=769091368)

run
 {
 allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;
 allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
 backup archivelog all delete all input;
 release channel c1;
 release channel c2;
8>  }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=141 instance=RACDB1 devtype=DISK

allocated channel: c2
channel c2: sid=124 instance=RACDB2 devtype=DISK

Starting backup at 11-JAN-12
current log archived
......
......
channel c1: deleting archive log(s)
archive log filename=/oracle/rac1_arch/1_9_771474603.dbf recid=15 stamp=772321287
archive log filename=/oracle/rac1_arch/1_10_771474603.dbf recid=17 stamp=772321478
Finished backup at 11-JAN-12

released channel: c1

released channel: c2

RMAN> quit


Recovery Manager complete.
--删除一数据文件
ASMCMD> rm test.283.772321119
ASMCMD> exit
+ASM1@rac1 /home/oracle$ export ORACLE_SID=RACDB1
RACDB1@rac1 /home/oracle$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 21:57:01 2012

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

Connected to an idle instance.

--启动数据库,发现文件丢失
SQL> startup
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              96471284 bytes
Database Buffers           67108864 bytes
Redo Buffers                2973696 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 7 - see DBWR trace file
ORA-01110: data file 7: '+DATA/racdb/datafile/test.283.772321119'

SQL> quit

--登录rman,试图进行恢复
RACDB1@rac1 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 21:57:37 2012

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

connected to target database: RACDB (DBID=769091368, not open)

RMAN> startup force mount;

Oracle instance started
database mounted

Total System Global Area     167772160 bytes

Fixed Size                     1218316 bytes
Variable Size                 96471284 bytes
Database Buffers              67108864 bytes
Redo Buffers                   2973696 bytes

RMAN> sql 'alter database datafile 7 offline';

using target database control file instead of recovery catalog
sql statement: alter database datafile 7 offline

RMAN> sql 'alter database open';

sql statement: alter database open

RMAN> restore datafile 7;

Starting restore at 11-JAN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=137 instance=RACDB1 devtype=DISK

creating datafile fno=7 name=+DATA/racdb/datafile/test.283.772321119
restore not done; all files readonly, offline, or already restored
Finished restore at 11-JAN-12

RMAN>  recover datafile 7;

Starting recover at 11-JAN-12
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=8
channel ORA_DISK_1: restoring archive log
archive log thread=2 sequence=9

--看这步,无法读取 /oracle/backup/arch_05n0hc7c_1_1_20120111 归档日志文件
channel ORA_DISK_1: reading from backup piece /oracle/backup/arch_05n0hc7c_1_1_20120111
ORA-19870: error reading backup piece /oracle/backup/arch_05n0hc7c_1_1_20120111
ORA-19505: failed to identify file "/oracle/backup/arch_05n0hc7c_1_1_20120111"
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=9
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=10
channel ORA_DISK_1: reading from backup piece /oracle/backup/arch_06n0hc7d_1_1_20120111
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/backup/arch_06n0hc7d_1_1_20120111 tag=TAG20120111T214445
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
archive log filename=/oracle/rac1_arch/1_9_771474603.dbf thread=1 sequence=9
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/11/2012 22:00:48
RMAN-20506: no backup of archivelog found

--这里提示没有足够的归档日志文件 seq 9,seq 8
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of log thread 2 seq 9 lowscn 822678 found to restore
RMAN-06025: no backup of log thread 2 seq 8 lowscn 791574 found to restore

RMAN> quit


Recovery Manager complete.
RACDB1@rac1 /home/oracle$ ll /oracle/rac1_arch/
total 26956
-rw-r----- 1 oracle oinstall    77824 Jan 11 22:00 1_10_771474603.dbf
-rw-r----- 1 oracle oinstall 27486720 Jan 11 22:00 1_9_771474603.dbf
RACDB1@rac1 /home/oracle$ ll /oracle/backup/
total 825588
-rw-r----- 1 oracle oinstall 146313728 Jan 11 21:45 arch_03n0hc6h_1_1_20120111
-rw-r----- 1 oracle oinstall  27565568 Jan 11 21:45 arch_06n0hc7d_1_1_20120111
-rw-r----- 1 oracle oinstall 655302656 Jan 11 21:36 racdb_01n0hbj8_1_1_20120111
-rw-r----- 1 oracle oinstall  15368192 Jan 11 21:36 racdb_02n0hbn2_1_1_20120111
RACDB1@rac1 /home/oracle$ ssh rac2
Last login: Wed Jan 11 21:46:24 2012 from rac1

--这里可以看出,节点二上的归档日志没有被restore
RACDB2@rac2 /home/oracle$ ll /oracle/rac2_arch/
total 0
RACDB2@rac2 /home/oracle$ ll /oracle/backup/
total 28248
-rw-r----- 1 oracle oinstall 27809280 Jan 11 21:45 arch_04n0hc6h_1_1_20120111
-rw-r----- 1 oracle oinstall  1075712 Jan 11 21:45 arch_05n0hc7c_1_1_20120111
RACDB2@rac2 /home/oracle$ ssh rac1
Last login: Wed Jan 11 21:47:23 2012 from rac2
RACDB1@rac1 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 22:06:55 2012

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

connected to target database: RACDB (DBID=769091368)

RMAN> run {
 allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;
 allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
 restore datafile 7;
 recover datafile 7;
 sql 'alter database datafile 5 online';
7>  }

released channel: ORA_DISK_1
allocated channel: c1
channel c1: sid=152 instance=RACDB1 devtype=DISK

released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================

--提示通道2没有打开,应将节点二置于mount状态
RMAN-12001: could not open channel c2
RMAN-10008: could not create channel context
RMAN-10003: unable to connect to target database
ORA-12521: TNS:listener does not currently know of instance requested in connect descriptor

RMAN> quit


Recovery Manager complete.
RACDB1@rac1 /home/oracle$ ssh rac2
Last login: Wed Jan 11 22:04:07 2012 from rac1
RACDB2@rac2 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 22:07:44 2012

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

connected to target database (not started)

RMAN> startup mount

Oracle instance started
database mounted

Total System Global Area     167772160 bytes

Fixed Size                     1218316 bytes
Variable Size                 88082676 bytes
Database Buffers              75497472 bytes
Redo Buffers                   2973696 bytes

RMAN> quit


Recovery Manager complete.
RACDB2@rac2 /home/oracle$ ssh rac1
Last login: Wed Jan 11 22:06:50 2012 from rac2
RACDB1@rac1 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 22:08:16 2012

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

connected to target database: RACDB (DBID=769091368)

run {
2>  allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;
3>  allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
 restore datafile 7;
 recover datafile 7;
 sql 'alter database datafile 5 online';
7>  }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=143 instance=RACDB1 devtype=DISK

allocated channel: c2
channel c2: sid=152 instance=RACDB2 devtype=DISK

Starting restore at 11-JAN-12

creating datafile fno=7 name=+DATA/racdb/datafile/test.283.772322367
restore not done; all files readonly, offline, or already restored
Finished restore at 11-JAN-12

Starting recover at 11-JAN-12

starting media recovery

archive log thread 1 sequence 9 is already on disk as file /oracle/rac1_arch/1_9_771474603.dbf
archive log thread 1 sequence 10 is already on disk as file /oracle/rac1_arch/1_10_771474603.dbf
archive log filename=/oracle/rac1_arch/1_9_771474603.dbf thread=1 sequence=9
channel c2: starting archive log restore to default destination
channel c2: restoring archive log
archive log thread=2 sequence=8
channel c2: restoring archive log
archive log thread=2 sequence=9
channel c2: reading from backup piece /oracle/backup/arch_05n0hc7c_1_1_20120111
channel c2: restored backup piece 1
piece handle=/oracle/backup/arch_05n0hc7c_1_1_20120111 tag=TAG20120111T214445
channel c2: restore complete, elapsed time: 00:00:01
archive log filename=/oracle/rac2_arch/2_8_771474603.dbf thread=2 sequence=8
released channel: c1
released channel: c2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/11/2012 22:08:31
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/oracle/rac2_arch/2_8_771474603.dbf'

--这里提示,在我们当前操作的节点,即节点一找不到 /oracle/rac2_arch/2_8_771474603.dbf 归档日志文件
ORA-00308: cannot open archived log '/oracle/rac2_arch/2_8_771474603.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

RMAN> quit


Recovery Manager complete.

--查看两个节点可知,归档日志已经正确restore到指定的归档日志位置
RACDB1@rac1 /home/oracle$ ll /oracle/rac1_arch/
total 26956
-rw-r----- 1 oracle oinstall    77824 Jan 11 22:00 1_10_771474603.dbf
-rw-r----- 1 oracle oinstall 27486720 Jan 11 22:00 1_9_771474603.dbf
RACDB1@rac1 /home/oracle$ ssh rac2
Last login: Wed Jan 11 22:07:36 2012 from rac1
RACDB2@rac2 /home/oracle$ ll /oracle/rac2_arch/
total 1056
-rw-r----- 1 oracle oinstall 1070592 Jan 11 22:08 2_8_771474603.dbf
-rw-r----- 1 oracle oinstall    4096 Jan 11 22:08 2_9_771474603.dbf
RACDB2@rac2 /home/oracle$ ssh rac1
Last login: Wed Jan 11 22:08:13 2012 from rac2
RACDB1@rac1 /home/oracle$ scp rac2:/oracle/rac2_arch/2_8_771474603.dbf  /oracle/rac1_arch/
2_8_771474603.dbf                                                 100% 1046KB   1.0MB/s   00:00
RACDB1@rac1 /home/oracle$ ll /oracle/rac1_arch/
total 28008
-rw-r----- 1 oracle oinstall    77824 Jan 11 22:00 1_10_771474603.dbf
-rw-r----- 1 oracle oinstall 27486720 Jan 11 22:00 1_9_771474603.dbf
-rw-r----- 1 oracle oinstall  1070592 Jan 11 22:15 2_8_771474603.dbf
RACDB1@rac1 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 22:15:51 2012

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

connected to target database: RACDB (DBID=769091368)

RMAN> 
 run {
 allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;
 allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
 recover datafile 7; --因为已经正确restore,这里只进行recover。
5>  sql 'alter database datafile 7 online';
6>  }

released channel: ORA_DISK_1
allocated channel: c1
channel c1: sid=128 instance=RACDB1 devtype=DISK

allocated channel: c2
channel c2: sid=146 instance=RACDB2 devtype=DISK

Starting recover at 11-JAN-12

starting media recovery

archive log thread 1 sequence 9 is already on disk as file /oracle/rac1_arch/1_9_771474603.dbf
archive log thread 1 sequence 10 is already on disk as file /oracle/rac1_arch/1_10_771474603.dbf
archive log filename=/oracle/rac1_arch/1_9_771474603.dbf thread=1 sequence=9
channel c2: starting archive log restore to default destination
channel c2: restoring archive log
archive log thread=2 sequence=8
channel c2: restoring archive log
archive log thread=2 sequence=9
channel c2: reading from backup piece /oracle/backup/arch_05n0hc7c_1_1_20120111
channel c2: restored backup piece 1
piece handle=/oracle/backup/arch_05n0hc7c_1_1_20120111 tag=TAG20120111T214445
channel c2: restore complete, elapsed time: 00:00:01
archive log filename=/oracle/rac2_arch/2_8_771474603.dbf thread=2 sequence=8
released channel: c1
released channel: c2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/11/2012 22:18:03
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/oracle/rac2_arch/2_8_771474603.dbf'

--在当前节点上依然找不到/oracle/rac2_arch/2_8_771474603.dbf
ORA-00308: cannot open archived log '/oracle/rac2_arch/2_8_771474603.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3

RMAN> quit


Recovery Manager complete.

--在当前节点,即节点一,创建rac2_arch目录,并赋于oracle用户,并将缺失的/oracle/rac2_arch/2_8_771474603.dbf日志文件远程复制到节点一。
RACDB1@rac1 /oracle$ su
Password:
RACDB1@rac1 /oracle$ cd /oracle/
RACDB1@rac1 /oracle$ mkdir rac2_arch
RACDB1@rac1 /oracle$ chown -R oracle.dba /oracle/rac2_arch/
RACDB1@rac1 /oracle$ scp rac2:/oracle/rac2_arch/2_8_771474603.dbf  /oracle/rac2_arch/
2_8_771474603.dbf                                                 100% 1046KB   1.0MB/s   00:00

RACDB1@rac1 /oracle$ su - oracle
RACDB1@rac1 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 22:21:23 2012

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

connected to target database: RACDB (DBID=769091368)

 run {
2>  allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
 allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;
 allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
 recover datafile 7;
 sql 'alter database datafile 7 online';
6>  }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=137 instance=RACDB1 devtype=DISK

allocated channel: c2
channel c2: sid=146 instance=RACDB2 devtype=DISK

Starting recover at 11-JAN-12

starting media recovery

archive log thread 1 sequence 9 is already on disk as file /oracle/rac1_arch/1_9_771474603.dbf
archive log thread 1 sequence 10 is already on disk as file /oracle/rac1_arch/1_10_771474603.dbf
archive log filename=/oracle/rac1_arch/1_9_771474603.dbf thread=1 sequence=9
channel c2: starting archive log restore to default destination
channel c2: restoring archive log
archive log thread=2 sequence=8
channel c2: restoring archive log
archive log thread=2 sequence=9
channel c2: reading from backup piece /oracle/backup/arch_05n0hc7c_1_1_20120111
channel c2: restored backup piece 1
piece handle=/oracle/backup/arch_05n0hc7c_1_1_20120111 tag=TAG20120111T214445
channel c2: restore complete, elapsed time: 00:00:01
archive log filename=/oracle/rac2_arch/2_8_771474603.dbf thread=2 sequence=8
released channel: c1
released channel: c2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/11/2012 22:21:42
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/oracle/rac2_arch/2_8_771474603.dbf'
ORA-00308: cannot open archived log '/oracle/rac2_arch/2_8_771474603.dbf'
ORA-27041: unable to open file
--日志文件是使用root用户复制的,因此才没有权限
Linux Error: 13: Permission denied
Additional information: 2

RMAN> quit


Recovery Manager complete.

--删除2_8_771474603.dbf后,使用oracle用户重新复制到节点1的rac2_arch目录下。
RACDB1@rac1 /home/oracle$ su
Password:
RACDB1@rac1 /home/oracle$ cd /oracle/rac2_arch/
RACDB1@rac1 /oracle/rac2_arch$ ll
total 1052
-rw-r----- 1 root root 1070592 Jan 11 22:21 2_8_771474603.dbf
RACDB1@rac1 /oracle/rac2_arch$ rm *
rm: remove regular file `2_8_771474603.dbf'? y
RACDB1@rac1 /oracle/rac2_arch$ su - oracle
RACDB1@rac1 /home/oracle$  scp rac2:/oracle/rac2_arch/2_8_771474603.dbf  /oracle/rac2_arch/
2_8_771474603.dbf                                                 100% 1046KB   1.0MB/s   00:00

--以下可知,已成功恢复。
RACDB1@rac1 /home/oracle$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 11 22:23:07 2012

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

connected to target database: RACDB (DBID=769091368)

 run {
 allocate channel c1 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb1;
3>  allocate channel c2 device type disk format '/oracle/backup/arch_%U_%T' connect sys/oracle@racdb2;
4>  recover datafile 7;
 sql 'alter database datafile 7 online';
6>  }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=146 instance=RACDB1 devtype=DISK

allocated channel: c2
channel c2: sid=146 instance=RACDB2 devtype=DISK

Starting recover at 11-JAN-12

starting media recovery

archive log thread 1 sequence 9 is already on disk as file /oracle/rac1_arch/1_9_771474603.dbf
archive log thread 1 sequence 10 is already on disk as file /oracle/rac1_arch/1_10_771474603.dbf
archive log thread 2 sequence 8 is already on disk as file /oracle/rac2_arch/2_8_771474603.dbf
archive log filename=/oracle/rac1_arch/1_9_771474603.dbf thread=1 sequence=9
archive log filename=/oracle/rac2_arch/2_8_771474603.dbf thread=2 sequence=8
media recovery complete, elapsed time: 00:00:05
channel c2: starting archive log restore to default destination
channel c2: restoring archive log
archive log thread=2 sequence=9
channel c2: reading from backup piece /oracle/backup/arch_05n0hc7c_1_1_20120111
channel c2: restored backup piece 1
piece handle=/oracle/backup/arch_05n0hc7c_1_1_20120111 tag=TAG20120111T214445
channel c2: restore complete, elapsed time: 00:00:01
Finished recover at 11-JAN-12

sql statement: alter database datafile 7 online
released channel: c1
released channel: c2

RMAN> quit


Recovery Manager complete.

--验证恢复结果
RACDB1@rac1 /home/oracle$ sqlplus lau/lau@racdb1

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 11 22:24:15 2012

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, Real Application Clusters, OLAP and Data Mining options

SQL> select * from t;

        ID TEXT
---------- ----------
         1 hello
         2 world

SQL>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值