作者:容易        2013-04-12   16:08:26


oracle rman全备异机恢复

首先创建全备,并且将生成的备份拷贝到新的系统环境中。

RMAN> backup database format '/oracle/oradata/rman/full_backup_%U.bak' tag='full_bak' plus archivelog format

'/oracle/oradata/rman/archivelog_full_%U.bak'

delete all input;


Starting backup at 11-APR-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=1390 recid=69 stamp=812459602
input archive log thread=1 sequence=1391 recid=68 stamp=812459601
input archive log thread=1 sequence=1392 recid=66 stamp=812457694
input archive log thread=1 sequence=1393 recid=67 stamp=812458162
input archive log thread=1 sequence=1394 recid=70 stamp=812459695
input archive log thread=1 sequence=1395 recid=71 stamp=812459742
input archive log thread=1 sequence=1396 recid=72 stamp=812485313
channel ORA_DISK_1: starting piece 1 at 11-APR-13
channel ORA_DISK_1: finished piece 1 at 11-APR-13
piece handle=/oracle/oradata/rman/archivelog_full_0bo6r2m1_1_1.bak tag=TAG20130411T182153 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/oracle/oradata/archive/1_1390_810066552.dbf recid=69 stamp=812459602
archive log filename=/oracle/oradata/archive/1_1391_810066552.dbf recid=68 stamp=812459601
archive log filename=/oracle/oradata/archive/1_1392_810066552.dbf recid=66 stamp=812457694
archive log filename=/oracle/oradata/archive/1_1393_810066552.dbf recid=67 stamp=812458162
archive log filename=/oracle/oradata/archive/1_1394_810066552.dbf recid=70 stamp=812459695
archive log filename=/oracle/oradata/archive/1_1395_810066552.dbf recid=71 stamp=812459742
archive log filename=/oracle/oradata/archive/1_1396_810066552.dbf recid=72 stamp=812485313
Finished backup at 11-APR-13

Starting backup at 11-APR-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00007 name=/oracle/oradata/syslogdb/remove_tbs_01.dbf
input datafile fno=00002 name=/oracle/oradata/syslogdb/undo1.dbf
input datafile fno=00006 name=/oracle/oradata/syslogdb/syslog_tbs01_02.dbf
input datafile fno=00008 name=/oracle/oradata/syslogdb/undo_tbs02_01.dbf
input datafile fno=00005 name=/oracle/oradata/syslogdb/syslog_tbs01_01.dbf
input datafile fno=00003 name=/oracle/oradata/syslogdb/sysaux01.dbf
input datafile fno=00001 name=/oracle/oradata/syslogdb/system01.dbf
input datafile fno=00004 name=/oracle/oradata/syslogdb/user_tbs01.dbf
channel ORA_DISK_1: starting piece 1 at 11-APR-13
channel ORA_DISK_1: finished piece 1 at 11-APR-13
piece handle=/oracle/oradata/rman/full_backup_0co6r2ms_1_1.bak tag=FULL_BAK comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 11-APR-13
channel ORA_DISK_1: finished piece 1 at 11-APR-13
piece handle=/oracle/oradata/rman/full_backup_0do6r2ph_1_1.bak tag=FULL_BAK comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 11-APR-13

Starting backup at 11-APR-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=1397 recid=73 stamp=812485427
channel ORA_DISK_1: starting piece 1 at 11-APR-13
channel ORA_DISK_1: finished piece 1 at 11-APR-13
piece handle=/oracle/oradata/rman/archivelog_full_0eo6r2pk_1_1.bak tag=TAG20130411T182347 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
channel ORA_DISK_1: deleting archive log(s)
archive log filename=/oracle/oradata/archive/1_1397_810066552.dbf recid=73 stamp=812485427
Finished backup at 11-APR-13


1)准备系统平台,灾难前的系统平台一致。
2)设置个ORACLE_SID进入rman
export ORACLE_SID=syslogdb
[oracle@mydg1 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Fri Apr 12 10:32:18 2013

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

connected to target database (not started)

3)将数据库启动到nomount状态
RMAN> startup nomount;

startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/oracle/10g/dbs/initsyslogdb.ora'

starting Oracle instance without parameter file for retrival of spfile
Oracle instance started

Total System Global Area     159383552 bytes

Fixed Size                     2082400 bytes
Variable Size                 67111328 bytes
Database Buffers              83886080 bytes
Redo Buffers                   6303744 bytes

