Chinaunix首页 | 论坛 | 博客
  • 博客访问: 254811
  • 博文数量: 59
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 698
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-19 21:17
文章分类

全部博文(59)

文章存档

2009年(14)

2008年(45)

我的朋友

分类: Oracle

2008-11-14 10:06:53

今天早上恢复了一个测试库。该测试库中有比较重要的系统测试数据,记得以前使用rman做过备份。
1)先建了一个参数文件,nomount后,利用已经备份的控制文件去恢复控制文件。
SQL>startup nomount pfile=/oracle/oradata/initantiper.ora
RMAN>restore controlfile from '/oracle/recv/ANTIPER_29.bak';
该控制文件恢复到参数文件中指定的地方。
2)mount数据库。
当执行restore database的时候,报错:
RMAN> restore database;
Starting restore at 14-8ÔÂ -08
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=35 devtype=DISK
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +DISKGP1/antiper/datafile/system.260.662520081
restoring datafile 00002 to +DISKGP1/antiper/datafile/users03.dbf
restoring datafile 00003 to +DISKGP1/antiper/datafile/sysaux.262.662520107
restoring datafile 00004 to +DISKGP1/antiper/datafile/users.264.662520137
restoring datafile 00005 to +DISKGP1/antiper/datafile/undotbs201.dbf
restoring datafile 00006 to +DISKGP1/antiper/datafile/user02.dbf
channel ORA_DISK_1: reading from backup piece /oracle/recv/ANTIPER_24.bak
ORA-19870: error reading backup piece /oracle/recv/ANTIPER_24.bak
ORA-19504: failed to create file "+DISKGP1"
ORA-17502: ksfdcre:4 Failed to create file +DISKGP1
ORA-15001: diskgroup "DISKGP1" does not exist or is not mounted
ORA-15077: could not locate ASM instance serving a required diskgroup
failover to previous backup
creating datafile fno=1 name=+DISKGP1/antiper/datafile/system.260.662520081
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 08/14/2008 21:58:12
ORA-01180: can not create datafile 1
ORA-01110: data file 1: '+DISKGP1/antiper/datafile/system.260.662520081'
3)这才发现以前的数据库是asm管理的文件系统,于是我就做了如下的转换:
run
{
set newname for datafile 1 to '/oracle/oradata/system01.dbf';
set newname for datafile 2 to '/oracle/oradata/users01.dbf';
set newname for datafile 3 to '/oracle/oradata/sysaux01.dbf';
set newname for datafile 4 to '/oracle/oradata/users03.dbf';
set newname for datafile 5 to '/oracle/oradata/undotbs01.dbf';
set newname for datafile 6 to '/oracle/oradata/users02.dbf';
restore database;
switch datafile all;
}
4)数据库还原后,就开始恢复啊,
RMAN> recover database;
Starting recover at 14-8ÔÂ -08
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /oracle/oradata/system01.dbf
destination for restore of datafile 00002: /oracle/oradata/users01.dbf
destination for restore of datafile 00003: /oracle/oradata/sysaux01.dbf
destination for restore of datafile 00004: /oracle/oradata/users03.dbf
destination for restore of datafile 00005: /oracle/oradata/undotbs01.dbf
destination for restore of datafile 00006: /oracle/oradata/users02.dbf
channel ORA_DISK_1: reading from backup piece /oracle/recv/ANTIPER_28.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/recv/ANTIPER_28.bak tag=TAG20080814T074250
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
starting media recovery
media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 08/14/2008 22:35:19
ORA-00283: recovery session canceled due to errors
RMAN-11003: failure during parse/execution of SQL statement: alter database recover if needed
 start until cancel using backup controlfile
