说明:
1、操作系统:oracle_linux_5.6_32
2、数据库:oracle_11.2.0.3 两台单实例数据库。
3、本例子是在一台数据库坏掉的情况下,将我们的备份恢复到另一台相同平台的数据库上。
注意:
另外一台服务器只需要安装数据库软件,不需要建库。因为我们是从原库恢复过来。
演示步骤如下:
(1)
获得源数据库的DBID:
[oracle@RAC1 ~]$ rman target /
connected to target database: RAC1 (DBID=736017170)
(2)
用rman做一次全备
RMAN> backup database format '/backup/2013_11_13_2112_%U.bak';
这时会生成两个备份集,一个是DBF的一个是控制文件和参数文件的。
(3)
将上面的两个文件传到第二台服务器,还是放在一个/backup目录下,注意授权。
不管你用什么办法,只要能做到就行。(比如什么xftp工具、scp命令、拖拽、还是拷贝)
(4)
在第二台服务器上,装一个oracle软件,不装数据库,注意基本配置与原库相同。
这里说的基本配置就是指尽量在装的时候按照原库的步骤和操作来。
(5)
当第二台服务器上装好oracle软件时,可以执行:
RMAN> set dbid 736017170;
(6)
目标库:
RMAN> startup nomount;
(7)
还原参数文件
RMAN> restore spfile to pfile '/u01/app/oracle/product/10.2.0/db_1/dbs/initrac1.ora'
from '/backup/2013_11_13_2112_11opt80p_1_1.bak';
(8)
这一步本可省略,如果在下一步中报错说某些路径不存在,那就做这一步:
[root@RAC2 ~]# mkdir -p /u01/app/oracle/admin/rac1/adump
[root@RAC2 ~]# chown -R oracle:oinstall /u01/app/oracle/admin/rac1/adump
[root@RAC2 ~]# mkdir -p /u01/app/oracle/admin/rac1/udump
[root@RAC2 ~]# chown -R oracle:oinstall /u01/app/oracle/admin/rac1/udump
[root@RAC2 backup]# mkdir -p /u01/app/oracle/admin/rac1/bdump
[root@RAC2 backup]# chown -R oracle:oinstall /u01/app/oracle/admin/rac1/bdump/
(9)
用我们恢复出来的参数文件强制启动到nomount状态
RMAN> startup force nomount pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initrac1.ora';
Oracle instance started
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 83887696 bytes
Database Buffers 197132288 bytes
Redo Buffers 2973696 bytes
(10)
还远控制文件:
RMAN> restore controlfile from '/backup/2013_11_13_2112_11opt80p_1_1.bak';
Starting restore at 13-NOV-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output filename=/u01/app/oracle/oradata/rac1/control01.ctl
output filename=/u01/app/oracle/oradata/rac1/control02.ctl
output filename=/u01/app/oracle/oradata/rac1/control03.ctl
Finished restore at 13-NOV-13
(11)
启动数据库到mount状态。
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
(12)
还原数据库:
RMAN> restore database;
Starting restore at 13-NOV-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 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 /u01/app/oracle/oradata/rac1/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/rac1/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/rac1/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/rac1/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/rac1/example01.dbf
channel ORA_DISK_1: reading from backup piece /backup/2013_11_13_2112_10opt7u0_1_1.bak
channel ORA_DISK_1: restored backup piece 1
piece handle=/backup/2013_11_13_2112_10opt7u0_1_1.bak tag=TAG20131126T041248
channel ORA_DISK_1: restore complete, elapsed time: 00:01:46
Finished restore at 13-NOV-13
(13)
恢复数据库:
RMAN> recover database;
Starting recover at 13-NOV-13
using channel ORA_DISK_1
starting media recovery
unable to find archive log
archive log thread=1 sequence=1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/13/2013 14:56:30
RMAN-06054: media recovery requesting unknown log: thread 1 seq 1 lowscn 572731
注意:
报错了,但是没关系,并非严重错误,只是提醒你恢复到一个未知的scn 号。如果要避免这
个错误,可以在alter database mount 之后,通过set until scn 或者set until time 命令设置恢复
到的scn 号或时间。
(14)
打开数据库,确实是可以打开的。
RMAN> alter database open resetlogs;
database opened
(15)
查看当前实例状态:
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
rac1 OPEN
(16)
查看数据:确实没有丢。
SQL> conn scott/tiger
Connected.
SQL> select * from zsx;
ID
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected.
(17)
成功了,哈哈,如果发现没有临时表空间,记得重建。
(18)
记得创建密码文件:
[oracle@RAC2 bdump]$ orapwd file=$ORACLE_HOME/dbs/orapwd$ORACLE_SID password=oracle entries=5
(19)
进行一次全备。
(20)
感谢!
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29107230/viewspace-1062275/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29107230/viewspace-1062275/