RMAN>
4)使用rman 恢复spfile,默认会还原至$ORACLE_HOME/dbs目录中
#RMAN> restore spfile to '/oracle/oradata/newspfile' from
RMAN> restore spfile from '/oracle/oradata/rman/full_backup_0do6r2ph_1_1.bak';

Starting restore at 12-APR-13
using channel ORA_DISK_1

channel ORA_DISK_1: autobackup found: /oracle/oradata/rman/full_backup_0do6r2ph_1_1.bak
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 12-APR-13

5)查看spfile 内容,确认db name,以及手动创建相应的目录
这里需要手动创建的目录有
mkdir -pv /oracle/admin/syslogdb/adump
mkdir -pv /oracle/admin/syslogdb/bdump
mkdir -pv /oracle/admin/syslogdb/cdump
mkdir -pv /oracle/admin/syslogdb/udump
mkdir -pv /oracle/oradata/archive
mkdir -pv /oracle/oradata/flash_recovery_area
mkdir -pv /oracle/oradata/syslogdb

[root@mydg oradata]# strings  /oracle/oradata/newspfile
[oracle@mydg1 dbs]$ strings  /oracle/10g/dbs/spfilesyslogdb.ora
syslogdb.__db_cache_size=1677721600
syslogdb.__java_pool_size=16777216
syslogdb.__large_pool_size=16777216
syslogdb.__shared_pool_size=402653184
syslogdb.__streams_pool_size=16777216
*.audit_file_dest='/oracle/admin/syslogdb/adump'
*.background_dump_dest='/oracle/admin/syslogdb/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/oracle/oradata/syslogdb/control01.ctl','/oracle/oradata/syslogdb/control02.ctl'
*.core_dump_dest='/oracle/admin/syslogdb/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_name='syslogdb'
*.db_recovery_file_dest='/oracle/oradata/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.log_archive_dest_1='location=/oracle/oradata/archive'
*.open_cursors=600
*.pga_aggregate_target=402653184
*.processes=1000
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=2147483648
*.undo_management='AUTO'
*.undo_tablespace='UNDO_TBS02'
*.user_dump_dest='/oracle/admin/syslogdb/udump'

6)关闭数据库,重新进入 rman 并且启动数据库到nomount状态。
RMAN> shutdown immediate;

Oracle instance shut down

RMAN> exit


Recovery Manager complete.
[oracle@mydg1 ~]$ rman target /

Recovery Manager: Release 10.2.0.4.0 - Production on Fri Apr 12 10:46:06 2013

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

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     2085320 bytes
Variable Size                452988472 bytes
Database Buffers            1677721600 bytes
Redo Buffers                  14688256 bytes

RMAN>

7)还原控制文件


RMAN> restore controlfile from '/oracle/oradata/rman/full_backup_0do6r2ph_1_1.bak';

Starting restore at 12-APR-13
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output filename=/oracle/oradata/syslogdb/control01.ctl
output filename=/oracle/oradata/syslogdb/control02.ctl
Finished restore at 12-APR-13

RMAN>
9)将数据库启动到mount状态加载controlfile;
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN>
10)查看备份信息

RMAN> list backup;
如果没有列出还原时需要用到的备份片,请执行第11步

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

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
11      1.48G      DISK        00:00:18     11-APR-13      
       BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20130411T182153
       Piece Name: /oracle/oradata/rman/archivelog_full_0bo6r2m1_1_1.bak

 List of Archived Logs in backup set 11
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    1390    12224517985 11-APR-13 12224779006 11-APR-13
 1    1391    12224779006 11-APR-13 12224993874 11-APR-13
 1    1392    12224993874 11-APR-13 12225256629 11-APR-13
 1    1393    12225256629 11-APR-13 12225541036 11-APR-13
 1    1394    12225541036 11-APR-13 12225807515 11-APR-13
 1    1395    12225807515 11-APR-13 12226064608 11-APR-13
 1    1396    12226064608 11-APR-13 12226223899 11-APR-13

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
12      Full    4.91G      DISK        00:01:17     11-APR-13      
       BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: FULL_BAK
       Piece Name: /oracle/oradata/rman/full_backup_0co6r2ms_1_1.bak
 List of Datafiles in backup set 12
 File LV Type Ckp SCN    Ckp Time  Name
 ---- -- ---- ---------- --------- ----
 1       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/system01.dbf
 2       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/undo1.dbf
 3       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/sysaux01.dbf
 4       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/user_tbs01.dbf
 5       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/syslog_tbs01_01.dbf
 6       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/syslog_tbs01_02.dbf
 7       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/remove_tbs_01.dbf
 8       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/undo_tbs02_01.dbf