ORA-00283: recovery session canceled due to errors
ORA-38760: This database instance failed to turn on flashback database
5)我又检查了下,对这个错误ORA-38760我是比较感兴趣,呵呵
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-38760: This database instance failed to turn on flashback database
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /oracle/10g/db/dbs/arch
Oldest online log sequence     23
Next log sequence to archive   25
Current log sequence           25
SQL> select flashback_on from v$database;
FLASHBACK_ON
------------------------------------
YES
这才发现因为数据库的闪回是打开的,但是还没有设置闪回目录以及闪回区的大小,那么我就开始恢复spfile呀,
然后用spfile去启动数据库。
6)RMAN> restore spfile;
Starting restore at 14-8ÔÂ -08
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: restoring SPFILE
output filename=/oracle/10g/db/dbs/spfileantiper.ora
channel ORA_DISK_1: reading from backup piece /oracle/recv/ANTIPER_29.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/oracle/recv/ANTIPER_29.bak tag=TAG20080814T074250
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 14-8ÔÂ -08
启动数据库到mount
SQL> startup mount
ORA-09925: Unable to create audit trail file
Linux Error: 2: No such file or directory
Additional information: 9925
创建了如下文件
/oracle/oradata/init.ora
内容如下:
spfile=/oracle/10g/db/dbs/spfileantiper.ora
*.audit_file_dest='/oracle/admin/antiper/adump'
*.background_dump_dest='/oracle/admin/antiper/bdump'
*.control_files='/oracle/oradata/control01.ctl'
*.core_dump_dest='/oracle/admin/antiper/cdump'
*.db_create_file_dest='/oracle/oradata'
*.user_dump_dest='/oracle/admin/antiper/udump'
重新加载数据库
startup mount pfile=/oracle/oradata/init.ora
SQL> startup mount pfile=/oracle/oradata/init.ora
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size             109054196 bytes
Database Buffers           54525952 bytes
Redo Buffers                2973696 bytes
Database mounted.
7)在rman下恢复数据库
RMAN> recover database;
Starting recover at 14-8ÔÂ -08
Starting implicit crosscheck backup at 14-8ÔÂ -08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=209 devtype=DISK
Crosschecked 8 objects
Finished implicit crosscheck backup at 14-8ÔÂ -08
Starting implicit crosscheck copy at 14-8ÔÂ -08
using channel ORA_DISK_1
Crosschecked 1 objects
Finished implicit crosscheck copy at 14-8ÔÂ -08
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 24 is already on disk as file /oracle/recv/ANTIPER/archivelog/2008_08_14/o1_mf_1_24_4b86ltd3_.arc
archive log filename=/oracle/recv/ANTIPER/archivelog/2008_08_14/o1_mf_1_24_4b86ltd3_.arc thread=1 sequence=24
unable to find archive log
archive log thread=1 sequence=25
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 08/14/2008 22:49:37
RMAN-06054: media recovery requesting unknown log: thread 1 seq 25 lowscn 1159353
8)RMAN> list backup of archivelog all;
List of Backup Sets
===================
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
13      2.79M      DISK        00:00:02     14-8ÔÂ -08    
        BP Key: 15   Status: AVAILABLE  Compressed: NO  Tag: TAG20080814T073557
        Piece Name: /oracle/recv/ANTIPER_23_1.bak
  List of Archived Logs in backup set 13
  Thrd Seq     Low SCN    Low Time   Next SCN   Next Time
  ---- ------- ---------- ---------- ---------- ---------
  1    20      1154846    14-8ÔÂ -08 1155561    14-8ÔÂ -08
  1    21      1155561    14-8ÔÂ -08 1159063    14-8ÔÂ -08
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
16      2.00K      DISK        00:00:00     14-8ÔÂ -08    
        BP Key: 18   Status: AVAILABLE  Compressed: NO  Tag: TAG20080814T073643
        Piece Name: /oracle/recv/ANTIPER_26_1.bak
  List of Archived Logs in backup set 16
  Thrd Seq     Low SCN    Low Time   Next SCN   Next Time
  ---- ------- ---------- ---------- ---------- ---------
  1    22      1159063    14-8ÔÂ -08 1159086    14-8ÔÂ -08
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
17      2.87M      DISK        00:00:01     14-8ÔÂ -08    
        BP Key: 19   Status: AVAILABLE  Compressed: NO  Tag: TAG20080814T074248
        Piece Name: /oracle/recv/ANTIPER_27_1.bak
  List of Archived Logs in backup set 17
  Thrd Seq     Low SCN    Low Time   Next SCN   Next Time
  ---- ------- ---------- ---------- ---------- ---------
  1    20      1154846    14-8ÔÂ -08 1155561    14-8ÔÂ -08
  1    21      1155561    14-8ÔÂ -08 1159063    14-8ÔÂ -08
  1    22      1159063    14-8ÔÂ -08 1159086    14-8ÔÂ -08
  1    23      1159086    14-8ÔÂ -08 1159337    14-8ÔÂ -08
BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
20      4.50K      DISK        00:00:01     14-8ÔÂ -08    
        BP Key: 22   Status: AVAILABLE  Compressed: NO  Tag: TAG20080814T074325
        Piece Name: /oracle/recv/ANTIPER_30_1.bak
  List of Archived Logs in backup set 20
  Thrd Seq     Low SCN    Low Time   Next SCN   Next Time
  ---- ------- ---------- ---------- ---------- ---------
  1    24      1159337    14-8ÔÂ -08 1159353    14-8ÔÂ -08
看来只有做不完全恢复了,因为25的日志文件根本就没有备份呀。
RMAN> recover database until logseq 25;
Starting recover at 14-8ÔÂ -08
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 14-8ÔÂ -08
9)在sql环境下打开数据库
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
Database altered.
至此该数据库恢复完成了。
阅读(11287) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~