ITPub博客

首页 > 数据库 > Oracle > 基于增量备份进行恢复

基于增量备份进行恢复

原创 Oracle 作者:to_be_dba 时间:2015-12-18 14:56:54 0 删除 编辑
本文实验如何基于增量备份进行恢复


首先进行0级备份:
backup incremental level 0 database;
然后创建测试表:
create table scott.test_incremental as select sysdate current_data from dual;
查询表内容:
select to_char(current_data,'yyyy-mm-dd hh24:mi:ss') from scott.test_incremental;


切换日志:
alter system switch logfile;


进行1级增量备份:
backup incremental level 1 database tag 'incremental' format '/app/incremental_testdb_%u_%s_%p';


创建测试表2:
create table scott.test_incremental2 as select sysdate current_data from dual;
select to_char(current_data,'yyyy-mm-dd hh24:mi:ss') from scott.test_incremental2;


执行以下命令多次切换日志:
alter system switch logfile;
alter system switch logfile;

select current_scn from v$database;

使用scp命令将备份文件、归档日志全部拷贝到目标主机上,命令略。

进行异机恢复:
1)指定dbid
set dbid 2662459129
2)启动默认的dummy到nomount,恢复spfile
startup nomount;
restore spfile to pfile '/u01/oracle/dbs/pfiletestdb.ora' from '/u02/backup_from_remote/spfile_c-2662459129-20151107-00';
3)修改spfile中的参数,比如我是从DG主库恢复到普通单节点数据库,因此去掉了db_unique_name、logfile_name_convert等参数
用pfile启动(到nomount)
startup force pfile='/u01/oracle/dbs/pfiletestdb.ora';
4)恢复控制文件
restore controlfile from '/u02/backup_from_remote/spfile_c-2662459129-20151107-00';
alter database mount;
5)告诉rman待使用的备份文件、归档日志文件的位置
catalog start with '/u02/backup_from_remote';
catalog start with '/u02/archivedlog_from_remote';
6)执行恢复操作,基于SCN、sequence等进行恢复
run{
set newname for datafile   1 to '/u01/oradata/testdb/system01.dbf'; 
set newname for datafile   2 to '/u01/oradata/testdb/sysaux01.dbf'; 
set newname for datafile   3 to '/u01/oradata/testdb/undotbs01.dbf';
set newname for datafile   4 to '/u01/oradata/testdb/users01.dbf';  
set newname for datafile   5 to '/u01/oradata/testdb/ogg.dbf';      
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo03.log'' to ''/u01/oradata/testdb/redo03.log''"  ;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo02.log'' to ''/u01/oradata/testdb/redo02.log''"  ;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo01.log'' to ''/u01/oradata/testdb/redo01.log''"  ;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo01.log'' to ''/u01/oradata/testdb/stdbyredo01.log''"  ;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo02.log'' to ''/u01/oradata/testdb/stdbyredo02.log''"  ;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo03.log'' to ''/u01/oradata/testdb/stdbyredo03.log''"  ;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo04.log'' to ''/u01/oradata/testdb/stdbyredo04.log''"  ;
#SET UNTIL SCN 8645142;
set until sequence 180;
  # restore the database and switch the data file names
  RESTORE DATABASE;
  SWITCH DATAFILE ALL;
  # recover the database
  RECOVER DATABASE;
 # alter database open resetlogs;
}


下面是实际操作的命令输出结果整理:

=============================================================
以下在原库进行备份:(注:时间存在不一致,请忽略)
=============================================================