11)重新加载catalog
RMAN> catalog start with '/oracle/oradata/rman/';

Starting implicit crosscheck backup at 12-APR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1092 devtype=DISK
Crosschecked 2 objects
Finished implicit crosscheck backup at 12-APR-13

Starting implicit crosscheck copy at 12-APR-13
using channel ORA_DISK_1
Finished implicit crosscheck copy at 12-APR-13

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

searching for all files that match the pattern /oracle/oradata/rman/

List of Files Unknown to the Database
=====================================
File Name: /oracle/oradata/rman/archivelog_full_0eo6r2pk_1_1.bak
File Name: /oracle/oradata/rman/full_backup_0do6r2ph_1_1.bak

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

List of Cataloged Files
=======================
File Name: /oracle/oradata/rman/archivelog_full_0eo6r2pk_1_1.bak
File Name: /oracle/oradata/rman/full_backup_0do6r2ph_1_1.bak

12)再次查看备份片的状态,确认备份片 Status:是否为 AVAILABLE

RMAN> list backup;


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

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
11      1.48G      DISK        00:00:18     11-APR-13      
       BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20130411T182153
       Piece Name: /oracle/oradata/rman/archivelog_full_0bo6r2m1_1_1.bak

 List of Archived Logs in backup set 11
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    1390    12224517985 11-APR-13 12224779006 11-APR-13
 1    1391    12224779006 11-APR-13 12224993874 11-APR-13
 1    1392    12224993874 11-APR-13 12225256629 11-APR-13
 1    1393    12225256629 11-APR-13 12225541036 11-APR-13
 1    1394    12225541036 11-APR-13 12225807515 11-APR-13
 1    1395    12225807515 11-APR-13 12226064608 11-APR-13
 1    1396    12226064608 11-APR-13 12226223899 11-APR-13

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
12      Full    4.91G      DISK        00:01:17     11-APR-13      
       BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: FULL_BAK
       Piece Name: /oracle/oradata/rman/full_backup_0co6r2ms_1_1.bak
 List of Datafiles in backup set 12
 File LV Type Ckp SCN    Ckp Time  Name
 ---- -- ---- ---------- --------- ----
 1       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/system01.dbf
 2       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/undo1.dbf
 3       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/sysaux01.dbf
 4       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/user_tbs01.dbf
 5       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/syslog_tbs01_01.dbf
 6       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/syslog_tbs01_02.dbf
 7       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/remove_tbs_01.dbf
 8       Full 12226223912 11-APR-13 /oracle/oradata/syslogdb/undo_tbs02_01.dbf

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
13      3.50K      DISK        00:00:00     11-APR-13      
       BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20130411T182347
       Piece Name: /oracle/oradata/rman/archivelog_full_0eo6r2pk_1_1.bak

 List of Archived Logs in backup set 13
 Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
 ---- ------- ---------- --------- ---------- ---------
 1    1397    12226223899 11-APR-13 12226223944 11-APR-13

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
14      Full    14.05M     DISK        00:00:00     11-APR-13      
       BP Key: 14   Status: AVAILABLE  Compressed: NO  Tag: FULL_BAK
       Piece Name: /oracle/oradata/rman/full_backup_0do6r2ph_1_1.bak
 Control File Included: Ckp SCN: 12226223940   Ckp time: 11-APR-13
 SPFILE Included: Modification time: 09-APR-13

13)将controlfile内容trace到指定文件,查看重做日志文件以及数据文件的存放目录都已经创建
SQL> alter database backup controlfile  to trace as '/oracle/oradata/trace_ctl';
Database altered.
14)查看trace文件,并且创建日志文件和数据文件存放目录。

[oracle@mydg oradata]$ cat /oracle/oradata/trace_ctl
...
LOGFILE
 GROUP 1 (
   '/oracle/oradata/syslogdb/redo1_01.log',
   '/oracle/oradata/syslogdb/redo1_02.log'
 ) SIZE 256M,
 GROUP 2 (
   '/oracle/oradata/syslogdb/redo2_01.log',
   '/oracle/oradata/syslogdb/redo2_02.log'
 ) SIZE 256M,
 GROUP 3 (
   '/oracle/oradata/syslogdb/redo3_01.log',
   '/oracle/oradata/syslogdb/redo3_02.log'
 ) SIZE 256M
