脚踏实地、勇往直前!
全部博文(1005)
分类: Oracle
2012-06-29 14:02:01
[oracle@hxlbak ~]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jun 29 06:51:54 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN>set dbid 1820932955 -- 这里的dbid需要跟原库保持一致
RMAN> startup nomount
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initoracl.ora'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area 159383552 bytes
Fixed Size 1218268 bytes
Variable Size 54528292 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
RMAN> restore spfile to pfile '/u01/app/oracle/product/10.2.0/db_1/dbs/initoracl.ora' from '/u02/ftp/full_backup_20120628_37';
Starting restore at 29-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: autobackup found: /u02/ftp/full_backup_20120628_37
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 29-JUN-12
备份集full_backup_20120628_3里7包含了参数文件,我们在备份数据的时候会默认备份参数文件,可以在原库使用list backup查看,list backup输出部分内容如下:
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
35 Full 80.00K DISK 00:00:01 28-JUN-12
BP Key: 35 Status: AVAILABLE Compressed: NO Tag: TAG20120628T184555
Piece Name: /u02/rman_backup/full_backup/full_backup_20120628_37
SPFILE Included: Modification time: 28-JUN-12
恢复了参数文件initoracl.ora后,因为原库和目的库各文件保存的路径不一致,这个时候需要修改参数文件,修改的地方如下,各文件路径指向新目录:
*.audit_file_dest='/u02/mydb/oracl/adump'
*.background_dump_dest='/u02/mydb/oracl/bdump'
*.control_files='/u02/mydb/oradata/oracl/control01.ctl','/u02/mydb/oradata/oracl/control02.ctl','/u02/mydb/oradata/oracl/control03.ctl'
*.core_dump_dest='/u02/mydb/oracl/cdump'
*.db_recovery_file_dest='/u02/mydb/flash_recovery_area'
*.user_dump_dest='/u02/mydb/oracl/udump'
7.使用编辑好的参数文件启动数据库到nomount状态并恢复控制文件
SQL> startup nomount pfile=/u01/app/oracle/product/10.2.0/db_1/dbs/initoracl.ora
ORACLE instance started.
Total System Global Area 1048576000 bytes
Fixed Size 1223368 bytes
Variable Size 310379832 bytes
Database Buffers 734003200 bytes
Redo Buffers 2969600 bytes
SQL>
恢复控制文件
RMAN> restore controlfile from '/u02/ftp/full_backup_20120628_36';
Starting restore at 29-JUN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:05
output filename=/u02/mydb/oradata/oracl/control01.ctl
output filename=/u02/mydb/oradata/oracl/control02.ctl
output filename=/u02/mydb/oradata/oracl/control03.ctl
Finished restore at 29-JUN-12
跟参数文件一样,在备份数据的时候会默认备份了控制文件,备份集full_backup_20120628_36中包含了控制文件,同样可以在原库使用list backup查看,list backup输出部分内容如下:
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
34 Full 6.98M DISK 00:00:02 28-JUN-12
BP Key: 34 Status: AVAILABLE Compressed: NO Tag: TAG20120628T184555
Piece Name: /u02/rman_backup/full_backup/full_backup_20120628_36
Control File Included: Ckp SCN: 1545845 Ckp time: 28-JUN-12
8.启动数据库到mount状态并注册备份集
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
注册备份集,因为控制文件中的保留的备份信息是原库的,我们这里需要重新注册新库路径下的备份集
RMAN> catalog start with '/u02/ftp/';
Starting implicit crosscheck backup at 29-JUN-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 29 objects
Finished implicit crosscheck backup at 29-JUN-12
Starting implicit crosscheck copy at 29-JUN-12
using channel ORA_DISK_1
Finished implicit crosscheck copy at 29-JUN-12
searching for all files in the recovery area
cataloging files...
no files cataloged
searching for all files that match the pattern /u02/ftp/
List of Files Unknown to the Database
=====================================
File Name: /u02/ftp/full_backup_20120628_35
File Name: /u02/ftp/full_backup_20120628_37
File Name: /u02/ftp/full_backup_20120628_34
File Name: /u02/ftp/arc_backup_20120628_38
File Name: /u02/ftp/arc_backup_20120628_40
File Name: /u02/ftp/full_backup_20120628_36
File Name: /u02/ftp/full_backup_20120628_31
File Name: /u02/ftp/full_backup_20120628_33
File Name: /u02/ftp/arc_backup_20120628_39
File Name: /u02/ftp/full_backup_20120628_32
File Name: /u02/ftp/full_backup_20120628_30
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/ftp/full_backup_20120628_35
File Name: /u02/ftp/full_backup_20120628_37
File Name: /u02/ftp/full_backup_20120628_34
File Name: /u02/ftp/arc_backup_20120628_38
File Name: /u02/ftp/arc_backup_20120628_40
File Name: /u02/ftp/full_backup_20120628_36
File Name: /u02/ftp/full_backup_20120628_31
File Name: /u02/ftp/full_backup_20120628_33
File Name: /u02/ftp/arc_backup_20120628_39
File Name: /u02/ftp/full_backup_20120628_32
File Name: /u02/ftp/full_backup_20120628_30
9.列出当前的所有数据文件