[192.168.73.134_20151218_05:53:34]
Last login: Sat Nov  7 17:13:16 2015 from 192.168.73.2
[oracle@ogg ~]$ 
[oracle@ogg ~]$ 
[oracle@ogg ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Nov 7 17:55:46 2015

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


connected to target database: TESTDB (DBID=2662459129)


RMAN> list backup of database;

using target database control file instead of recovery catalog

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
7       Full    998.58M    DISK        00:01:47     07-NOV-15      
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20151107T073441
        Piece Name: /app/back_20151107_7_1.bak
  List of Datafiles in backup set 7
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 8601781    07-NOV-15 /opt/ora10g/oradata/testdb/system01.dbf
  2       Full 8601781    07-NOV-15 /opt/ora10g/oradata/testdb/sysaux01.dbf
  3       Full 8601781    07-NOV-15 /opt/ora10g/oradata/testdb/undotbs01.dbf
  4       Full 8601781    07-NOV-15 /opt/ora10g/oradata/testdb/users01.dbf
  5       Full 8601781    07-NOV-15 /opt/ora10g/oradata/testdb/ogg.dbf

RMAN> delete backup of database;

allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=44 device type=DISK


List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
7       7       1   1   AVAILABLE   DISK        /app/back_20151107_7_1.bak


Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/app/back_20151107_7_1.bak RECID=7 STAMP=895131282
Deleted 1 objects

RMAN> delete noprompt archivelog all;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=44 device type=DISK
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/opt/ora10g/archive_dest/1_168_879131004.arc thread=1 sequence=168
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/opt/ora10g/archive_dest/1_169_879131004.arc thread=1 sequence=169
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/opt/ora10g/archive_dest/1_170_879131004.arc thread=1 sequence=170
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/opt/ora10g/archive_dest/1_171_879131004.arc thread=1 sequence=171
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/opt/ora10g/archive_dest/1_172_879131004.arc thread=1 sequence=172
List of Archived Log Copies for database with db_unique_name DBPRI
=====================================================================

Key     Thrd Seq     S Low Time 
------- ---- ------- - ---------
257     1    155     A 07-NOV-15
        Name: /opt/ora10g/archive_dest/1_155_879131004.arc


……中间省略


269     1    166     A 07-NOV-15
        Name: /opt/ora10g/archive_dest/1_166_879131004.arc


deleted archived log
archived log file name=/opt/ora10g/archive_dest/1_155_879131004.arc RECID=257 STAMP=895131162
deleted archived log
archived log file name=/opt/ora10g/archive_dest/1_156_879131004.arc RECID=258 STAMP=895131403
deleted archived log
……中间省略
archived log file name=/opt/ora10g/archive_dest/1_166_879131004.arc RECID=269 STAMP=895135255
Deleted 12 objects


RMAN> crosscheck backup;

using channel ORA_DISK_1
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/app/back_20151107_6_1.bak RECID=6 STAMP=895131123
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/app/back_20151107_8_1.bak RECID=8 STAMP=895131399
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/app/backup_arc_20151107_9_1.bak RECID=9 STAMP=895131404
Crosschecked 3 objects

RMAN> report obsolete;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           6      07-NOV-15         
  Backup Piece       6      07-NOV-15          /app/back_20151107_6_1.bak


RMAN> delete obsolete;


RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set           6      07-NOV-15         
  Backup Piece       6      07-NOV-15          /app/back_20151107_6_1.bak


Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/app/back_20151107_6_1.bak RECID=6 STAMP=895131123
Deleted 1 objects

RMAN> show all;


using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name DBPRI are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/ora10g/product/10.2.0/db_1/dbs/snapcf_dbpri.f'; # default

RMAN> configure controlfile autobackup on;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

RMAN> backup incremental level 0 database tag 'full';

Starting backup at 07-NOV-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=40 device type=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/ora10g/oradata/testdb/system01.dbf
input datafile file number=00002 name=/opt/ora10g/oradata/testdb/sysaux01.dbf
input datafile file number=00003 name=/opt/ora10g/oradata/testdb/undotbs01.dbf
input datafile file number=00005 name=/opt/ora10g/oradata/testdb/ogg.dbf
input datafile file number=00004 name=/opt/ora10g/oradata/testdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 07-NOV-15
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 11/07/2015 18:02:07
ORA-19502: write error on file "/opt/ora10g/flash_recovery_area/DBPRI/backupset/2015_11_07/o1_mf_nnnd0_FULL_c3vlxjfw_.bkp", block number 98176 (block size=8192)
ORA-27072: File I/O error
Linux Error: 25: Inappropriate ioctl for device
Additional information: 4
Additional information: 98176
Additional information: 40960

查看空间使用率,发现是空间不足导致的。当前使用的/opt/ora10g/flash_recovery_area是根目录挂载点("/")下的,可用空间740M,而system表空间的大小就超过1G了,因此报错。
[oracle@ogg ~]$ df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                         10849      9550       740  93% /
/dev/sda1                   99        32        62  35% /boot
tmpfs                      885         0       885   0% /dev/shm
/dev/sdc1                10077       190      9375   2% /app
/dev/sdb1                 5035       929      3850  20% /u02
none                       885         1       885   1% /var/lib/xenstored

为方便获取,将控制文件路径修改:
RMAN> configure controlfile autobackup format for device type disk to '/app/spfile_%F';

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/app/spfile_%F';
new RMAN configuration parameters are successfully stored

将备份存放位置修改为/app挂载点下:
RMAN> backup incremental level 0 database tag 'full' format '/app/dbfull_testdb_%u_%s_%p';

Starting backup at 07-NOV-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 device type=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/ora10g/oradata/testdb/system01.dbf
input datafile file number=00002 name=/opt/ora10g/oradata/testdb/sysaux01.dbf
input datafile file number=00003 name=/opt/ora10g/oradata/testdb/undotbs01.dbf
input datafile file number=00005 name=/opt/ora10g/oradata/testdb/ogg.dbf
input datafile file number=00004 name=/opt/ora10g/oradata/testdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 07-NOV-15
channel ORA_DISK_1: finished piece 1 at 07-NOV-15
piece handle=/app/dbfull_testdb_0bqlmct6_11_1 tag=FULL comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
Finished backup at 07-NOV-15

Starting Control File and SPFILE Autobackup at 07-NOV-15
piece handle=/app/spfile_c-2662459129-20151107-00 comment=NONE
Finished Control File and SPFILE Autobackup at 07-NOV-15

查看备份结果:
RMAN> list backup of database;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10      Incr 0  1023.61M   DISK        00:01:38     07-NOV-15      
        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: FULL
        Piece Name: /app/dbfull_testdb_0bqlmct6_11_1
  List of Datafiles in backup set 10
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/system01.dbf
  2    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/sysaux01.dbf
  3    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/undotbs01.dbf
  4    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/users01.dbf
  5    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/ogg.dbf

RMAN> list backup of controlfile;

List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8       Full    9.64M      DISK        00:00:02     07-NOV-15      
        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20151107T073441
        Piece Name: /app/back_20151107_8_1.bak
  Control File Included: Ckp SCN: 8601912      Ckp time: 07-NOV-15

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11      Full    9.64M      DISK        00:00:01     07-NOV-15      
        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20151107T181233
        Piece Name: /app/spfile_c-2662459129-20151107-00
  Control File Included: Ckp SCN: 8644546      Ckp time: 07-NOV-15


RMAN> list backup of spfile;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8       Full    9.64M      DISK        00:00:02     07-NOV-15      
        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20151107T073441
        Piece Name: /app/back_20151107_8_1.bak
  SPFILE Included: Modification time: 07-NOV-15
  SPFILE db_unique_name: DBPRI


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11      Full    9.64M      DISK        00:00:01     07-NOV-15      
        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20151107T181233
        Piece Name: /app/spfile_c-2662459129-20151107-00
  SPFILE Included: Modification time: 07-NOV-15
  SPFILE db_unique_name: DBPRI


切换日志:
SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

创建测试表1:
SQL> create table scott.test_incremental as select sysdate current_data from dual;

Table created.

SQL> select to_char(current_data,'yyyy-mm-dd hh24:mi:ss') from scott.test_incremental;

TO_CHAR(CURRENT_DAT
-------------------
2015-11-07 18:15:32

切换日志:
SQL> alter system switch logfile;

System altered.


进行1级增量备份:
[oracle@ogg ~]$ rman target /

Recoery Manager: Release 11.2.0.1.0 - Production on Sat Nov 7 18:16:46 2015

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

connected to target database: TESTDB (DBID=2662459129)

RMAN> backup incremental level 1 database tag 'incremental' format '/app/incremental_testdb_%u_%s_%p';

Starting backup at 07-NOV-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=40 device type=DISK
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/ora10g/oradata/testdb/system01.dbf
input datafile file number=00002 name=/opt/ora10g/oradata/testdb/sysaux01.dbf
input datafile file number=00003 name=/opt/ora10g/oradata/testdb/undotbs01.dbf
input datafile file number=00005 name=/opt/ora10g/oradata/testdb/ogg.dbf
input datafile file number=00004 name=/opt/ora10g/oradata/testdb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 07-NOV-15
channel ORA_DISK_1: finished piece 1 at 07-NOV-15
piece handle=/app/incremental_testdb_0dqlmd9u_13_1 tag=INCREMENTAL comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 07-NOV-15

Starting Control File and SPFILE Autobackup at 07-NOV-15
piece handle=/app/spfile_c-2662459129-20151107-01 comment=NONE
Finished Control File and SPFILE Autobackup at 07-NOV-15

创建测试表2:
[oracle@ogg ~]$ sqlplus / as sysdba

SQL> alter system switch logfile;

System altered.

SQL> create table scott.test_incremental2 as select sysdate current_data from dual;

Table created.

SQL> select to_char(current_data,'yyyy-mm-dd hh24:mi:ss') from scott.test_incremental2;

TO_CHAR(CURRENT_DAT
-------------------
2015-11-07 18:19:00

SQL>  select current_scn from v$database;

CURRENT_SCN
-----------
    8645142

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@ogg ~]$ cd /app
[oracle@ogg app]$ ls
back_20151107_8_1.bak        dbfull_testdb_0bqlmct6_11_1       spfile_c-2662459129-20151107-00
backup_arc_20151107_9_1.bak  incremental_testdb_0dqlmd9u_13_1  spfile_c-2662459129-20151107-01
[oracle@ogg app]$ du -sh *
9.7M    back_20151107_8_1.bak
676K    backup_arc_20151107_9_1.bak
1.1G    dbfull_testdb_0bqlmct6_11_1
572K    incremental_testdb_0dqlmd9u_13_1
9.7M    spfile_c-2662459129-20151107-00
9.7M    spfile_c-2662459129-20151107-01
[oracle@ogg app]$ scp ./* 192.168.73.124:/u02/backup_from_remote/
The authenticity of host '192.168.73.124 (192.168.73.124)' can't be established.
RSA key fingerprint is 08:76:c7:61:ab:ca:38:71:4c:dc:c4:9a:e0:f0:d1:f9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.73.124' (RSA) to the list of known hosts.
oracle@192.168.73.124's password: 
back_20151107_8_1.bak                            100% 9888KB   3.2MB/s   00:03    
backup_arc_20151107_9_1.bak                      100%  670KB 669.5KB/s   00:01    
dbfull_testdb_0bqlmct6_11_1                      100% 1024MB   2.7MB/s   06:19    
incremental_testdb_0dqlmd9u_13_1                 100%  568KB 568.0KB/s   00:00    
spfile_c-2662459129-20151107-00                  100% 9888KB   2.4MB/s   00:04    
spfile_c-2662459129-20151107-01                  100% 9888KB   3.2MB/s   00:03    
[oracle@ogg app]$ 
[oracle@ogg app]$ 


查看归档日志:
SQL> select name from v$archived_log;

NAME
--------------------------------------------------------------------------------
DBSTD

……(省略部分结果)
DBSTD
DBSTD2
DBSTD
/opt/ora10g/archive_dest/1_168_879131004.arc
/opt/ora10g/archive_dest/1_169_879131004.arc
/opt/ora10g/archive_dest/1_170_879131004.arc
/opt/ora10g/archive_dest/1_171_879131004.arc
/opt/ora10g/archive_dest/1_172_879131004.arc
/opt/ora10g/archive_dest/1_173_879131004.arc
/opt/ora10g/archive_dest/1_174_879131004.arc
/opt/ora10g/archive_dest/1_175_879131004.arc
/opt/ora10g/archive_dest/1_176_879131004.arc

280 rows selected.

直接查看,因为该库是data guard架构,有备库的归档日志信息及被删除了的归档日志信息

可以查看归档日志状态来确认:
SQL> select distinct status from v$archived_log;

S
-
D
A

查询V$ARCHIVED_LOG时,注意其日志状态为:
A - Available
D - Deleted
U - Unavailable
X - Expired

SQL> select name from v$archived_log where status='A' and name like '/opt%';

NAME
--------------------------------------------------------------------------------
/opt/ora10g/archive_dest/1_168_879131004.arc
/opt/ora10g/archive_dest/1_169_879131004.arc
/opt/ora10g/archive_dest/1_170_879131004.arc
/opt/ora10g/archive_dest/1_171_879131004.arc
/opt/ora10g/archive_dest/1_172_879131004.arc
/opt/ora10g/archive_dest/1_173_879131004.arc
/opt/ora10g/archive_dest/1_174_879131004.arc
/opt/ora10g/archive_dest/1_175_879131004.arc
/opt/ora10g/archive_dest/1_176_879131004.arc

9 rows selected.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

通过scp命令将归档传到目标库:
[oracle@ogg app]$ scp /opt/ora10g/archive_dest/1_1
1_168_879131004.arc  1_170_879131004.arc  1_172_879131004.arc  1_174_879131004.arc  1_176_879131004.arc  
1_169_879131004.arc  1_171_879131004.arc  1_173_879131004.arc  1_175_879131004.arc  
[oracle@ogg app]$ scp /opt/ora10g/archive_dest/1_1* 192.168.73.124:/u02/archivedlog_from_remote/
oracle@192.168.73.124's password: 
1_168_879131004.arc                      100%   17MB   2.5MB/s   00:07    
1_169_879131004.arc                      100%   24KB  23.5KB/s   00:00    
1_170_879131004.arc                      100%  398KB 398.0KB/s   00:00    
1_171_879131004.arc                      100%   49KB  49.0KB/s   00:00    
1_172_879131004.arc                      100%   39MB   2.6MB/s   00:15    
1_173_879131004.arc                      100% 2014KB   2.0MB/s   00:01    
1_174_879131004.arc                      100% 2560     2.5KB/s   00:00    
1_175_879131004.arc                      100%   76KB  76.0KB/s   00:00    
1_176_879131004.arc                      100%   69KB  69.0KB/s   00:00

======================================================================
以下在192.168.73.124上恢复数据库
======================================================================

[oracle@rhlinux admin]$ cd /u01/admin/testdb/
创建必要的目录(这些可能不全,实际可根据报错提示创建)
[oracle@rhlinux testdb]$ mkdir adump
[oracle@rhlinux testdb]$ mkdir bdump
[oracle@rhlinux testdb]$ mkdir cdump
[oracle@rhlinux testdb]$ mkdir udump
[oracle@rhlinux testdb]$ rman target /      

Recovery Manager: Release 11.2.0.1.0 - Production on Sun Jun 22 03:34:56 2014

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

connected to target database: TESTDB (not mounted)
指定dbid:
RMAN> set dbid 2662459129

executing command: SET DBID

恢复spfile
RMAN> restore spfile to pfile '/u01/oracle/dbs/pfiletestdb.ora' from '/u02/backup_from_remote/spfile_c-2662459129-20151107-00';

Starting restore at 22-JUN-14
using channel ORA_DISK_1

channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u02/backup_from_remote/spfile_c-2662459129-20151107-00
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 22-JUN-14

查看从备份获得的pfile,并修改:
[oracle@rhlinux backup_testdb]$ cat /u01/oracle/dbs/pfiletestdb.ora   
dbpri.__db_cache_size=226492416
dbpri.__java_pool_size=4194304
dbpri.__large_pool_size=4194304
dbpri.__oracle_base='/opt/ora10g'#ORACLE_BASE set from environment
dbpri.__pga_aggregate_target=184549376
dbpri.__sga_target=557842432
dbpri.__shared_io_pool_size=0
dbpri.__shared_pool_size=306184192
dbpri.__streams_pool_size=8388608
*.audit_file_dest='/opt/ora10g/admin/testdb/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/opt/ora10g/oradata/testdb/control01.ctl','/opt/ora10g/flash_recovery_area/testdb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_name_convert='TESTDB','TESTDB'
*.db_name='testdb'
*.db_recovery_file_dest='/opt/ora10g/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.db_unique_name='dbpri'
*.diagnostic_dest='/opt/ora10g'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dbpriXDB)'
*.fal_client='dbstd'
*.fal_server='dbpri'
*.log_archive_config='DG_CONFIG=(dbpri,dbstd)'
*.log_archive_dest_1='LOCATION=/opt/ora10g/archive_dest VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=dbpri'
*.log_archive_dest_2='SERVICE=DBSTD LGWR async VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=dbstd'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'
*.log_archive_format='%t_%s_%r.arc'
*.log_file_name_convert='TESTDB','TESTDB'
*.open_cursors=300
*.pga_aggregate_target=184549376
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=555745280
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

[oracle@rhlinux ~]$ vi /u01/oracle/dbs/pfiletestdb.ora
dbpri.__db_cache_size=226492416
dbpri.__java_pool_size=4194304
dbpri.__large_pool_size=4194304
dbpri.__oracle_base='/opt/ora10g'#ORACLE_BASE set from environment
dbpri.__pga_aggregate_target=184549376
dbpri.__sga_target=557842432
dbpri.__shared_io_pool_size=0
dbpri.__shared_pool_size=306184192
dbpri.__streams_pool_size=8388608
*.audit_file_dest='/u01/admin/testdb/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/oradata/testdb/control01.ctl','/u01/flash_recovery_area/testdb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='testdb'
*.db_recovery_file_dest='/u01/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
#*.db_unique_name='dbpri'
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=dbpriXDB)'
*.log_archive_dest_1='LOCATION='/u01/TESTDB/archivelog'
*.log_archive_dest_state_1='enable'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=184549376
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=555745280
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'
"dbs/pfiletestdb.ora" 31L, 1087C written        
                                                                                                    
[oracle@rhlinux ~]$ sqlplus / as sysdba               

SQL*Plus: Release 11.2.0.1.0 Production on Sun Jun 22 05:09:01 2014

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

Connected to an idle instance.

SQL> startup force pfile='/u01/oracle/dbs/pfiletestdb.ora';
ORACLE instance started.

Total System Global Area  556584960 bytes
Fixed Size                  1337860 bytes
Variable Size             167773692 bytes
Database Buffers          381681664 bytes
Redo Buffers                5791744 bytes
ORA-00205: error in identifying control file, check alert log for more info

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@rhlinux ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun Jun 22 05:10:09 2014

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

connected to target database: TESTDB (not mounted)

RMAN> restore controlfile from '/u02/backup_from_remote/spfile_c-2662459129-20151107-00';


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


channel ORA_DISK_1: restoring control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/22/2014 05:10:18
ORA-19504: failed to create file "/u01/flash_recovery_area/testdb/control02.ctl"
ORA-27040: file create error, unable to create file
Linux Error: 2: No such file or directory
ORA-19600: input file is control file  (/u01/oradata/testdb/control01.ctl)
ORA-19601: output file is control file  (/u01/flash_recovery_area/testdb/control02.ctl)


这是由于缺少目录导致的,创建/u01/flash_recovery_area/testdb/后再次执行:
RMAN> restore controlfile from '/u02/backup_from_remote/spfile_c-2662459129-20151107-00';

Starting restore at 22-JUN-14
using channel ORA_DISK_1


channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/oradata/testdb/control01.ctl
output file name=/u01/flash_recovery_area/testdb/control02.ctl
Finished restore at 22-JUN-14

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1


通过catalog命令指定备份和归档日志的路径:
RMAN> catalog start with '/u02/backup_from_remote';

Starting implicit crosscheck backup at 22-JUN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 22-JUN-14

Starting implicit crosscheck copy at 22-JUN-14
using channel ORA_DISK_1
Finished implicit crosscheck copy at 22-JUN-14

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

searching for all files that match the pattern /u02/backup_from_remote

List of Files Unknown to the Database
=====================================
File Name: /u02/backup_from_remote/spfile_c-2662459129-20151107-00
File Name: /u02/backup_from_remote/spfile_c-2662459129-20151107-01
File Name: /u02/backup_from_remote/backup_arc_20151107_9_1.bak
File Name: /u02/backup_from_remote/back_20151107_8_1.bak
File Name: /u02/backup_from_remote/incremental_testdb_0dqlmd9u_13_1
File Name: /u02/backup_from_remote/dbfull_testdb_0bqlmct6_11_1

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u02/backup_from_remote/spfile_c-2662459129-20151107-00
File Name: /u02/backup_from_remote/spfile_c-2662459129-20151107-01
File Name: /u02/backup_from_remote/backup_arc_20151107_9_1.bak
File Name: /u02/backup_from_remote/back_20151107_8_1.bak
File Name: /u02/backup_from_remote/incremental_testdb_0dqlmd9u_13_1
File Name: /u02/backup_from_remote/dbfull_testdb_0bqlmct6_11_1

RMAN> catalog start with '/u02/archivedlog_from_remote';

searching for all files that match the pattern /u02/archivedlog_from_remote

List of Files Unknown to the Database
=====================================
File Name: /u02/archivedlog_from_remote/1_175_879131004.arc
File Name: /u02/archivedlog_from_remote/1_171_879131004.arc
File Name: /u02/archivedlog_from_remote/1_174_879131004.arc
File Name: /u02/archivedlog_from_remote/1_173_879131004.arc
File Name: /u02/archivedlog_from_remote/1_176_879131004.arc
File Name: /u02/archivedlog_from_remote/1_172_879131004.arc
File Name: /u02/archivedlog_from_remote/1_169_879131004.arc
File Name: /u02/archivedlog_from_remote/1_168_879131004.arc
File Name: /u02/archivedlog_from_remote/1_170_879131004.arc

Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u02/archivedlog_from_remote/1_175_879131004.arc
File Name: /u02/archivedlog_from_remote/1_171_879131004.arc
File Name: /u02/archivedlog_from_remote/1_174_879131004.arc
File Name: /u02/archivedlog_from_remote/1_173_879131004.arc
File Name: /u02/archivedlog_from_remote/1_176_879131004.arc
File Name: /u02/archivedlog_from_remote/1_172_879131004.arc
File Name: /u02/archivedlog_from_remote/1_169_879131004.arc
File Name: /u02/archivedlog_from_remote/1_168_879131004.arc
File Name: /u02/archivedlog_from_remote/1_170_879131004.arc

RMAN> list backup of database;


List of Backup Sets
===================


BS Key  Type LV Size
------- ---- -- ----------
10      Incr 0  1023.61M
  List of Datafiles in backup set 10
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/system01.dbf
  2    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/sysaux01.dbf
  3    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/undotbs01.dbf
  4    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/users01.dbf
  5    0  Incr 8644440    07-NOV-15 /opt/ora10g/oradata/testdb/ogg.dbf

  Backup Set Copy #1 of backup set 10
  Device Type Elapsed Time Completion Time Compressed Tag
  ----------- ------------ --------------- ---------- ---
  DISK        00:01:38     07-NOV-15       NO         FULL

    List of Backup Pieces for backup set 10 Copy #1
    BP Key  Pc# Status      Piece Name
    ------- --- ----------- ----------
    10      1   EXPIRED     /app/dbfull_testdb_0bqlmct6_11_1

  Backup Set Copy #2 of backup set 10
  Device Type Elapsed Time Completion Time Compressed Tag
  ----------- ------------ --------------- ---------- ---
  DISK        00:01:38     22-JUN-14       NO         FULL

    List of Backup Pieces for backup set 10 Copy #2
    BP Key  Pc# Status      Piece Name
    ------- --- ----------- ----------
    14      1   AVAILABLE   /u02/backup_from_remote/dbfull_testdb_0bqlmct6_11_1

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11      Incr 1  560.00K    DISK        00:00:00     07-NOV-15      
        BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: INCREMENTAL
        Piece Name: /u02/backup_from_remote/incremental_testdb_0dqlmd9u_13_1
  List of Datafiles in backup set 11
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1    1  Incr 8644951    07-NOV-15 /opt/ora10g/oradata/testdb/system01.dbf
  2    1  Incr 8644951    07-NOV-15 /opt/ora10g/oradata/testdb/sysaux01.dbf
  3    1  Incr 8644951    07-NOV-15 /opt/ora10g/oradata/testdb/undotbs01.dbf
  4    1  Incr 8644951    07-NOV-15 /opt/ora10g/oradata/testdb/users01.dbf
  5    1  Incr 8644951    07-NOV-15 /opt/ora10g/oradata/testdb/ogg.dbf

RMAN> list archivelog all;

List of Archived Log Copies for database with db_unique_name TESTDB
=====================================================================

Key     Thrd Seq     S Low Time 
------- ---- ------- - ---------
282     1    168     A 07-NOV-15
        Name: /opt/ora10g/archive_dest/1_168_879131004.arc


294     1    168     A 07-NOV-15
        Name: /u02/archivedlog_from_remote/1_168_879131004.arc


283     1    169     A 07-NOV-15
        Name: /opt/ora10g/archive_dest/1_169_879131004.arc


293     1    169     A 07-NOV-15
        Name: /u02/archivedlog_from_remote/1_169_879131004.arc


284     1    170     A 07-NOV-15
        Name: /opt/ora10g/archive_dest/1_170_879131004.arc


295     1    170     A 07-NOV-15
        Name: /u02/archivedlog_from_remote/1_170_879131004.arc


285     1    171     A 07-NOV-15
        Name: /opt/ora10g/archive_dest/1_171_879131004.arc


288     1    171     A 07-NOV-15
        Name: /u02/archivedlog_from_remote/1_171_879131004.arc


286     1    172     A 07-NOV-15
        Name: /opt/ora10g/archive_dest/1_172_879131004.arc


292     1    172     A 07-NOV-15
        Name: /u02/archivedlog_from_remote/1_172_879131004.arc


290     1    173     A 07-NOV-15
        Name: /u02/archivedlog_from_remote/1_173_879131004.arc


289     1    174     A 07-NOV-15
        Name: /u02/archivedlog_from_remote/1_174_879131004.arc


287     1    175     A 07-NOV-15
        Name: /u02/archivedlog_from_remote/1_175_879131004.arc


291     1    176     A 07-NOV-15
        Name: /u02/archivedlog_from_remote/1_176_879131004.arc

RMAN> 

RMAN> exit

Recovery Manager complete.
[oracle@rhlinux ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Jun 22 05:16:15 2014

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

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select status from v$instance;

STATUS
------------
MOUNTED

SQL> col name for a40
SQL> select file#,name from v$datafile;

     FILE# NAME
---------- ----------------------------------------
         1 /opt/ora10g/oradata/testdb/system01.dbf
         2 /opt/ora10g/oradata/testdb/sysaux01.dbf
         3 /opt/ora10g/oradata/testdb/undotbs01.dbf
         4 /opt/ora10g/oradata/testdb/users01.dbf
         5 /opt/ora10g/oradata/testdb/ogg.dbf

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/opt/ora10g/oradata/testdb/redo03.log
/opt/ora10g/oradata/testdb/redo02.log
/opt/ora10g/oradata/testdb/redo01.log
/opt/ora10g/oradata/testdb/stdbyredo01.log
/opt/ora10g/oradata/testdb/stdbyredo02.log
/opt/ora10g/oradata/testdb/stdbyredo03.log
/opt/ora10g/oradata/testdb/stdbyredo04.log

7 rows selected.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@rhlinux ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun Jun 22 05:35:47 2014

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

connected to target database: TESTDB (DBID=2662459129, not open)

RMAN> run{
2> set newname for datafile   2 to '/u01/oradata/testdb/sysaux01.dbf 
set newname for datafile   1 to '/u01/oradata/testdb/system01.dbf 
set newname for datafile   2 to '/u01/oradata/testdb/sysaux01.dbf 

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01006: error signaled during parse
RMAN-02001: unrecognized punctuation symbol "/"
set newname for datafile   3 to '/u01/oradata/testdb/undotbs01.dbf

RMAN> 2> sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo03.log'' to ''/u01/oradata/testdb/redo03.log''"  ;
set newname for datafile   4 to '/u01/oradata/testdb/users01.dbf  

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01006: error signaled during parse
RMAN-02001: unrecognized punctuation symbol "/"
set newname for datafile   5 to '/u01/oradata/testdb/ogg.dbf      
sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo03.log'' to ''/u01/oradata/testdb/redo03.log''"  ;

RMAN> 2> 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "single-quoted-string": expecting one of: "newline, ;"
RMAN-01007: at line 2 column 34 file: standard input
  # restore the database and switch the data file names
  SWITCH DATAFILE ALL;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo02.log'' to ''/u01/oradata/testdb/redo02.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo01.log'' to ''/u01/oradata/testdb/redo01.log''"  ;

RMAN> 
sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo01.log'' to ''/u01/oradata/testdb/stdbyredo01.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo02.log'' to ''/u01/oradata/testdb/stdbyredo02.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo03.log'' to ''/u01/oradata/testdb/stdbyredo03.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo04.log'' to ''/u01/oradata/testdb/stdbyredo04.log''"  ;
SET UNTIL SCN 8645142;
  # restore the database and switch the data file names
  RESTORE DATABASE;
  SWITCH DATAFILE ALL;
  # recover the database
  RECOVER DATABASE;
 # alter database open resetlogs;
using target database control file instead of recovery catalog
}
sql statement: alter database rename file ''/opt/ora10g/oradata/testdb/redo02.log'' to ''/u01/oradata/testdb/redo02.log''

RMAN> 
sql statement: alter database rename file ''/opt/ora10g/oradata/testdb/redo01.log'' to ''/u01/oradata/testdb/redo01.log''

RMAN> 
sql statement: alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo01.log'' to ''/u01/oradata/testdb/stdbyredo01.log''

RMAN> 
sql statement: alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo02.log'' to ''/u01/oradata/testdb/stdbyredo02.log''

RMAN> 
sql statement: alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo03.log'' to ''/u01/oradata/testdb/stdbyredo03.log''

RMAN> 
sql statement: alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo04.log'' to ''/u01/oradata/testdb/stdbyredo04.log''

RMAN> 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03031: this option of set command needs to be used inside a run block

RMAN> 2> 
Starting restore at 22-JUN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=22 device type=DISK


channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /opt/ora10g/oradata/testdb/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /opt/ora10g/oradata/testdb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /opt/ora10g/oradata/testdb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /opt/ora10g/oradata/testdb/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /opt/ora10g/oradata/testdb/ogg.dbf
channel ORA_DISK_1: reading from backup piece /u02/backup_from_remote/dbfull_testdb_0bqlmct6_11_1
channel ORA_DISK_1: ORA-19870: error while restoring backup piece /u02/backup_from_remote/dbfull_testdb_0bqlmct6_11_1
ORA-19504: failed to create file "/opt/ora10g/oradata/testdb/system01.dbf"
ORA-27040: file create error, unable to create file
Linux Error: 2: No such file or directory


failover to previous backup


RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/22/2014 05:36:02
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore


RMAN> 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "all": expecting one of: "double-quoted-string, integer, single-quoted-string"
RMAN-01007: at line 1 column 19 file: standard input


RMAN> 2> 
Starting recover at 22-JUN-14
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/22/2014 05:36:02
RMAN-06094: datafile 1 must be restored


RMAN> 2> 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "}": expecting one of: "advise, allocate, alter, backup, @, catalog, change, configure, connect, convert, copy, create, crosscheck, delete, drop, duplicate, exit, flashback, grant, host, import, list, mount, open, print, quit, recover, register, release, repair, replace, report, reset, restore, resync, revoke, run, send, set, show, shutdown, spool, sql, startup, switch, transport, unregister, upgrade, validate, {, "
RMAN-01007: at line 2 column 1 file: standard input


………………中间因为分号错误等原因执行了多次该命令,需要注意的是:后续再次执行命令时,alter database rename file命令已经执行成功了,再次执行就会报错:


RMAN> run{
2> set newname for datafile   1 to '/u01/oradata/testdb/system01.dbf'; 
3> set newname for datafile   2 to '/u01/oradata/testdb/sysaux01.dbf'; 
4> set newname for datafile   3 to '/u01/oradata/testdb/undotbs01.dbf';
set newname for datafile   4 to '/u01/oradata/testdb/users01.dbf';  
set newname for datafile   5 to '/u01/oradata/testdb/ogg.dbf';      
sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo03.log'' to ''/u01/oradata/testdb/redo03.log''"  ;
8> sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo03.log'' to ''/u01/oradata/testdb/stdbyredo03.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo02.log'' to ''/u01/oradata/testdb/redo02.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo01.log'' to ''/u01/oradata/testdb/redo01.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo01.log'' to ''/u01/oradata/testdb/stdbyredo01.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo02.log'' to ''/u01/oradata/testdb/stdbyredo02.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo03.log'' to ''/u01/oradata/testdb/stdbyredo03.log''"  ;
sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo04.log'' to ''/u01/oradata/testdb/stdbyredo04.log''"  ;
SET UNTIL SCN 8645142;
  # restore the database and switch the data file names
  RESTORE DATABASE;
  SWITCH DATAFILE ALL;
  # recover the database
  RECOVER DATABASE;
 # alter database open resetlogs;
21> }


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


sql statement: alter database rename file ''/opt/ora10g/oradata/testdb/redo03.log'' to ''/u01/oradata/testdb/redo03.log''


sql statement: alter database rename file ''/opt/ora10g/oradata/testdb/redo02.log'' to ''/u01/oradata/testdb/redo02.log''
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 06/22/2014 05:38:10
RMAN-11003: failure during parse/execution of SQL statement: alter database rename file '/opt/ora10g/oradata/testdb/redo02.log' to '/u01/oradata/testdb/redo02.log'
ORA-01511: error in renaming log/data files
ORA-01516: nonexistent log file, data file, or temporary file "/opt/ora10g/oradata/testdb/redo02.log"


修改后正常执行,但最后会报错:


RMAN> run{
set newname for datafile   1 to '/u01/oradata/testdb/system01.dbf'; 
set newname for datafile   2 to '/u01/oradata/testdb/sysaux01.dbf'; 
4> set newname for datafile   3 to '/u01/oradata/testdb/undotbs01.dbf';
set newname for datafile   4 to '/u01/oradata/testdb/users01.dbf';  
6> set newname for datafile   5 to '/u01/oradata/testdb/ogg.dbf';      
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo03.log'' to ''/u01/oradata/testdb/redo03.log''"  ;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo02.log'' to ''/u01/oradata/testdb/redo02.log''"  ;
9> SET UNTIL SCN 8645142;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/redo01.log'' to ''/u01/oradata/testdb/redo01.log''"  ;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo01.log'' to ''/u01/oradata/testdb/stdbyredo01.log''"  ;
11>   RECOVER DATABASE;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo02.log'' to ''/u01/oradata/testdb/stdbyredo02.log''"  ;
# alter database open resetlogs;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo03.log'' to ''/u01/oradata/testdb/stdbyredo03.log''"  ;
#sql "alter database rename file ''/opt/ora10g/oradata/testdb/stdbyredo04.log'' to ''/u01/oradata/testdb/stdbyredo04.log''"  ;
SET UNTIL SCN 8645142;
  # restore the database and switch the data file names
  RESTORE DATABASE;
  SWITCH DATAFILE ALL;
  # recover the database
  RECOVER DATABASE;
 # alter database open resetlogs;
21> }

executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET until clause


Starting restore at 22-JUN-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 device type=DISK


channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/oradata/testdb/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oradata/testdb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/oradata/testdb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/oradata/testdb/users01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /u01/oradata/testdb/ogg.dbf
channel ORA_DISK_1: reading from backup piece /u02/backup_from_remote/dbfull_testdb_0bqlmct6_11_1
channel ORA_DISK_1: piece handle=/u02/backup_from_remote/dbfull_testdb_0bqlmct6_11_1 tag=FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:03:28
Finished restore at 22-JUN-14


datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=850889018 file name=/u01/oradata/testdb/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=850889018 file name=/u01/oradata/testdb/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=850889018 file name=/u01/oradata/testdb/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=850889018 file name=/u01/oradata/testdb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=850889018 file name=/u01/oradata/testdb/ogg.dbf


Starting recover at 22-JUN-14
using channel ORA_DISK_1

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

请登录后发表评论 登录
全部评论

注册时间:2011-11-23

  • 博文量
    148
  • 访问量
    391983