-- STANDBY LOGFILE

DATAFILE
 '/oracle/oradata/syslogdb/system01.dbf',
 '/oracle/oradata/syslogdb/undo1.dbf',
 '/oracle/oradata/syslogdb/sysaux01.dbf',
 '/oracle/oradata/syslogdb/user_tbs01.dbf',
 '/oracle/oradata/syslogdb/syslog_tbs01_01.dbf',
 '/oracle/oradata/syslogdb/syslog_tbs01_02.dbf',
 '/oracle/oradata/syslogdb/remove_tbs_01.dbf',
 '/oracle/oradata/syslogdb/undo_tbs02_01.dbf'
CHARACTER SET ZHS16GBK
.....
14)还原数据库
RMAN> restore database;

Starting restore at 12-APR-13
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracle/oradata/syslogdb/system01.dbf
restoring datafile 00002 to /oracle/oradata/syslogdb/undo1.dbf
restoring datafile 00003 to /oracle/oradata/syslogdb/sysaux01.dbf
restoring datafile 00004 to /oracle/oradata/syslogdb/user_tbs01.dbf
restoring datafile 00005 to /oracle/oradata/syslogdb/syslog_tbs01_01.dbf
restoring datafile 00006 to /oracle/oradata/syslogdb/syslog_tbs01_02.dbf
restoring datafile 00007 to /oracle/oradata/syslogdb/remove_tbs_01.dbf
restoring datafile 00008 to /oracle/oradata/syslogdb/undo_tbs02_01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/oradata/rman/full_backup_0co6r2ms_1_1.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/oradata/rman/full_backup_0co6r2ms_1_1.bak tag=FULL_BAK
channel ORA_DISK_1: restore complete, elapsed time: 00:01:45
Finished restore at 12-APR-13
15)通过archivelog 恢复数据库,先恢复archivelog
#该操作只是确定能够从那个seq号开始恢复archivelog,这里可以看到能够恢复的archivelog日志seq是从1390开始
RMAN>  restore archivelog all;  

Starting restore at 12-APR-13
using channel ORA_DISK_1

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/12/2013 11:02:44
RMAN-06026: some targets not found - aborting restore
RMAN-06025: no backup of log thread 1 seq 1389 lowscn 12224494423 found to restore
RMAN-06025: no backup of log thread 1 seq 1388 lowscn 12224223200 found to restore
RMAN-06025: no backup of log thread 1 seq 1387 lowscn 12223957661 found to restore
RMAN-06025: no backup of log thread 1 seq 1386 lowscn 12223689194 found to restore
RMAN-06025: no backup of log thread 1 seq 1385 lowscn 12223423961 found to restore
RMAN-06025: no backup of log thread 1 seq 1384 lowscn 12223155831 found to restore
RMAN-06025: no backup of log thread 1 seq 1383 lowscn 12222885213 found to restore
RMAN-06025: no backup of log thread 1 seq 1382 lowscn 12222621025 found to restore
RMAN-06025: no backup of log thread 1 seq 1381 lowscn 12222359545 found to restore
RMAN-06025: no backup of log thread 1 seq 1380 lowscn 12222090062 found to restore
......
MAN-06025: no back
16)恢复archivelog

RMAN> restore archivelog from logseq 1390;

Starting restore at 12-APR-13
using channel ORA_DISK_1

channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1390
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1391
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1392
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1393
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1394
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1395
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1396
channel ORA_DISK_1: reading from backup piece /oracle/oradata/rman/archivelog_full_0bo6r2m1_1_1.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/oradata/rman/archivelog_full_0bo6r2m1_1_1.bak tag=TAG20130411T182153
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=1397
channel ORA_DISK_1: reading from backup piece /oracle/oradata/rman/archivelog_full_0eo6r2pk_1_1.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/oradata/rman/archivelog_full_0eo6r2pk_1_1.bak tag=TAG20130411T182347
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 12-APR-13


17)通过日志恢复数据库,通过resetlogs方式打开数据库

RMAN> recover database until sequence 1398 thread 1;  

Starting recover at 12-APR-13
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 12-APR-13

RMAN> alter database open resetlogs;

database opened

RMAN> exit

One Response


    还没有评论!
1  

Leave your comment

请留下您的姓名(*)

请输入正确的邮箱地址(*)

请输入你的评论(*)


感谢开源 © 2016. All rights reserved.&3Q Open Source&^_^赣ICP备15012863号-1^_^
乐于分享共同进步 KreativeThemes