标签:
一.RMAN备份源库
注意点:
最好保留rman备份日志
$rman target / log=backup.log RMAN>run { allocate channel t1 type disk; allocate channel t2 type disk; allocate channel t3 type disk; allocate channel t4 type disk; backup format ‘<give location of backup/%U>‘ filesperset 8 (database); sql ‘alter system archive log current‘; backup format ‘<give location of backup/%U>‘ fiesperset 8 (archivelog all); backup format ‘<give location of backup/%U>‘ current controlfile; }
二.将备份文件传输到用于恢复的机器
注意点:
在10之前,必须将备份放到相同的路径和目录;10g之后,可以使用catalog命令进行注册。
除了备份文件,还要将参数文件传输过去(当然也可以自己重建)
2.1 创建或修改参数文件
对于参数文件中使用的文件路径目录都要创建好
2.2 创建口令文件
C:\> orapwd file=pwdmdb.ora password=ys0608ys entries=2
2.3 创建oracle services(windows平台需要执行)
C:\> ORADIM -new -sid mdb -intpwd ys0608ys -maxusers 10 -startmode auto -pfile ‘C:\init.ora‘;
三.还原控制文件
> set oracle_sid=mdb > sqlplus /nolog $ connect /as sysdba $ startup nomount pfile=C:\init.ora $ exit > rman target / RMAN> restore controlfile from ‘C:\data\NCCNTRL_20150921_8AQHLUR6_1_1‘ #这一步需要使用到参数文件中对控制文件的配置信息 RMAN> alter database mount;
四.catalog备份信息
如果备份文件的位置和源库上不同,需要进行catalog注册
RMAN> catalog start with ‘备份文件的存放目录‘ noprompt; #会将所有的备份片注册进来 RMAN> crosscheck backup tag ‘<backup tag from backup log>‘ ; #如果有多份备份,将老的备份标记为expired RMAN> delete expired backup; #删除过期的备份
五.还原数据库
RMAN> report schema; #列出schema信息,如果源库和目标库的文件位置或文件名不同,需要使用set newname进行重新设置 RMAN> run{ allocate channel t1 type disk; allocate channel t2 type disk; set newname for datafile 1 to ‘C:\ORACLE\ORADATA\SYSTEM01.DBF‘; set newname for datafile 2 to ‘C:\ORACLE\ORADATA\SYSAUX01.DB‘; set newname for datafile 3 to ‘C:\ORACLE\ORADATA\UNDOTBS01.DBF‘; set newname for datafile 4 to ‘C:\ORACLE\ORADATA\USERS01.DBF‘; set until sequence 24; restore database; switch datafile all; recover database; }
sequence可以从rman备份日志中找到,或者查看v$backup_redolog
六.重命名redo文件
SQL> set lines 200 col member format a60 select a.thread#,a.group#,b.type,b.member,a.bytes/1048576 from v$log a,v$logfile b where a.group#=b.group# order by a.group#; SQL> alter database rename file ‘<old file location and name>‘ to ‘<new location and name>‘;
确认一下
SQL> select a.thread#,a.group#,b.type,b.member,a.bytes/1048576 from v$log a,v$logfile b where a.group#=b.group# order by a.group#;
七.重命名temp文件
SQL> alter database rename tempfile ‘D:\APP\ADMINISTRATOR\ORADATA\mdb\TEMP01.DBF‘ to ‘C:\ORACLE\ORADATA\TEMP01.DBF‘
八.打开数据库
SQL> alter database open resetlogs; SQL> create spfile from pfile; SQL> shutdown immediate SQL> startup
标签:
原文地址:http://www.cnblogs.com/abclife/p/4825999.html